| FS 03 /HOW MAKE IT: very shortly PICTORIAL GUIDE after GOMOKU ENGINE code | |||||
| go on: | < previous page
|
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 |
This exception is for defence of player. In this sample engine is first (X) player and his top "flag" value is 1000. Second player (O) have "three" structure (NNOOONN), consequently two squares with "flag" value bigger than best "flag" value of first player. Shortly second (O) player has two better moves than first (X) player. But if one of them is on the same square position with the best move of first (X) player, he have effective defence. If engine detect such common square in "flag" arrays, increase value in his "flag" array (here "flagx") on value 9999 (higher than best value of second player). More about "three" structure: see previous page.
The same sample as above-mentioned, but without "three" structure.
Next exception for defence. Only for engine as second (O) player. Best values for both players in their "flag" arrays is 100, and one of them has common square position. If engine detect such common square in "flag" arrays, increase value on this position in "flago" array (9999).
In this sample have second (O) player higher "flag" value (200) than first player (100). Condition for exception here so is not perform.
Last exception for defence. Only for engine as second (O) player. First (X) player have "three" structure and: maximum "flagx" value of first player is 5000 and maximum "flago" value of second (O) player is lower than 2000. Therefore in "flagx" array must exist two (more) squares with maximum (5000) value ("three" structure"), better is square with higher value on the same position in the araray "flago". On this position increase "flagx" value on 9999. If also both values in array "flago" they are identical (for example: 0, 0), increase both values in "flagx" array" (9999, 9999).
|
||||
|
examples in C++
Search top values in arrays "flagx" and "flago": //int xmax = 0; //flagx: maximum value //int omao = 0; //flago: maximum value //int xmax_o = 0; //maximum flagx value: maximum flago value on the same square //int omax_x = 0; //maximum flago value: maximum flagx value on the same squareSearch crossmix exception. If yes, change values in "flag" arrays: //(special exceptions)--------------------------------------------------------------------
//if(who == 1) you are first player (X)
//if(who == 0) you are second player (O)
//threex: count of sequences NNXXXNN
//crossmix 1:
xshift = oshift = 0;
if((who == 1) && (xmax > 999) && (xmax < 2000) && (omax > 4999) && (omax_x > 999)) {
xshift = 1;
}
if((who == 0) && (omax > 999) && (omax < 2000) && (xmax > 4999) && (xmax_o > 999)) {
oshift = 1;
}
//crossmix 2:
if((who == 0) && (omax > 99) && (omax < 101) && (omax == xmax) && (omax == omax_x)) {
xshift = 1;
}
//crossmix 3:
if((who == 0) && (xmax == 5000) && (threex > 0) && (omax < 2000)) xshift = 2;
//----------------------------------------------------------------------------------------
for(row = 0; row < rcmax; row++) {
for(column = 0; column < rcmax; column++) {
if((xshift == 1) && (flago[row][column] == omax) && (flagx[row][column] == omax_x)) {
flago[row][column] = 9999;
}
if((oshift == 1) && (flagx[row][column] == xmax) && (flago[row][column] == xmax_o)) {
flagx[row][column] = 9999;
}
if((xshift == 2) && (flagx[row][column] == xmax) && (flago[row][column] == xmax_o)) {
flagx[row][column] = 9999;
}
}
}
|
|||||
| go on: | < previous page | next page > | |||
| FREE SECTOR, 2014 (free alliance of developers Pixoria gomoku plug-in engines) | page 27/30 | ||||