From 76abfa378b7a6e3e91a2eb2dd4897894372722e4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Feb 2026 17:25:09 +0000 Subject: [PATCH] refactor: always use Monte Carlo (MCTSBot) for AI players Change AI logic to exclusively use MCTSBot (Monte Carlo Tree Search) for all games instead of conditionally selecting between MCTSBot and RandomBot based on game type. https://claude.ai/code/session_015368pqKFgsdf1ucDopxp9V --- src/App.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 1e3ee72..21b7096 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useMemo } from 'react'; import { Client } from 'boardgame.io/react'; import { Local } from 'boardgame.io/multiplayer'; -import { RandomBot, MCTSBot } from 'boardgame.io/ai'; +import { MCTSBot } from 'boardgame.io/ai'; import { games, gameIds, type GameDefinition } from './registry'; type AISettings = { @@ -131,16 +131,15 @@ function createMCTSBot(game: GameDefinition['game']) { }; } -function GameView({ gameId, definition }: { gameId: string; definition: GameDefinition }) { +function GameView({ definition }: { definition: GameDefinition }) { const [aiSettings, setAiSettings] = useState({ player0: false, player1: false }); const GameClient = useMemo(() => { - // Use MCTSBot for tic-tac-toe (turn-based), RandomBot for others (like simultaneous RPS) - const useMCTS = gameId === 'tic-tac-toe'; - const BotClass = useMCTS ? createMCTSBot(definition.game) : RandomBot; + // Always use MCTSBot (Monte Carlo Tree Search) for AI + const BotClass = createMCTSBot(definition.game); // Build the bots configuration based on AI settings - const bots: Record = {}; + const bots: Record = {}; if (aiSettings.player0) { bots['0'] = BotClass; } @@ -153,7 +152,7 @@ function GameView({ gameId, definition }: { gameId: string; definition: GameDefi board: definition.Board, multiplayer: Local({ bots: Object.keys(bots).length > 0 ? bots : undefined }), }); - }, [gameId, definition, aiSettings]); + }, [definition, aiSettings]); return (
@@ -232,7 +231,7 @@ export function App() { }; if (currentGame && games[currentGame]) { - return ; + return ; } return ;