@Test public void testRotateBoard() throws Exception { double[] features = state.getFeatures(); state.rotateBoard(); state.rotateBoard(); state.rotateBoard(); state.rotateBoard(); double[] rotatedFeatures = state.getFeatures(); Assert.assertArrayEquals(features, rotatedFeatures, 0); }
public void rotateBoard() { for (int i = 0; i < SIZE / 2; i++) { for (int j = i; j < SIZE - i - 1; j++) { int tmp = board[i][j]; board[i][j] = board[j][SIZE - i - 1]; board[j][SIZE - i - 1] = board[SIZE - i - 1][SIZE - j - 1]; board[SIZE - i - 1][SIZE - j - 1] = board[SIZE - j - 1][i]; board[SIZE - j - 1][i] = tmp; } } }
State2048 implements BoardState { public void rotateBoard() { for (int i = 0; i < SIZE / 2; i++) { for (int j = i; j < SIZE - i - 1; j++) { int tmp = board[i][j]; board[i][j] = board[j][SIZE - i - 1]; board[j][SIZE - i - 1] = board[SIZE - i - 1][SIZE - j - 1]; board[SIZE - i - 1][SIZE - j - 1] = board[SIZE - j - 1][i]; board[SIZE - j - 1][i] = tmp; } } } }
State2048 implements BoardState { public void rotateBoard() { for (int i = 0; i < SIZE / 2; i++) { for (int j = i; j < SIZE - i - 1; j++) { int tmp = board[i][j]; board[i][j] = board[j][SIZE - i - 1]; board[j][SIZE - i - 1] = board[SIZE - i - 1][SIZE - j - 1]; board[SIZE - i - 1][SIZE - j - 1] = board[SIZE - j - 1][i]; board[SIZE - j - 1][i] = tmp; } } } private  State2048();  State2048(State2048 state);  State2048(double[] features); }
State2048 implements BoardState { public void rotateBoard() { for (int i = 0; i < SIZE / 2; i++) { for (int j = i; j < SIZE - i - 1; j++) { int tmp = board[i][j]; board[i][j] = board[j][SIZE - i - 1]; board[j][SIZE - i - 1] = board[SIZE - i - 1][SIZE - j - 1]; board[SIZE - i - 1][SIZE - j - 1] = board[SIZE - j - 1][i]; board[SIZE - j - 1][i] = tmp; } } } private  State2048();  State2048(State2048 state);  State2048(double[] features); static int getNumValues(); int[][] getPowerGrid(); @Override double[] getFeatures(); int getValue(int flatLocation); List<Pair<Double, EnvTransition<State2048>>> getPossibleEnvironmentTransitions(); void addRandomTile(RandomDataGenerator random); List<Integer> getEmptyLocations(); int moveUp(); void rotateBoard(); int makeMove(Action2048 action); List<Action2048> getPossibleMoves(); boolean isTerminal(); int getMaxTile(); void printHumanReadable(); static State2048 getInitialState(int numLocations, RandomDataGenerator random); static State2048 getInitialState(RandomDataGenerator random); @Override Game2048Board getBoard(); @Override String toString(); boolean hasValue(int[] values, int value); int[] getValues(); int getStage(int num_segments, int max_segment); }
State2048 implements BoardState { public void rotateBoard() { for (int i = 0; i < SIZE / 2; i++) { for (int j = i; j < SIZE - i - 1; j++) { int tmp = board[i][j]; board[i][j] = board[j][SIZE - i - 1]; board[j][SIZE - i - 1] = board[SIZE - i - 1][SIZE - j - 1]; board[SIZE - i - 1][SIZE - j - 1] = board[SIZE - j - 1][i]; board[SIZE - j - 1][i] = tmp; } } } private  State2048();  State2048(State2048 state);  State2048(double[] features); static int getNumValues(); int[][] getPowerGrid(); @Override double[] getFeatures(); int getValue(int flatLocation); List<Pair<Double, EnvTransition<State2048>>> getPossibleEnvironmentTransitions(); void addRandomTile(RandomDataGenerator random); List<Integer> getEmptyLocations(); int moveUp(); void rotateBoard(); int makeMove(Action2048 action); List<Action2048> getPossibleMoves(); boolean isTerminal(); int getMaxTile(); void printHumanReadable(); static State2048 getInitialState(int numLocations, RandomDataGenerator random); static State2048 getInitialState(RandomDataGenerator random); @Override Game2048Board getBoard(); @Override String toString(); boolean hasValue(int[] values, int value); int[] getValues(); int getStage(int num_segments, int max_segment); static final int SIZE; static final RectSize BOARD_SIZE; static final int NUM_INITIAL_LOCATIONS; static final double RANDOM_FOUR_PROB; static final int REWARDS; }