title: Help with my MinMax Implementation
body: <p>I've been trying to implement a minMax Algorithm (will try alphabeta pruning later) for a simple game....I've seen many pseudo codes and tutorials but i just can't get it to work...</p>
  
  <p>A little help will be appreciated :)</p>
  
  <p>Here are the relevant classes...(removed implementation for clarity)</p>
  
  <pre><code>class Board { //Stores board state, Immutable
  
      Board playMove(Move m); //generates new Board after playing "Move m"
  
      List&lt;Move&gt; nextMoves(Move m); // generates all possible moves, previous move is required to decide the validity of the next moves
  
      boolean isTerminal(); //board at terminal state?
  }
  
  
  class Move { //stores positions played and score gained from that move
  
  }
  </code></pre>
  
  <p>And here is my Min-Max Implementation...Can someone please point out what i'm doing wrong? Thank you.</p>
  
  <pre><code>private Move bestMove = null; // field variable
  
  private int maxMove(Board board, Move prevMove, int myScore, int oppnScore) {
      out("maxMove " + board );
      if(board.isTerminal()) {
          return myScore - oppnScore;
      }
      int mx = Integer.MIN_VALUE;
      for(Move nxtMove: board.nextMoves(prevMove)) {
          int k = minMove(board.playMove(nxtMove),
                          nxtMove,
                          myScore + nxtMove.score,
                          oppnScore);
          if(k &gt; mx) {
              mx = k;
              bestMove = nxtMove;
          }
      }
      return mx;
  }
  
  private int minMove(Board board, Move prevMove, int myScore, int oppnScore) {
      if(board.isTerminal()) {
          return myScore - oppnScore;
      }
      out("minMove " + board );
      int mn = Integer.MAX_VALUE;
      for(Move nxtMove: board.nextMoves(prevMove)) {
          int k = maxMove(board.playMove(nxtMove),
                          nxtMove,
                          myScore,
                          oppnScore + nxtMove.score);
          if(k &lt; mn) {
              mn = k;
              bestMove = nxtMove;
          }
      }
      return mn;
  }
  </code></pre>
  
  <p>EDIT: A brief description of the game is as follows, you have a certain number of coins of different denominations before you. You and another player take turns removing a single coin from eithor side (left or right). The denomination of the coin denotes the points you score for that move. Certain coins have special meaning, say Picking X means you'll skip a turn, or Y means you'll get one more turn. Your objective is to score more points than your opponent.</p>