/** * Get an ArrayList of all possible moves that we can make given state. * * @param state * @return */ protected ArrayList<ScoredBreakthroughMove> getPossibleMoves(GameState state) { BreakthroughState board = (BreakthroughState) state; ArrayList<ScoredBreakthroughMove> list = new ArrayList<ScoredBreakthroughMove>(); ScoredBreakthroughMove mv = new ScoredBreakthroughMove(); int dir = state.who == GameState.Who.HOME ? +1 : -1; for (int r = 0; r < BreakthroughState.N; r++) { for (int c = 0; c < BreakthroughState.N; c++) { mv.startRow = r; mv.startCol = c; mv.endingRow = r + dir; mv.endingCol = c; if (board.moveOK(mv)) { list.add((ScoredBreakthroughMove) mv.clone()); } mv.endingRow = r + dir; mv.endingCol = c + 1; if (board.moveOK(mv)) { list.add((ScoredBreakthroughMove) mv.clone()); } mv.endingRow = r + dir; mv.endingCol = c - 1; if (board.moveOK(mv)) { list.add((ScoredBreakthroughMove) mv.clone()); } } } return list; }