Game Tree Search Technology Introduction:
Game Tree Search algorithm, negative value of the great search, Alpha-beta search, eager to search, PVs very narrow window search and so on. Often, search algorithms are often combined with the following technologies.
As follows:
1. Replace the table, record the game already searched, avoid searching again.
2. Eat the child inspiration, priority to try to eat the other pieces of the way.
3. Killer inspired, history inspired simplified version.
4. Historical inspiration, give priority to the comparison of historical statistics to get a better approach.
5. Stationary search, continue to search some leaf nodes, avoid the horizontal effect.
6. Iterate to deepen the search, based on the search time, status. Decide whether to continue the search.
Interested friends can delve into the above techniques and algorithms.
Eating sub-chess search algorithm:
The initial implementation of my program uses the negative value of the search algorithm, then uses the Alpha-beta search algorithm, and later using the PVs very narrow window search algorithm.
In my own implementation, there is no use of permutation tables, historical inspiration and other techniques. It is because of the relatively small number of walking in each layer of the eating chess, so it is not used.
But we know that these technologies can greatly improve the search efficiency.
Eat son chess search algorithm Source:
Next, look at the source code of the Eating Chess search algorithm:
Negative value maximal algorithm
1 intCnegamaxengine::negamax (intdepth)2 {3 intCurrentmaxscore =-20000;//init value Mini4 intscore;5 intNextmovecount;6 intOvernum =isgameover (curposition, depth);7 if(Overnum! =0)returnOvernum;8 if(Depth <=0)9 returnM_peval->eveluate (Curposition, (m_nmaxdepth-depth)%2 );TenNextmovecount = M_pmg->createpossiblemove (curposition, Depth, (m_nmaxdepth-depth)%2); One for(inti =0; i < Nextmovecount; i++) A { -Makemove (&m_pmg->m_movelist[depth][i], (m_nmaxdepth-depth)%2); -Score =-negamax (depth-1); theUnmakemove (&m_pMG->m_movelist[depth][i]); - if(score>Currentmaxscore) - { -Currentmaxscore =score; + if(Depth = =m_nmaxdepth) { - +M_cmbestmove = m_pmg->M_movelist[depth][i]; A } at } - } - returnCurrentmaxscore; -}
Alpha-beta algorithm
intCalphtbetaengine::alphabeta (intDepthintAlpha,intBeta) { intscore; intNextmovecount; intOvernum =isgameover (curposition, depth); if(Overnum! =0)returnOvernum; intWhoturn = (m_nmaxdepth-depth)%2; if(Depth <=0) returnM_peval->eveluate (curposition, Whoturn); Nextmovecount= m_pmg->Createpossiblemove (curposition, depth, whoturn); for(inti =0; i < Nextmovecount; i++) {Makemove (&m_pMG->M_movelist[depth][i], Whoturn); Score=-alphabeta (Depth-1,-beta,-Alpha); Unmakemove (&m_pMG->M_movelist[depth][i]); if(score>Alpha) {Alpha=score; if(Depth = =m_nmaxdepth) {M_cmbestmove= m_pmg->M_movelist[depth][i]; } } if(Alpha >= Beta) Break; } returnAlpha;}
PVS algorithm:
1 intCpvs_engine::P rincipalvariation (intDepthintAlphaintBeta)2 {3 intscore;4 intCount, I;5 BYTE type;6 intBest ;7 8i =isgameover (curposition, depth);9 if(I! =0)Ten returni; One A if(Depth <=0)//estimation of leaf node values - returnM_peval->eveluate (Curposition,false); - theCount = M_pmg->createpossiblemove (curposition, Depth, (m_nmaxdepth-depth)%2); - - -Makemove (&m_pmg->m_movelist[depth][0], (m_nmaxdepth-depth)%2); +Best =-principalvariation (Depth-1,-beta,-Alpha); -Unmakemove (&m_pmg->m_movelist[depth][0]); + if(Depth = =m_nmaxdepth) AM_cmbestmove = m_pmg->m_movelist[depth][0]; at - for(i =1; i<count; i++) - { - - if(Best <Beta) - { in if(Best >Alpha) -Alpha =Best ; toMakemove (&m_pmg->m_movelist[depth][i], (m_nmaxdepth-depth)%2); +Score =-principalvariation (Depth-1,-alpha-1, -Alpha); - if(Score > Alpha && score <Beta) the { *Best =-principalvariation (Depth-1,-beta,-score); $ if(Depth = =m_nmaxdepth)Panax NotoginsengM_cmbestmove = m_pmg->M_movelist[depth][i]; - } the Else if(Score >Best ) + { ABest =score; the if(Depth = =m_nmaxdepth) +M_cmbestmove = m_pmg->M_movelist[depth][i]; - } $Unmakemove (&m_pMG->m_movelist[depth][i]); $ } - } - the returnBest ; -}
Interested students can look at Wang Xiaochun written "PC game programming-man-Machine game", the above algorithms are reference from this book.
Finally, show, the current game embryonic, embedded video section.
The latest outside of the chain is not normal, you can go to the General order that blog post to see the previous video
Man-Machine game-eating chess game (four) search algorithm