// Test that our search finds example mates in one. char* TestMatesInTwo() { char *fen; Game game; int i, dummyVal; Move actual, expected; uint64_t dummy = 0; StringBuilder builder = NewStringBuilder(); for(i = 0; i < COUNT; i++) { fen = fens[i]; expected = ParseMove(mates[i]); game = ParseFen(fen); actual = Search(&game, &dummy, &dummyVal, 3); if(actual != expected) { AppendString(&builder, "Search failed mate-in-two for:-\n\n" "%s\n" "Expected move %s, engine selected %s.\n\n", StringChessSet(&game.ChessSet), StringMove(expected), StringMove(actual)); } } return builder.Length == 0 ? NULL : BuildString(&builder, true); }
static Move * ParseMoveAndVariants(void) { Move *move_details; move_details = ParseMove(); if(move_details != NULL) { CommentList *comment; move_details->Variants = ParseOptVariantList(); comment = ParseOptCommentList(); if(comment != NULL) { append_comments_to_move(move_details,comment); } } return move_details; }
void PlayBot() { printf("\n\nAt Any Time In The Game If You Want To See The Grid Indexing In Which You Have To Make A Move\n\n"); printf("During Enter A Move Command...Just Press 0 And Press Enter \n\n"); BOARD *board=new BOARD; SetStart(board); printf("The Starting Board\n\n"); PrintBoard(board); char Inp[200]; int Side; printf("\nChoose Your Side...\n\n0. For Black\n1. For White\n"); scanf("%d",&Side); if(Side==0) { MOVE *list1=new MOVE; GenMoves(board,list1); vector<int>BestMove1=SearchPos(board,8); MakeMove(board,BestMove1); PrintBoard(board); } while(1) { printf("\n\nEnter Your Move\n"); getchar(); scanf("%[^\n]",&Inp); if(Inp[0]=='0') { PrintIndex(); continue; } else if(Inp[0]=='1') { printf("\nYour Possible MoveList is\n"); MOVE *YourMoveList=new MOVE; GenMoves(board,YourMoveList); PrintMoveList(YourMoveList); } vector<int>Move=ParseMove(Inp); if(MoveExists(board,Move)) MakeMove(board,Move); else { MOVE *User=new MOVE; GenMoves(board,User); if(User->Count==0) { printf("Sorry You Lost\n\n"); break; } else printf("Invalid Move...Enter Again\n\n"); continue; } PrintBoard(board); printf("-----------------------------------Bot's Turn----------------------------------\n"); MOVE *Bot=new MOVE; GenMoves(board,Bot); if(Bot->Count==0) { printf("--------------------------Congratulations You Win--------------------------\n"); break; } vector<int>BestMove=SearchPos(board,8); MakeMove(board,BestMove); PrintBoard(board); } StartGame(); }