void getmove() { int i, c; c = 0; for (;;) { i = checkmove(c); switch (i) { case -1: if (movokay(mvlim)) { move(20, 0); for (i = 0; i < mvlim; i++) if (h[i]) wrhit(g[i]); nexturn(); if (*offopp == 15) cturn *= -2; return; } case -4: case 0: refresh(); if (i != 0 && i != -4) break; mvaddstr(20, 0, *Colorptr); if (i == -4) addstr(" must make "); else addstr(" can only make "); printw("%d move%s.\n", mvlim, mvlim > 1 ? "s":""); break; case -3: if (quit()) return; } move(cturn == -1 ? 18 : 19, 39); clrtoeol(); c = -1; } }
getmove () { register int i, c; c = 0; for (;;) { i = checkmove(c); switch (i) { case -1: if (movokay(mvlim)) { if (tflag) curmove (20,0); else writec ('\n'); for (i = 0; i < mvlim; i++) if (h[i]) wrhit(g[i]); nexturn(); if (*offopp == 15) cturn *= -2; if (tflag && pnum) bflag = pnum; return; } case -4: case 0: if (tflag) refresh(); if (i != 0 && i != -4) break; if (tflag) curmove (20,0); else writec ('\n'); writel (*Colorptr); if (i == -4) writel (" must make "); else writel (" can only make "); writec (mvlim+'0'); writel (" move"); if (mvlim > 1) writec ('s'); writec ('.'); writec ('\n'); break; case -3: if (quit()) return; } if (! tflag) proll (); else { curmove (cturn == -1? 18: 19,39); cline (); c = -1; } } }
int gpAiTwo::solve(int cid, int depth, int pq) { bool usefulmoves=false; bool keeploop=true; if(depth==0) { stat_simmoves=0; stat_allmoves=0; } // Pamiętana ocena ruchu int mq; if(cid==id) mq=INT_MIN; else mq=INT_MAX; if(depth==0) { static XYPos movelist[19*19]; // Przygotowanie listy ruchów for(int x=0; x<xysize; x++) for(int y=0; y<xysize; y++) { movelist[y*xysize+x].x=x; movelist[y*xysize+x].y=y; } for(int i=0; i<xysize*xysize; i++) { int src, dest; src=rand()%(xysize*xysize); dest=rand()%(xysize*xysize); XYPos t; t=movelist[src]; movelist[src]=movelist[dest]; movelist[dest]=t; } // Ruch na podstawie listy for(int i=0; i<xysize*xysize && keeploop; i++) { int x=movelist[i].x; int y=movelist[i].y; int status=checkmove(x,y,cid,depth,mq,pq); if(status & gpAiTwo_USEFUL) usefulmoves=true; if(status & gpAiTwo_BREAK) keeploop=false; } if(!usefulmoves) { // poszukaj ruchu heurystycznie int maxol=0; for(int i=0; i<xysize*xysize; i++) { int x=movelist[i].x; int y=movelist[i].y; if(board->field(x,y)!=0) continue; int ol=0, el=0; oelcalc(ol, el, x, y, cid); if(ol>maxol) { maxol=ol; mmove.x=x; mmove.y=y; usefulmoves=true; } } } } else { for(int x=0; x<xysize && keeploop; x++) for(int y=0; y<xysize && keeploop; y++) { int status=checkmove(x,y,cid,depth,mq,pq); if(status & gpAiTwo_USEFUL) usefulmoves=true; if(status & gpAiTwo_BREAK) keeploop=false; } } if(depth==0) { printf("stat_simmoves: %d\n", stat_simmoves); printf("stat_allmoves: %d\n", stat_allmoves); } if(!usefulmoves) mq=0; return mq; }