@Test public void testFindMoves() throws Exception { List<OthelloMove> moves = othelloRules.findMoves(initialState); Assert.assertTrue(moves.contains(new OthelloMove(2, 3))); Assert.assertTrue(moves.contains(new OthelloMove(3, 2))); Assert.assertTrue(moves.contains(new OthelloMove(4, 5))); Assert.assertTrue(moves.contains(new OthelloMove(5, 4))); }
@Override public List<OthelloMove> findMoves(OthelloState state) { OthelloBoard board = state.getBoard(); List<OthelloMove> actions = new ArrayList<OthelloMove>(); for (int row = 0; row < board.getHeight(); row++) { for (int col = 0; col < board.getWidth(); col++) { if (canPlace(board, row, col, state.getPlayerToMove())) { actions.add(new OthelloMove(row, col)); } } } return actions; }
OthelloRules implements GameRules<OthelloState, OthelloMove> { @Override public List<OthelloMove> findMoves(OthelloState state) { OthelloBoard board = state.getBoard(); List<OthelloMove> actions = new ArrayList<OthelloMove>(); for (int row = 0; row < board.getHeight(); row++) { for (int col = 0; col < board.getWidth(); col++) { if (canPlace(board, row, col, state.getPlayerToMove())) { actions.add(new OthelloMove(row, col)); } } } return actions; } }
OthelloRules implements GameRules<OthelloState, OthelloMove> { @Override public List<OthelloMove> findMoves(OthelloState state) { OthelloBoard board = state.getBoard(); List<OthelloMove> actions = new ArrayList<OthelloMove>(); for (int row = 0; row < board.getHeight(); row++) { for (int col = 0; col < board.getWidth(); col++) { if (canPlace(board, row, col, state.getPlayerToMove())) { actions.add(new OthelloMove(row, col)); } } } return actions; }  }
OthelloRules implements GameRules<OthelloState, OthelloMove> { @Override public List<OthelloMove> findMoves(OthelloState state) { OthelloBoard board = state.getBoard(); List<OthelloMove> actions = new ArrayList<OthelloMove>(); for (int row = 0; row < board.getHeight(); row++) { for (int col = 0; col < board.getWidth(); col++) { if (canPlace(board, row, col, state.getPlayerToMove())) { actions.add(new OthelloMove(row, col)); } } } return actions; }  @Override OthelloState createInitialState(); @Override boolean isTerminal(OthelloState state); @Override List<OthelloMove> findMoves(OthelloState state); @Override int getOutcome(OthelloState state); @Override OthelloState makeMove(OthelloState state, OthelloMove action); boolean canPlace(OthelloBoard board, int row, int col, int player); @Override boolean isMaxPlayer(int currentPlayer); @Override double getReward(OthelloState state); }
OthelloRules implements GameRules<OthelloState, OthelloMove> { @Override public List<OthelloMove> findMoves(OthelloState state) { OthelloBoard board = state.getBoard(); List<OthelloMove> actions = new ArrayList<OthelloMove>(); for (int row = 0; row < board.getHeight(); row++) { for (int col = 0; col < board.getWidth(); col++) { if (canPlace(board, row, col, state.getPlayerToMove())) { actions.add(new OthelloMove(row, col)); } } } return actions; }  @Override OthelloState createInitialState(); @Override boolean isTerminal(OthelloState state); @Override List<OthelloMove> findMoves(OthelloState state); @Override int getOutcome(OthelloState state); @Override OthelloState makeMove(OthelloState state, OthelloMove action); boolean canPlace(OthelloBoard board, int row, int col, int player); @Override boolean isMaxPlayer(int currentPlayer); @Override double getReward(OthelloState state);  }