FS 05 /HOW MAKE IT: very shortly PICTORIAL GUIDE after GOMOKU ENGINE code
go on: < previous page this page 14/16three: better end next page >


game board
summary

flagx add ten
flagx values
M+ in line /001
M+ in line /002
M+ in line /003
M+ in line /004
LastMove /001
LastMove /002
predict low now
predict high now
2d delay, dilay
more delay now
dilay +, delay +
three: better end
strategy FS05

summary

Engine is first (X) player in defensive situation. Second (O) player has "three" structure and so in "flago" array is two highest value 2000. Engine must choose only one square (end of three) for next move.
For "flagx" values: see page 02. More about "three" structure: see pages FS03 (26)





For choose better end engine searching near surroundings of both ends (nine squares). Squares on border of game area engine ignore. If one from near ends contains more "O" signs, than the other, so is better. In this example both near ends contains the same amount of "O" signs and engine therefore continue in testing.




Now engine search in the both near ends on array "flago" squares with values higher than 99. Sum this "flago" values have both near ends here the same and engine therefore continue in testing.




Last test: engine searching near ends on array "x_tack". First near end contains two squares with "predict" value. Second near end contains that squares three, therefore ist now better second end.




examples in C++
search better end of three:
//...
//x_tack[row][nextcol] += 500;  //label: here is the end of three
//threex++  //counter of this structures: -XXX-- (--XXX-)
//...
//if((threex == 1) || (threeo == 1))  {          
//  liftx = bacx = skinx = skipx = tiffx = sud0 = sud1 = 0;
//  middx = lagx = xshift = ashiftx = x_pluso = 0;
//...
//  for (row = 0; row < rcmax; row++) {  //rcmax = 19;
//      if((row == 0) || (row == 18)) continue;
//  for (column = 0; column < rcmax; column++) {
//      if((column == 0) || (column == 18)) continue;
        if((x_tack[row][column] > 499) && (x_tack[row][column] < 1000)) {
          if(flagx[row][column] < 2100) {  //here is the end of threex
            sumx = sumo = sumonx = sumono = predictx = predicto = 0;
            liftx++;
//search in block 3x3 squares: start
            for (write = (row - 1); write < (row + 2); write++) {
            for (vcite = (column - 1); vcite < (column + 2); vcite++) {
                switch(matRCboard[write][vcite]) {
                       case 'X': sumx++; break;
                     //case 'O': sumo++; break;
                       case 'N': if(x_tack[write][vcite] > 1000) middx++;
                                 if(flagx[write][vcite] > 99)  {
                                   sumonx += flagx[write][vcite];
                                   }
                       } //switch
  	        } //for vcite
  	        } //for write
//search in block 3x3 squares: end
            if(liftx == 1) {  //first end of three
              bacx = sumx, x_pluso = sumo, skipx = sumonx, xshift = middx;
              xtemporal[row][column] = 1, tiffx = 2;
              }
            if(liftx == 2) {  //second end of three
              sud0 = sud1 = 0;
              if((bacx*1000 + skipx) > (sumx*1000 + sumonx)) sud0++;
              if((sumx*1000 + sumonx) > (bacx*1000 + skipx)) sud1++;
              if(sud0 > sud1) tiffx = 1;  //sud0 (first end), sud1 (second end)
              if(sud0 < sud1) xtemporal[row][column] = 2;
              if(sud0 == sud1) {
                sud0 = sud1 = 0;
                if(xshift > middx) sud0++;
                if(middx > xshift) sud1++;
                if(sud0 > sud1) tiffx = 1;  //sud0 (first end), sud1 (second end)
                if(sud0 < sud1) xtemporal[row][column] = 2;
                }
              }  //if(liftx)
            }  //if(threex here)
          }
//...
//      }  //for
//      }  //for
//...
//  } //if threes

use better end of three:
//...
//for (row = 0; row < rcmax; row++) {
//for (column = 0; column < rcmax; column++) {
//...
//here is better end of three:
 if ((threex == 1) && (tiffx > 0) && (xtemporal[row][column] == tiffx));
//...
go on: < previous page next page >
FREE SECTOR, 2016 (free alliance of developers Pixoria gomoku plug-in engines) page 14/16