title: MiniMax Implementation
body: <p>I am trying to write a small AI algorithm in Java implementing the miniMax algorithm.</p>
  
  <p>The game upon which this is based is a two-player game where both players make one move per turn, and each board position resulting in each player having a score. The "quality" of a position for player X is evaluated by subtracting the opponent's score from player X's score for that position. Each move is represented by an integer (i.e. Move one is made by inputting 1, move two by inputting 2 etc)</p>
  
  <p>I understand that miniMax should be implemented using recursion. At the moment I have:</p>
  
  <p>An <code>evaluate()</code> method, which takes as parameters an object representing the board state (Ie "BoardState" object and a boolean called "max" (the signature would be <em>evaluate(BoardState myBoard, boolean max)</em>). </p>
  
  <p>max is true when it is player X's turn. Given a board position, it will evaluate all possible moves and return that which is most beneficial for player X. If it is the opponent's turn, max will be false and the method will return the move which is LEAST beneficial for player X (ie: most beneficial for player y)</p>
  
  <p>However, I am having difficulties writing the actual <code>miniMax</code> method. My general structure would be something like:</p>
  
  <pre><code>public int miniMax(GameState myGameState, int depth)
  </code></pre>
  
  <p>Whereby I submit the initial gameState and the "depth" I want it to look into.</p>
  
  <p>I would then be having something like:</p>
  
  <pre><code>int finalMove = 0;
  while(currentDepth &lt; depth) {
      GameState tmp = myGameState.copy();
      int finalMove = evaluate(tmp, true or false);
      iniMax(tmp.makeMove(finalMove));
  
  }
  return finalMove;
  </code></pre>
  
  <p>Would this sound like a plausible implementation? Any suggestions? :)</p>
  
  <p>Thanks!</p>