void abstractGame(ChessMove (*whitePlayer)(ChessBoard &,int),ChessMove (*blackPlayer)(ChessBoard &,int)) { ChessBoard board; board.setup(); SearchTree ai; ChessMove selectedMove; unsigned int i; vector<ChessMove> moves; BoardIO boardWriter; vector<ChessBoard> boards; int color=WHITE; for (i=0;i<16;i++) { boards.push_back(board); if (color==WHITE) selectedMove=(*whitePlayer)(board,color); else selectedMove=(*blackPlayer)(board,color); board.getMoves(color,moves); board.applyMove(selectedMove); cout << moveString(selectedMove) << "\n"; color=getOpponent(color); } boardWriter.saveBoards(boards, "C:\\Users\\sam\\Documents\\cpp\\chess.html"); }
void Client::makeMove(const Move &move, Piece promotionChoice) { toClient(moveString(move,promotionChoice)); }
void UciEngine::parseLine(const QString& line) { const QStringRef command(firstToken(line)); if (command == "info") { parseInfo(command); } else if (command == "bestmove") { if (state() != Thinking) { if (state() == FinishingGame) pong(); else qDebug() << "Unexpected move from" << name(); return; } QString moveString(nextToken(command).toString()); m_moveStrings += " " + moveString; Chess::Move move = board()->moveFromString(moveString); if (!move.isNull()) emitMove(move); else forfeit(Chess::Result::IllegalMove, moveString); } else if (command == "readyok") { pong(); } else if (command == "uciok") { if (state() == Starting) { onProtocolStart(); ping(); } } else if (command == "id") { QStringRef tag(nextToken(command)); if (tag == "name" && name() == "UciEngine") setName(nextToken(tag, true).toString()); } else if (command == "registration") { if (nextToken(command) == "error") { qDebug("Failed to register UCI engine %s", qPrintable(name())); write("register later"); } } else if (command == "option") { EngineOption* option = parseOption(command); QString variant; if (option == 0 || !option->isValid()) qDebug("Invalid UCI option from %s: %s", qPrintable(name()), qPrintable(line)); else if (!(variant = variantFromUci(option->name())).isEmpty()) addVariant(variant); else if (option->name() == "UCI_Opponent") m_sendOpponentsName = true; else if (option->name() == "Ponder" || (option->name().startsWith("UCI_") && option->name() != "UCI_LimitStrength" && option->name() != "UCI_Elo")) { // TODO: Deal with UCI features } else { addOption(option); return; } delete option; } }