public Move(Board board, BoardSquare from, BoardSquare to, double rating = 0) { this.board = board; this.from = from; this.to = to; this.valid = validityCheck(from, to); this.rating = rating; }
private static bool isOnBoard(BoardSquare from, BoardSquare to) { if ((from.getRowCoord() >= 0 && from.getRowCoord() < Board.BOARD_ROW_COUNT) && (from.getColumnCoord() >= 0 && from.getColumnCoord() < Board.BOARD_COLUMN_COUNT) && (to.getRowCoord() >= 0 && to.getRowCoord() < Board.BOARD_ROW_COUNT) && (to.getColumnCoord() >= 0 && to.getColumnCoord() < Board.BOARD_COLUMN_COUNT)) { return(true); } return(false); }
private static bool isNeighbour(BoardSquare from, BoardSquare to) { if (((from.getRowCoord() + 1 == to.getRowCoord() && from.getColumnCoord() == to.getColumnCoord()) || (from.getRowCoord() - 1 == to.getRowCoord() && from.getColumnCoord() == to.getColumnCoord())) ^ ((from.getColumnCoord() + 1 == to.getColumnCoord() && from.getRowCoord() == to.getRowCoord()) || (from.getColumnCoord() - 1 == to.getColumnCoord() && from.getRowCoord() == to.getRowCoord()))) { return(true); } return(false); }
private static bool validityCheck(BoardSquare from, BoardSquare to) { if (to.getCurrentObject() is None) { if (isNeighbour(from, to) && isOnBoard(from, to) && !isLocked(from)) { return(true); } } return(false); }
private static bool isLocked(BoardSquare from) { return(from.getCurrentObject().getLocked()); }