TicTacToeState extends TwoDimensionalBoardGameState { @Override public Set<BoardGameState> possibleBoardGameStates(BoardGameState currentState) { Set<BoardGameState> returnStates = new HashSet<BoardGameState>(); List<Point> tempPoints = getEmptyIndex(); for(Point p : tempPoints){ TicTacToeState temp = (TicTacToeState) currentState.copy(); temp.moveSinglePoint(p); returnStates.add(temp); } return returnStates; } TicTacToeState();  TicTacToeState(TicTacToeState state);  TicTacToeState(int[][] board, int player, List<Integer> win); int getNumPlayers(); @Override boolean moveSinglePoint(Point space); @Override boolean endState(); @SuppressWarnings("unchecked") @Override TicTacToeState copy(); @Override Set<BoardGameState> possibleBoardGameStates(BoardGameState currentState); @Override void setupStartingBoard(); @Override int getBoardWidth(); @Override int getBoardHeight(); char[] getPlayerSymbols(); @Override Color[] getPlayerColors(); @Override boolean moveDoublePoint(Point goTo, Point moveTo); @Override boolean moveOnePiece(); static final int X; static final int O; static final int NUMBER_OF_PLAYERS; static final int BOARD_WIDTH; }
@Test public void testPossibleBoardGameStates() { Set<BoardGameState> startList = start.possibleBoardGameStates(start); Set<BoardGameState> list1 = test1.possibleBoardGameStates(test1); Set<BoardGameState> list2 = test2.possibleBoardGameStates(test2); Set<BoardGameState> list3 = test3.possibleBoardGameStates(test3); Set<BoardGameState> list4 = test4.possibleBoardGameStates(test4); Set<BoardGameState> testStart = new HashSet<BoardGameState>(); testStart.add(new TicTacToeState(new int[][]{{X,E,E}, {E,E,E}, {E,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,X,E}, {E,E,E}, {E,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,X}, {E,E,E}, {E,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,E}, {X,E,E}, {E,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,E}, {E,X,E}, {E,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,E}, {E,E,X}, {E,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,E}, {E,E,E}, {X,E,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,E}, {E,E,E}, {E,X,E}}, O, new ArrayList<Integer>())); testStart.add(new TicTacToeState(new int[][]{{E,E,E}, {E,E,E}, {E,E,X}}, O, new ArrayList<Integer>())); Set<BoardGameState> testList1 = new HashSet<BoardGameState>(); testList1.add(new TicTacToeState(new int[][]{{X,O,E}, {E,O,E}, {X,E,E}}, X, new ArrayList<Integer>())); testList1.add(new TicTacToeState(new int[][]{{X,E,O}, {E,O,E}, {X,E,E}}, X, new ArrayList<Integer>())); testList1.add(new TicTacToeState(new int[][]{{X,E,E}, {O,O,E}, {X,E,E}}, X, new ArrayList<Integer>())); testList1.add(new TicTacToeState(new int[][]{{X,E,E}, {E,O,O}, {X,E,E}}, X, new ArrayList<Integer>())); testList1.add(new TicTacToeState(new int[][]{{X,E,E}, {E,O,E}, {X,O,E}}, X, new ArrayList<Integer>())); testList1.add(new TicTacToeState(new int[][]{{X,E,E}, {E,O,E}, {X,E,O}}, X, new ArrayList<Integer>())); Set<BoardGameState> testList2 = new HashSet<BoardGameState>(); testList2.add(new TicTacToeState(new int[][]{{O,X,X},{O,X,E},{E,O,E}}, X, new ArrayList<Integer>())); testList2.add(new TicTacToeState(new int[][]{{E,X,X},{O,X,O},{E,O,E}}, X, new ArrayList<Integer>())); testList2.add(new TicTacToeState(new int[][]{{E,X,X},{O,X,E},{O,O,E}}, X, new ArrayList<Integer>())); testList2.add(new TicTacToeState(new int[][]{{E,X,X},{O,X,E},{E,O,O}}, X, new ArrayList<Integer>())); Set<BoardGameState> testList3 = new HashSet<BoardGameState>(); Set<BoardGameState> testList4 = new HashSet<BoardGameState>(); List<Integer> win4 = new ArrayList<Integer>(); win4.add(O); testList4.add(new TicTacToeState(new int[][]{{O,X,X},{X,O,E},{E,X,O}}, O, win4)); testList4.add(new TicTacToeState(new int[][]{{O,E,X},{X,O,X},{E,X,O}}, O, win4)); testList4.add(new TicTacToeState(new int[][]{{O,E,X},{X,O,E},{X,X,O}}, O, win4)); for(BoardGameState tic : startList){ assertTrue(testStart.contains(tic)); } for(BoardGameState tic : list1){ assertTrue(testList1.contains(tic)); } for(BoardGameState tic : list2){ assertTrue(testList2.contains(tic)); } for(BoardGameState tic : list3){ assertTrue(testList3.contains(tic)); } for(BoardGameState tic : list4){ assertTrue(testList4.contains(tic)); } }