@Override public boolean test(Node node) { V pos = (V) node.getState(); // for all seeds for (Seed s : board.getSeeds()) { // are we on the same (axis parallel) line ? if (V.sameLine(pos, s.pos)) { // are we far enough from it ? if (V.manhattan(pos, s.pos) < s.range) { return false; } } } return true; }
private Move searchNextCloud(Unicorn me, IBoard board) { BFS bfs = new BFS(); Node end = bfs.search(new OnlyPositionNode(board, me.pos), new NextToCloud(board)); List<Node> path = PathUtils.getPath(end); if (path.size() <= 1) return Move.STAY; V nextPos = (V) path.get(1).getState(); V direction = V.sub(nextPos, me.pos); return Board.getDirectionToMoveMapping().get(direction); }
@Override public boolean test(Node currentNode) { V currentUnicornPos = (V) currentNode.getState(); for (V d : Board.getDirections()) { for (GameObject obj : board.at(V.add(currentUnicornPos, d))) { if (obj instanceof Cloud) { return true; } } } return false; }