@Override
    public void update() {
        
        fov.update(x,y,9);
        
        int px = screen.getPlayerX();
        int py = screen.getPlayerY();
        
        if (!fov.isVisible(px,py))
            return;
        
        int cdx = 0;
        int cdy = 0;
        
        double currentWorth = 10000;
        
        for (int ox=-1;ox<=1;ox++) {
            for (int oy=-1;oy<=1;oy++) {
                if (ox==0 && oy==0)
                    continue;
                if (!world.getTile(x+ox,y+oy).isPassable || world.getEnemy(x+ox,y+oy)!=null)
                    continue;
                double worth = (x+ox-px)*(x-px+ox) + (y+oy-py)*(y+oy-py);
                if (worth < currentWorth) {
                    currentWorth = worth;
                    cdx = ox;
                    cdy = oy;
                }
            }
        }
        moveBy(cdx,cdy);
    }