CheckersState extends TwoDimensionalBoardGameState { @Override public boolean moveDoublePoint(Point moveThis, Point moveTo){ assert isPointInBounds(moveThis); assert isPointInBounds(moveTo); if(!checkMovement(moveThis, moveTo)) return false; int thisCheck = boardState[(int) moveThis.getX()][(int) moveThis.getY()]; int finalX = -1; int finalY = -1; if(boardState[(int) moveTo.getX()][(int) moveTo.getY()] == EMPTY){ boardState[(int) moveTo.getX()][(int) moveTo.getY()] = thisCheck; finalX = (int) moveTo.getX(); finalY = (int) moveTo.getY(); movesSinceLastJump++; }else{ int jumpX = (int) moveTo.getX() + (int) (moveTo.getX() - moveThis.getX()); int jumpY = (int) moveTo.getY() + (int) (moveTo.getY() - moveThis.getY()); boardState[jumpX][jumpY] = thisCheck; boardState[(int) moveTo.getX()][(int) moveTo.getY()] = EMPTY; finalX = jumpX; finalY = jumpY; movesSinceLastJump = 0; checkDoubleJump(new Point(jumpX, jumpY)); } if(thisCheck == BLACK_CHECK_KING || thisCheck == RED_CHECK_KING){ movesSinceNon_King++; }else{ movesSinceNon_King = 0; } if(doubleJumpCheck == null){ nextPlayer = (nextPlayer + 1) % 2; } if(thisCheck == BLACK_CHECK && finalX == BOARD_WIDTH-1){ boardState[finalX][finalY] = BLACK_CHECK_KING; }else if(thisCheck == RED_CHECK && finalX == 0){ boardState[finalX][finalY] = RED_CHECK_KING; } boardState[(int) moveThis.getX()][(int) moveThis.getY()] = EMPTY; return true; } 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 testMove() { assertTrue(start.moveDoublePoint(new Point(2,1), new Point(3,2))); assertTrue(start.moveDoublePoint(new Point(5,0), new Point(4,1))); assertFalse(start.moveDoublePoint(new Point(2,3), new Point(3,3))); assertFalse(start.moveDoublePoint(new Point(1,4), new Point(2,5))); assertFalse(start.moveDoublePoint(new Point(3,2), new Point(2,1))); assertFalse(start.moveDoublePoint(new Point(2,3), new Point(3,4))); assertTrue(start.moveDoublePoint(new Point(3,2), new Point(4,1))); assertFalse(start.moveDoublePoint(new Point(4,1), new Point(5,0))); assertTrue(test1.moveDoublePoint(new Point(2,3), new Point(3,2))); assertTrue(test1.moveDoublePoint(new Point(5,4), new Point(6,3))); assertTrue(test1.moveDoublePoint(new Point(3,2), new Point(2,3))); assertTrue(test1.moveDoublePoint(new Point(6,3), new Point(5,4))); assertTrue(test1.moveDoublePoint(new Point(2,3), new Point(1,2))); assertTrue(test1.moveDoublePoint(new Point(5,4), new Point(4,3))); assertTrue(test1.moveDoublePoint(new Point(1,2), new Point(2,3))); assertTrue(test1.moveDoublePoint(new Point(4,3), new Point(5,4))); assertTrue(test4.moveDoublePoint(new Point(2,3), new Point(3,2))); assertFalse(test4.moveDoublePoint(new Point(5,2), new Point(4,1))); assertFalse(test4.moveDoublePoint(new Point(0,7), new Point(1,6))); assertTrue(test4.moveDoublePoint(new Point(4,1), new Point(5,2))); assertTrue(test5.moveDoublePoint(new Point(6,5), new Point(7,6))); assertTrue(test5.moveDoublePoint(new Point(3,2), new Point(2,3))); assertTrue(test5.moveDoublePoint(new Point(7,6), new Point(6,5))); }