| FS 05 /HOW MAKE IT: very shortly PICTORIAL GUIDE after GOMOKU ENGINE code | |||||
| go on: | < previous page
|
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 search sequences of squares wit this fourteen sign (X,M,C) combinations. Maximal number of signs must be three or two. To free (N) squares os sequence engine record value according thist arithmetic of signs: For sign X sum value 100, for M value 10 and for sign C value 1. Signs M and C they are values of array "x_tack" ("flagx") from different directions than actual.
If in sequence engine change all signs M or C behind X, this sequence will be now "donor" for sequences from another directions. Sequence with three signs (number X, M, C) will have on free squares signs M in actual direction (donor M), alike sequence with two signs will have C (donor C). Values of changed signs (M and C) sum engine according this arithmetic: for M sum value 1, for C value 10.
This example contains on game board more sequences of signs (X, M, C) in different directions
If complete sequences with their free (N) squares, see one square which is joint fot two sequences from different directions.
Sequence from horizontal direction are "donor" for C (donor value is 10). Diagonal sequence are the same "donor" C and their donor value is: 10(C) + 1(M) = 11.
Engie choose horizontal sequence. If this sequence "donor" C (donor value is 10) for diagonal, diagonal will now "dilay". Engine in array "flagx" rewrite value 100(C) on 197 (dilay). If engine choose alike "donor" diagonal sequence, then donor value is 11 and horizontal sequence will as well "dilay".
Here see how is change values in array "flagx" after move to choose square.
|
||||
|
examples in C++
search "predict high" and choose "2d dilay, delay": //...
//X = 40, M = 10, C = 1
//example:
//direction(-): if(XXM..) -> 80 + 10 = 90
//direction(|): if(-XC..-) -> 40 + 1 = 41
//sum: (-) + (|) -> 90 + 41*100 = 90 + 4100 = 4190(xmap[][])
//...
//for(loop = 0; loop < 4; loop++) {limit[(loop)] = 0;} //clear field
//...
//example: 11004190(xmap{/\|-}) -> 90,41,00,11(limit{ -, |, \, /})
//sud0 = 0;
//for(loop = 0; loop > 4; loop++) {if(limit[(loop)] > 0) sud0++;} //counter
//...
//first max value (example: 90,41,00,11 -> liftx = 90, sud0 = 3)
//second max value (example: 90,41,00,11 -> middx = 41, sud0 = 3)
//if(sud0 > 1) {
// for(loop = 0; loop < 4; loop++) {
// if(liftx < limit[(loop)]) liftx = limit[(loop)];
// }
// for(loop = 0; loop < 4; loop++) {
// if((limit[(loop)] > 0) && (limit[(loop)] < liftx) {
// if(middx < limit[(loop)]) middx = limit[(loop)];
// }
// }
// if(middx == 0) middx = liftx; //example: 90,90,00,00
// }
//first xMC (highest donor) full (X = 100, M = 10, C = 1):
//example(XXM..): liftx(90) -> lift(210)
//if(((liftx/100) + ((liftx/10) % 10) + (liftx % 10)) == 2) plusx = 1; //donor C
//if(((liftx/100) + ((liftx/10) % 10) + (liftx % 10)) == 3) plusx = 10; //donor M
//moves to donor (C = 10, M = 1) example: liftx(21) -> keepx(12)
//keepx = ((liftx/10) % 10) + ((liftx % 10)*10);
//second xMC (akceptor) full (X = 100, M = 10, C = 1):
//example(-XC..-): middx(41) -> middx(101)
//sumx = middx/100; //X
//lagx = ((middx + plusx)/10) % 10; //M + donor(M)
//lag = (middx + plusx) % 10; //C + donor(C)
//sum_lagx = sumx + lagx; //X + M
//xosum = sum_lagx + lag; //X + M + C
//if(who == 1) { //engine is first player (X)
// if((xosum == 4) && (sumx == 2) && (sum_lagx == 4)) corn = 1; //delay(xxMM. 220) M
// if((xosum == 4) && (sumx == 2) && (sum_lagx == 3)) corn = 1; //delay(xxMC. 211) M,C
// if((xosum == 4) && (sumx == 1) && (sum_lagx == 4)) corn = 1; //delay(xMMM. 130) M
// if((xosum == 4) && (sumx == 1) && (sum_lagx == 3)) corn = 1; //delay(xMMC. 121) M,C
// if((xosum == 3) && (sumx == 1) && (sum_lagx == 3)) corn = 1; //delay(-xMM.- 120) M
//...
// example: liftx(XXM..) + 2000(here is 198) -> 210 + 2000 = 2210(xmap[][])
// if((corn == 1) && (keepx == 1)) xmap[][] = 4000 + liftx; //flagx[][] = 1098
// if((corn == 1) && (keepx == 2)) xmap[][] = 4000 + liftx; //flagx[][] = 1098
// //if((corn == 1) && (keepx == 3)) xmap[][] = 4000 + liftx; //flagx[][] = 1098
// if((corn == 1) && (keepx == 10)) xmap[][] = 2000 + liftx; //flagx[][] = 198
// if((corn == 1) && (keepx == 11)) xmap[][] = 3000 + liftx; //flagx[][] = 1097
// if((corn == 1) && (keepx == 20)) xmap[][] = 2000 + liftx; //flagx[][] = 198
//...
write "2d delay, dilay" to array "flagx":
//...
//direction horizontal(-):
//best value from sequence of five, example: xmap(2210,0,0,0,1011) -> plusx(2210)
//for (loop = 0; loop < 5; loop++) {
// if((xmap[][] > 0) && (plusx < xmap[][])) plusx = xmap[][], skipx = loop + 1;
// }
//...
//example: if(-MC..-) predict = 2, if(XXM..) predict = 1
//if((predictx == 2) && (skipx == 1)) skipx = 0;
//...
//example(-): if(XXM..) keep = 210;
//...
//if((plusx > 0) && ((plusx % 1000) == keepx))
// if((plusx/1000) == 1) liftx = 197; //dilay(C)
// if((plusx/1000) == 2) liftx = 198; //dilay(C) + dilay(C)
// if((plusx/1000) == 3) liftx = 1097; //dilay(M)
// if((plusx/1000) == 4) liftx = 1098; //delay
// }
//...
//for(loop = 0; loop < 5; loop++) {
// switch(x_tack[][]) {
// case 0: break;
// case 1: break; //direction horizontal(-): here is C(-)
// case 10: break; //direction horizontal(-): here is M(-)
// case 100: break; //direction horizontal(-): here is M+M(-)
// default: if((x_tack[][] < 1000) && (skipx > 0) && (liftx > 99)) {
// if((liftx < 200) && (flagx[][] > 99) && (flagx[][] < 200)) {
// if(flagx[][] < liftx) flagx[][] = liftx;
// }
// }
// if((x_tack[][] < 1000) && (skipx > 0) && (liftx > 999)) {
// if((flagx[][] > 999) && (flagx[][] < 1100)) {
// if(flagx[][] < liftx) flagx[][] = liftx;
// }
// }
//...
// } //switch
// } //for
//...
|
|||||
| go on: | < previous page | next page > | |||
| FS03: alike theme | FREE SECTOR, 2016 (free alliance of developers Pixoria gomoku plug-in engines) | page 11/16 | |||