public Move chooseMove(Board theboard) { Random rand = new Random(); // Cast the arguments to the objects we want to work with CCBoard board = (CCBoard) theboard; // Get the list of legal moves. ArrayList<CCMove> moves = board.getLegalMoves(); // Use my tool for nothing MyTools.getSomething(); // Return a randomly selected move. return (CCMove) moves.get(rand.nextInt(moves.size())); }
@Override public double getScore(CCBoard board, CCBoard original, int playerID) { // For every piece within the max distance threshold to an opponent base // negatively score them based on how close they are double score = 0; for (Point piece : board.getPieces(playerID)) { for (int o = 0; o < OPPONENTS[playerID].length; o++) { double distance = DISTANCE_TO_GOAL[piece.x][piece.y][OPPONENTS[playerID][o]]; if (distance <= maxDistance) { score -= Math.pow((maxDistance - distance), 2); } } } return score; }