package bot.Bender1;

import algorithms.dijkstra.Dijkstra;
import bot.Bender.ISimplifiedGState;
import bot.Bender.Map;
import bot.Bender0.RewardConfig;
import bot.dto.GameState;

/**
 * Created by slaan on 02.11.15.
 */
public class SimplifiedGState1 implements ISimplifiedGState {

    private Quantity life;
    private int lifeHP;
    private Quantity noOfOurMines;
    private int mineCount;
    private SimpleHero closestHero=null;
    private SimpleMine closestMine;
    private SimpleTavern closestTavern;
    private Map map;
    private Dijkstra dijkstra;
    private GameState.Position spawn;
    private GameState.Position currentPos;

    public SimplifiedGState1() {
    }

    public void init(GameState gameState) {
        map = new Map(gameState);
        spawn = gameState.getHero().getSpawnPos();
        currentPos = gameState.getHero().getPos();

        dijkstra = new Dijkstra(map, spawn);
        dijkstra.runDijkstra();

        life = calcLife(gameState.getHero().getLife());
        noOfOurMines = calcNoOfMines(gameState.getHero().getMineCount());
        closestHero = null;
        closestMine = dijkstra.getNearestMine();
        closestTavern = dijkstra.getNearestTavern();
        lifeHP = gameState.getHero().getLife();
        mineCount = gameState.getHero().getMineCount();
    }

    private Quantity calcNoOfMines(int mineCount) {
        if (mineCount<=RewardConfig.getLowerMineBoundryTotal()) {
            return Quantity.FEW;
        } else if (mineCount<=RewardConfig.getUpperMineBoundryTotal()) {
            return Quantity.MIDDLE;
        } else {
            return Quantity.LOTS;
        }
    }

    private Quantity calcLife(int life) {
        if (life>=RewardConfig.getUpperLifeboundry()) {
            return Quantity.LOTS;
        } else if (life>=RewardConfig.getLowerLifeBoundry()){
            return Quantity.MIDDLE;
        } else {return Quantity.FEW; }
    }


    public Quantity getLife() {
        return life;
    }

    public Quantity getNoOfOurMines() {
        return noOfOurMines;
    }

    public SimpleHero getClosestHero() {
        return closestHero;
    }

    public SimpleMine getClosestMine() {
        return closestMine;
    }

    public SimpleTavern getClosestTavern() {
        return closestTavern;
    }

    public Map getMap() {
        return map;
    }

    public GameState.Position getSpawn() {
        return spawn;
    }

    public GameState.Position getCurrentPos() {
        return currentPos;
    }

    public int generateGStateId() {

        return 0;
    }

    public int getLifeHP() {
        return lifeHP;
    }

    public int getMineCount() {
        return mineCount;
    }
}

@@ -15,16 +15,45 @@
 nder1;%0A%0A
+import algorithms.IdShifter;%0A
 import a
@@ -303,16 +303,194 @@
 GState %7B
+%0A    static final int ID_SHIFT_DISTANCE = 3;%0A    static final int ID_SHIFT_QUANTITY = 2;%0A    static final int ID_SHIFT_DIRECTION = 3;%0A    static final int ID_SHIFT_MINECOUNT = 1;
 %0A%0A    pr
@@ -2739,25 +2739,1060 @@
 ) %7B%0A
-%0A        return 0
+        IdShifter id = new IdShifter();%0A        id.shift(getLife().getValue(), ID_SHIFT_QUANTITY);%0A        id.shift(getNoOfOurMines().getValue(), ID_SHIFT_QUANTITY);%0A        id.shift(getClosestMine().getDirection().getValue(), ID_SHIFT_DIRECTION);%0A        // TODO: implement closest hero.%0A        //id.shift(getClosestHero().getDirection().getValue(), ID_SHIFT_DIRECTION);%0A        id.shift(0, ID_SHIFT_DIRECTION);%0A        id.shift(getClosestTavern().getDirection().getValue(), ID_SHIFT_DIRECTION);%0A        id.shift(getClosestMine().getDistance().getValue(), ID_SHIFT_DISTANCE);%0A        //id.shift(getClosestHero().getDistance().getValue(), ID_SHIFT_DISTANCE);%0A        id.shift(0, ID_SHIFT_DISTANCE);%0A        //id.shift(getClosestHero().getHealth().getValue(), ID_SHIFT_QUANTITY);%0A        id.shift(0, ID_SHIFT_QUANTITY);%0A        //id.shift(getClosestHero().getNoOfMines().getValue(), ID_SHIFT_MINECOUNT);%0A        id.shift(0, ID_SHIFT_MINECOUNT);%0A        id.shift(getClosestTavern().getDistance().getValue(), ID_SHIFT_DISTANCE);%0A        return id.getId()
 ;%0A  

Add initial implementation of ID generation for Bender1.