diff options
Diffstat (limited to 'player_d1.cpp')
-rw-r--r-- | player_d1.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/player_d1.cpp b/player_d1.cpp new file mode 100644 index 0000000..cf1e6e9 --- /dev/null +++ b/player_d1.cpp @@ -0,0 +1,46 @@ +#include <iostream> +#include <string> +#include <sys/time.h> +#include "common.h" + +using namespace std; + +Move calcmove(Board &bd,int me){ + int i; + int count,maxcount=-1,maxat=0; + for(i=0;i<WID*HEI;i++){ + Board bd2=bd; + bd2.put(i,me); + count=bd2.ballcount(me); + if(count>maxcount){ + maxcount=count; + maxat=i; + } + } + return Move(maxat%WID,maxat/WID); +} + +int main(void){ + struct timeval tv; + gettimeofday(&tv,NULL); + srand(tv.tv_sec*1000000+tv.tv_usec); + + Board bd; + char c; + Move mv; + cin>>c; cin.ignore(1024,'\n'); + int me=c-'A'; + int x,y,i; + while(true){ + c=cin.peek(); + if(c=='q'||c=='Q')break; + for(i=me+1;i%NPLAYERS!=me;i++){ + cin>>x>>y; + if(x!=-1&&y!=-1)bd.put(x,y,i%NPLAYERS); + } + cin.ignore(1024,'\n'); + mv=calcmove(bd,me); + cout<<mv.x<<' '<<mv.y<<endl; + bd.put(mv.idx(),me); + } +} |