FS 03 /HOW MAKE IT: very shortly PICTORIAL GUIDE after GOMOKU ENGINE code
go on: < previous page this page 21/30pred_x next page >


game board
summary

sumx and sumo
sumx to xmap
xmap between x add
xmap between x less
xmap more samples
zeroX and zeroO
xmap editing
x_plus and middx
x_plus and zeroX
x_away and o_away
xRCboard and liftx
xRCboard add & less
xmap to lagx
lagx 5000 & x_away
lagx 100 & x_away
lagx 10 and lagx 1
lagx to x_tack
xRCboard allways
flagx allways

delayx
dilayx
pred_x
pred_x to xmap
choose from flagx
more delay
more delay samples
three
crossmix
more delay use
flag to RCboard

summary

Search special sequences of squares with using information from arrays "matRCboard" and "x_tack". This sequence in blue borders contains sign "x". Therefore value for record to array "pred_x" is 10.




Inside this sequence isn't sign "x". Therefore value for record to array "pred_x" is 1.




Rule 1 (more combination) for "pred" (prediction) sequence of squares: from array "x_tack" reads only information about direction. Inside sequence don't accept squares value with the same direction like a actual searching direction.




Rule 2 for (more combination) "pred" sequence of squares: (squares 1 and 6 must be free)

examples in C++
search "predict" structures in horizontal ( - ) direction:
for (row = 0; row < 19; row++) {
  for (column = 0; column < 19; column++) {
    mat = matRCboard[row][column], mat5 = matRCboard[row][(column + 5)];
    border = (19 - 1) - column;  //if (border == 0) end of game area (last square)
    if(border > 3)) {
      for (loop = 0; loop < 5; loop++) {  //search in horizontal direction >>
        write = column + loop;
        switch(matRCboard[row][write]) {
            case 'X': sumx++, xosum++; break;
            case 'O': sumo++, xosum++; break;
            case 'N': switch(x_tack[row][write]) {
                          case 0: break;
                          case 1: break;
                         case 10: break;
                        case 100: break;
                         default: lagx++;  //400,300,200,40,30,20,4,3,2
                      }
                      //switch(o_tack[column][write]) {...}
                      if((column == write) && (lagx > 0)) bacx = 1;
                      //if((column == write) && (lago > 0)) ...
        }
      }
    }  //if (border)
    sum_lagx = sumx + lagx;
    //sum_lago = ...
    //rules:
    if((sumx == xosum) && (sumx < 3) && (sum_lagx == 3) && (border > 3)) predictx = 1;
    if((sumx == xosum) && (sumx < 2) && (sum_lagx == 2) && (bacx == 0) && (border > 4) {
     if((mat == 'N') && (mat5 == 'N')) predictx = 1, xshift = 1;
    }
    if((predictx > 0) && (sumx > 0)) predictx *= 10;
    //if( ... ) predicto = 1;
and write values to arrays "pred":
    if(predictx > 0) {
      for(loop = 0; loop < 5; loop++) {  //search in horizontal direction >>
        write = column + loop;
        if((x_tack[row][write] == 0) && (column == write) && (xshift > 0)) continue;
        if((x_tack[row][write] == 0) && (matRCboard[row][write] == 'N') {
         if((pred_x[row][write] < predictx)) pred_x[row][write] = predictx;
      }
    }
    //if((delayo == 1) { ... }
    //reset counters (sumx = xosum = lagx = predictx = bacx = xhift = 0, sumo = ...)
  }
}
add values from other direction (perhaps horizontal add vertical) to "pred_x" array:
//search in vertical direction
//...
//if(...)xtemporal[][] = predictx;
//...
pred_x[][] += xtemporal[][];
xtemporal[][] = 0;
//...
go on: < previous page next page >
FREE SECTOR, 2014 (free alliance of developers Pixoria gomoku plug-in engines) page 21/30