public void testIterativeDeepeningAlphaBetaDecision() { IterativeDeepeningAlphaBetaSearch <TicTacToeState, XYLocation, string> search = IterativeDeepeningAlphaBetaSearch <TicTacToeState, XYLocation, string> .createFor(game, 0.0, 1.0, 100); search.makeDecision(state); int expandedNodes = search.getMetrics().getInt(MinimaxSearch <TicTacToeState, XYLocation, string> .METRICS_NODES_EXPANDED); Assert.AreEqual(76035, expandedNodes); }
public List <GameMoveResult> MakeMoves(Game objGame, object state, int movesNumber) { var toReturn = new List <GameMoveResult>(); AdversarialSearch objGameStrategy; switch (StrategyType) { case GameStrategyType.AlphaBeta: objGameStrategy = AlphaBetaSearch.createFor(objGame); break; case GameStrategyType.IterativeDeepeningAlphaBeta: objGameStrategy = IterativeDeepeningAlphaBetaSearch.createFor(objGame, MinUtility, MaxUtility, MaxDurationSeconds); break; case GameStrategyType.ConnectFourIDAlphaBeta: objGameStrategy = new ConnectFourAIPlayer(objGame, MaxDurationSeconds); break; default: objGameStrategy = MinimaxSearch.createFor(objGame); break; } int counter = 0; while (!objGame.isTerminal(state) && counter < movesNumber) { var action = objGameStrategy.makeDecision(state); var newMove = new GameMoveResult() { Game = objGame, InitialState = state, Action = action, Metrics = objGameStrategy.getMetrics() }; toReturn.Add(newMove); state = newMove.ResultState; counter++; } return(toReturn); }