private void Sample() { CuckComp = new ComputerPlayer(); CuckHumn = new HumanPlayer(); CuckBK = new Book(false); CuckGM = new Game(CuckHumn, CuckComp); Position pos = CuckGM.getPos(); // e4(102) d4(31) ... string CurrentBookMoves = CuckBK.getAllBookMoves(pos); // Nb1-a3;Nb1-c3;...;a2-a3;a2-a4;... string CurrentValidMoves = TextIO.AllMovesTostring(pos, true); // RNB...w KQkq... string CurrentPositionFEN = TextIO.toFEN(pos); // Display board to console TextIO.DispBoard(pos); // Swap & move CuckGM.whitePlayer = CuckComp; CuckGM.blackPlayer = CuckHumn; //CuckComp.bookEnabled = false; CuckComp.maxTimeMillis = 1 * 100; CuckComp.maxTimeMillis = 6 * 100; //CuckComp.maxDepth = 6; // Ng1-f3 string CommandFromComp = CuckComp.getCommand(new Position(pos), CuckGM.haveDrawOffer(), CuckGM.getHistory()); }
public string getCommand(Position pos, bool drawOffer, List <Position> history) { // Create a search object ulong[] posHashList = new ulong[200 + history.Count]; int posHashListSize = 0; for (int i = 0; i < history.Count; i++) { Position p = history[i]; posHashList[posHashListSize++] = p.zobristHash(); } tt.nextGeneration(); Search sc = new Search(pos, posHashList, posHashListSize, tt); // Determine all legal moves MoveGen.MoveList moves = new MoveGen().pseudoLegalMoves(pos); MoveGen.RemoveIllegal(pos, moves); sc.scoreMoveList(moves, 0); // Test for "game over" if (moves.size == 0) { // Switch sides so that the human can decide what to do next. return("swap"); } if (bookEnabled) { Move bookMove = book.getBookMove(pos); if (bookMove != null) { SystemHelper.printf("Book moves: " + book.getAllBookMoves(pos)); return(TextIO.moveTostring(pos, bookMove, true)); } } // Find best move using iterative deepening currentSearch = sc; sc.setListener(listener); Move bestM; if ((moves.size == 1) && (canClaimDraw(pos, posHashList, posHashListSize, moves.m[0]) == "")) { bestM = moves.m[0]; bestM.score = 0; } else if (randomMode) { bestM = findSemiRandomMove(sc, moves); } else { sc.timeLimit(minTimeMillis, maxTimeMillis); bestM = sc.iterativeDeepening(moves, maxDepth, maxNodes, verbose); } currentSearch = null; // tt.printStats(); string strMove = TextIO.moveTostring(pos, bestM, true); bestmv = bestM; // Claim draw if appropriate if (bestM.score <= 0) { string drawClaim = canClaimDraw(pos, posHashList, posHashListSize, bestM); if (drawClaim != "") { strMove = drawClaim; } } return(strMove); }
private void Sample() { CuckComp = new ComputerPlayer(); CuckHumn = new HumanPlayer(); CuckBK = new Book(false); CuckGM = new Game(CuckHumn, CuckComp); Position pos = CuckGM.getPos(); // e4(102) d4(31) ... string CurrentBookMoves = CuckBK.getAllBookMoves(pos); // Nb1-a3;Nb1-c3;...;a2-a3;a2-a4;... string CurrentValidMoves = TextIO.AllMovesTostring(pos, true); // RNB...w KQkq... string CurrentPositionFEN = TextIO.toFEN(pos); // Display board to console TextIO.DispBoard(pos); // Swap & move CuckGM.whitePlayer = CuckComp; CuckGM.blackPlayer = CuckHumn; //CuckComp.bookEnabled = false; CuckComp.maxTimeMillis = 1 * 100; CuckComp.maxTimeMillis = 6 * 100; //CuckComp.maxDepth = 6; // Ng1-f3 string CommandFromComp = CuckComp.getCommand(new Position(pos), CuckGM.haveDrawOffer(), CuckGM.getHistory()); }