public void testAlphaBetaDecision() { AlphaBetaSearch <TicTacToeState, XYLocation, string> search = AlphaBetaSearch <TicTacToeState, XYLocation, string> .createFor(game); search.makeDecision(state); int expandedNodes = search.getMetrics().getInt(MinimaxSearch <TicTacToeState, XYLocation, string> .METRICS_NODES_EXPANDED); Assert.AreEqual(30709, expandedNodes); }
private void Start() { End.SetActive(false); game = new Awale(); //minimaxSearch = MinimaxSearch<State, int, int>.createFor(game); alphabetaSearch = AlphaBetaSearch <StateAwale, int, int> .createFor(game); CurrentState = game.getInitialState(); CheckisTerminal(); }
public void SetupGame(int nb) { End.SetActive(false); allumettesTxt.text = ""; IATxt.text = ""; game = new Nim(nb); //minimaxSearch = MinimaxSearch<List<int>, int, int>.createFor(game); alphabetaSearch = AlphaBetaSearch <NimState, int, int> .createFor(game); CurrentState = game.getInitialState(); allumettesTxt.text = "Allumettes restantes : " + CurrentState.allumettes.ToString(); CheckisTerminal(); }
static void startAlphaBetaDemo() { System.Console.WriteLine("ALPHA BETA DEMO\n"); TicTacToeGame game = new TicTacToeGame(); TicTacToeState currState = game.GetInitialState(); IAdversarialSearch <TicTacToeState, XYLocation> search = AlphaBetaSearch <TicTacToeState, XYLocation, string> .createFor(game); while (!(game.IsTerminal(currState))) { System.Console.WriteLine(game.GetPlayer(currState) + " playing ... "); XYLocation action = search.makeDecision(currState); currState = game.GetResult(currState, action); System.Console.WriteLine(currState); } System.Console.WriteLine("ALPHA BETA DEMO done"); }
private void Start() { Nim game = new Nim(Matches); MinimaxSearch <NimState, int, int> minimaxSearch = MinimaxSearch <NimState, int, int> .createFor(game); AlphaBetaSearch <NimState, int, int> alphabetaSearch = AlphaBetaSearch <NimState, int, int> .createFor(game); NimState state = game.getInitialState(); int action1 = -1; int action2 = -1; action1 = minimaxSearch.makeDecision(state); action2 = alphabetaSearch.makeDecision(state); Debug.Log("Chosen action is " + action1 + " and node minimax " + minimaxSearch.getMetrics()); Debug.Log("Chosen action is " + action2 + " and node alphabeta " + alphabetaSearch.getMetrics()); }
private void Start() { TTT game = new TTT(); MinimaxSearch <StateTTT, int, int> minimaxSearch = MinimaxSearch <StateTTT, int, int> .createFor(game); AlphaBetaSearch <StateTTT, int, int> alphabetaSearch = AlphaBetaSearch <StateTTT, int, int> .createFor(game); StateTTT state = game.getInitialState(); int action1 = -100000; int action2 = -100000; action1 = minimaxSearch.makeDecision(state); action2 = alphabetaSearch.makeDecision(state); Debug.Log("Chosen action is " + action1 + " and node minimax " + minimaxSearch.getMetrics()); Debug.Log("Chosen action is " + action2 + " and node alphabeta " + alphabetaSearch.getMetrics()); }
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); }