package io.aigar;

import io.aigar.game.models.Cell;
import io.aigar.game.models.Coordinate;
import io.aigar.game.models.GameState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Ai {
    private static final Logger logger = LoggerFactory.getLogger(Ai.class);

    public void step(GameState game) {
        List<Coordinate> resources = game.getResources().getAllResources();

        for (Cell cell : game.getMe().getCells()) {
            Coordinate target = findClosest(resources, cell.getPosition());

            cell.move(target);
            cell.split();
        }
    }

    private Coordinate findClosest(List<Coordinate> coordinates, Coordinate currentPosition) {
        return coordinates.stream()
                .collect(Collectors.toMap(currentPosition::distanceTo, r -> r))
                .entrySet()
                .stream()
                .sorted(Map.Entry.comparingByKey()).map(Map.Entry::getValue)
                .findFirst()
                .orElse(null);
    }
}

@@ -204,70 +204,14 @@
 til.
-List;%0Aimport java.util.Map;%0Aimport java.util.stream.Collectors
+Random
 ;%0A%0Ap
@@ -302,16 +302,56 @@
 .class);
+%0A    private Random rand = new Random();
 %0A%0A    pu
@@ -395,237 +395,132 @@
     
-List%3CCoordinate%3E resources = game.getResources().getAllResources();%0A%0A        for (Cell cell : game.getMe().getCells()) %7B%0A            Coordinate target = findClosest(resources, cell.getPosition());%0A%0A            cell.move(t
+for (Cell cell : game.getMe().getCells()) %7B%0A            double distance = cell.getPosition().distanceTo(cell.getT
 arget
+()
 );%0A
+%0A
     
@@ -531,21 +531,28 @@
     
-cell.split();
+if (distance %3C 10) %7B
 %0A   
@@ -560,29 +560,16 @@
     
-%7D%0A
     
-%7D%0A%0A
     
-private 
 Coor
@@ -579,386 +579,174 @@
 ate 
-findClosest(List%3CCoordinate%3E coordinates, Coordinate currentPosition) %7B%0A        return coordinates.stream()%0A                .collect(Collectors.toMap(currentPosition::distanceTo, r -%3E r))%0A                .entrySet()%0A                .stream()%0A                .sorted(Map.Entry.comparingByKey()).map(Map.Entry::getValue)%0A                .findFirst()%0A                .orElse(null);
+target = new Coordinate(rand.nextDouble() * game.getMap().width, rand.nextDouble() * game.getMap().height);%0A                cell.move(target);%0A            %7D%0A        %7D
 %0A   

Make java bot dumb