CheckersState extends TwoDimensionalBoardGameState { @Override public boolean endState() { int blackChecksLeft = 0; int redChecksLeft = 0; for(int i = 0; i < BOARD_WIDTH; i++){ for(int j = 0; j < BOARD_WIDTH; j++){ int space = boardState[i][j]; if(space == BLACK_CHECK || space == BLACK_CHECK_KING){ blackChecksLeft++; }else if(space == RED_CHECK || space == RED_CHECK_KING){ redChecksLeft++; } } } if(blackChecksLeft == 0 || redChecksLeft == 0){ return true; }else if(possibleBoardGameStates(this).size() == 0){ if(winners.isEmpty()) { winners.add((nextPlayer + 1) % 2); } return true; }else if(movesSinceLastJump > 50 && movesSinceNon_King > 50){ return true; } return false; } CheckersState();  CheckersState(CheckersState state);   CheckersState(int[][] newBoard, int player, List<Integer> win); int getNumPlayers(); List<Integer> getWinners(); @Override boolean endState(); @Override double[] getDescriptor(); @Override boolean moveDoublePoint(Point moveThis, Point moveTo); @SuppressWarnings("unchecked") @Override CheckersState copy(); @SuppressWarnings("unchecked") @Override Set<T> possibleBoardGameStates(T currentState); @Override void setupStartingBoard(); @Override int getBoardWidth(); @Override int getBoardHeight(); @Override char[] getPlayerSymbols(); @Override Color[] getPlayerColors(); @Override boolean moveSinglePoint(Point goTo); @Override boolean moveOnePiece(); static final int BOARD_WIDTH; static final int STARTCHECKS; static final int BLACK_CHECK; static final int BLACK_CHECK_KING; static final int RED_CHECK; static final int RED_CHECK_KING; public Point doubleJumpCheck; }
@Test public void testEndState() { assertFalse(start.endState()); assertFalse(test1.endState()); assertFalse(test2.endState()); assertTrue(test3.endState()); }