Return bestMove in minimax algorithm for tictactoe
I have tried to code the minimax algorithm for tic-tac-toe given in Russel Norvig's book on Artificial Intelligence. It had everything except that the way to return the bestMove to the user. I am trying hard to return the bestMove, but cannot decide when to choose the bestMove. Help, anyone? moveT MiniMax(stateT state) { moveT bestMove; max_move(state,bestMove); return bestMove; } int max_move(stateT state,int & bestMove) { int v = -10000; if(GameIsOver(state)) { return EvaluateStaticPosition(state); } vector<moveT> moveList; GenerateMoveList(state, moveList); int nMoves = moveList.size(); for