Exemplo n.º 1
0
    override public bool Level2GoalFunction(BlockWorld blockWorld)
    {
        int playerI   = blockWorld.Player.I;
        int playerJ   = blockWorld.Player.J;
        int opponentI = Level2DangerZone.SourceI;
        int opponentJ = Level2DangerZone.SourceJ;

        // Check distance
        if (Util.ManhattanDistance(playerI, playerJ, opponentI, opponentJ) <= RunAwayBlockDistance)
        {
            return(false);
        }

        // Enforce no ground above
        bool groundAbove = false;

        for (int j = playerJ; j >= 0; j--)
        {
            if (blockWorld.CheckGroundByIndex(playerI, j))
            {
                groundAbove = true;
                break;
            }
        }
        if (groundAbove)
        {
            return(false);
        }

        // Enforce no danger
        if (Level2DangerZone.CheckDanger(playerI, playerJ) != 0.0f)
        {
            return(false);
        }

        return(true);
    }
Exemplo n.º 2
0
 override public float Level2CostFunction(BlockWorld blockWorld)
 {
     return(1.0f + Level2DangerDistanceRatio * Level2DangerZone.CheckDanger(blockWorld.Player.I, blockWorld.Player.J));
 }