handlePosition method
Implementation
void handlePosition(List<String> parts) {
int movesIndex = parts.indexOf('moves');
String fen = '';
if (parts[1] == 'startpos') {
fen = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1';
} else if (parts[1] == 'fen') {
fen = parts
.sublist(2, movesIndex != -1 ? movesIndex : parts.length)
.join(' ');
}
game = Game(variant: null);
game.setup(fen: fen);
// Re-initialize the MCTS engine with the updated game object
mcts = mc.Mcts(game, gpt);
if (movesIndex != -1) {
List<String> moves = parts.sublist(movesIndex + 1);
for (String moveString in moves) {
Move? move = game.getMove(moveString);
if (move != null) {
game.makeMove(move);
}
}
}
}