static void TestMakeMove() { CQPosition pos; char sBoard[65]; pos.Initialize(); pos.MakeMove(CMove("F5")); assertStringEquals("---------------------------O*------***--------------------------", pos.GetSBoard(sBoard)); assertFalse(pos.BlackMove()); assertEquals(59, pos.NEmpty()); assertEquals(1, pos.NMover()); }
void AnalyzePosition(CPlayerComputer* computer, CQPosition& pos) { CMVK mvk; std::cout << pos.NEmpty(); computer->Clear(); u4 fNeed=CSearchInfo::kNeedMove+CSearchInfo::kNeedValue+CSearchInfo::kNeedMPCStats; CSearchInfo si = computer->DefaultSearchInfo(pos.BlackMove(), fNeed, INFINITE_TIME, 0); computer->GetChosen(si, pos, mvk, true); printf("\n"); std::cerr << "."; }
//! Test that WriteCompressed() followed by ReadCompressed() returns the same book void CBook::TestIO() { { // test book with no position CBook book(NULL, s_out); book.TestMyIO(); } { // test book with a pass position and a subposition from that CBook book(NULL, s_out); CQPosition pos; pos.Initialize("---------------------------**------**------------------O------O*", true); book.StoreRoot(pos.BitBoard(), CHeightInfoX(10, 4, false, pos.NEmpty()), 32, -300); pos.MakeMove(CMove(057)); pos.Pass(); book.StoreLeaf(pos.BitBoard(), CHeightInfoX(10, 4, false, pos.NEmpty()), 32); book.TestMyIO(); } { // test book with only one entry CBook book(NULL, s_out); CQPosition pos; pos.Initialize(); book.StoreLeaf(pos.BitBoard(), CHeightInfoX(10, 4, false, 60), 32); book.TestMyIO(); } { // test book with two entries in a tree CBook book(NULL, s_out); CQPosition pos; pos.Initialize(); book.StoreRoot(pos.BitBoard(), CHeightInfoX(10, 4, false, 60), 32, 16400); pos.MakeMove(CMove(045)); book.StoreLeaf(pos.BitBoard(), CHeightInfoX(10, 4, false, 59), -32); book.TestMyIO(); } }
//! Test CBook::StoreSubposition(). //! While we're at it, test negamaxing as well, so store the parent position //! as a branch node and see if it's assigned the right value. static void TestStoreSubposition() { { // test StoreSubposition() when there is no pass after the move. CBook book; CQPosition pos; pos.Initialize(); const CMoveValue mv(F5, 41); CHeightInfoX hix(2, 4, false, pos.NEmpty()); // store subpos in book book.StoreSubposition(pos, mv, hix); TEST(book.Size()==1); // test that subpos went in correctly CQPosition posSub(pos); posSub.MakeMove(mv.move); CHeightInfoX hixSub(1, 4, false, posSub.NEmpty()-1); TestULeafPos(book, posSub, -mv.value, hixSub); // test that pos is valued correctly when we negamax book.StoreRoot(pos.BitBoard(), hix, mv.value, -100); book.NegamaxAll(); const CBookData* pbd=book.FindData(pos.BitBoard()); TEST(pbd!=NULL); TEST(pbd->Values().vHeuristic==mv.value); } { // test StoreSubposition() when there is a pass after the move. CBook book; CQPosition pos("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*******-----------------", false); CMoveValue mv(A7, 64*kStoneValue); CHeightInfoX hix(2, 4, false, pos.NEmpty()); // store subpos in book book.StoreSubposition(pos, mv, hix); TEST(book.Size()==1); // test that subpos went in correctly CQPosition posSub(pos); posSub.MakeMoveAndPass(mv.move); CHeightInfoX hixSub(1, 4, false, posSub.NEmpty()-1); TestULeafPos(book, posSub, mv.value, hixSub); // test that pos is valued correctly when we negamax book.StoreRoot(pos.BitBoard(), hix, mv.value, -100); book.NegamaxAll(); const CBookData* pbd=book.FindData(pos.BitBoard()); TEST(pbd!=NULL); TEST(pbd->Values().vHeuristic==mv.value); } { // test StoreSubposition() when there are two passes after the move. // no subposition should be added to the book (we don't store terminal nodes in book.) CBook book; CQPosition pos("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO******-----------------", false); CMoveValue mv; mv.move=H6; mv.value=64*kStoneValue; CHeightInfoX hix(2, 4, false, pos.NEmpty()); // store subpos in book book.StoreSubposition(pos, mv, hix); TEST(book.Size()==0); // test that pos is valued correctly when we negamax book.StoreRoot(pos.BitBoard(), hix, mv.value, -100); book.NegamaxAll(); const CBookData* pbd=book.FindData(pos.BitBoard()); TEST(pbd!=NULL); TEST(pbd->Values().vHeuristic==mv.value); } }