#include #include #include #include "common.h" #define INFINITY (2100000000) using namespace std; const int MMDEPTH=2; void search(int *best,Board &bd,int me,int win,int depth=MMDEPTH){ int i; if(win!=-1||depth<=0){ for(i=0;ibest[me]){ memcpy(best,res,NPLAYERS*sizeof(int)); } } } #if 1 Move calcmove(Board &bd,int me){ int i; int score,maxscore=INT_MIN,maxat=-1; int res[NPLAYERS]; for(i=0;imaxscore){ maxscore=score; maxat=i; } } return Move(maxat); } #else Move calcmove(Board &bd,int me){ if(bd.totalballcount()<2*NPLAYERS){ if(bd.getballs(0)==0)return 0; if(bd.getballs(WID-1)==0)return WID-1; if(bd.getballs(WID*(HEI-1))==0)return WID*(HEI-1); if(bd.getballs(WID*HEI-1)==0)return WID*HEI-1; } struct Item{ Board bd; int score,i; }; Item items[WID*HEI]; int i; for(i=0;ibool{ return i1.score>i2.score; }); int res[NPLAYERS]; int maxscore=-1,maxat=-1; for(i=0;items[i].score>=items[0].score*9/10&&imaxscore){ maxscore=res[me]; maxat=items[i].i; } } return Move(maxat); } #endif 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<