Esempio n. 1
0
    private InfluenceMap CreateInfluenceMap()
    {
//        double squareLength = (60 * 0.4);
        double squareLength = INFLUENCEMAP_SQUARELENGTH; //Maximum common divisor between 60, 100, 75, 50 (movement speeds)

        int          mapWidth     = (int)Math.Ceiling(1980 / squareLength);
        int          mapHeight    = (int)Math.Ceiling(1020 / squareLength);
        double       minInfluence = -100;
        double       maxInfluence = 100;
        InfluenceMap map          = new InfluenceMap(mapWidth, mapHeight, minInfluence, maxInfluence, new EuclideanDistanceSqr());

        var enemyUnits = currGameState.units
                         .Where(u => u.owner == Owner.Enemy);

        //Enemy units influence
        foreach (var enemy in enemyUnits)
        {
            Position enemyPos       = enemy.pos;
            double   enemyInfluence = GetEnemyInfluence(enemy);
            map.applyInfluence(enemyPos.x, enemyPos.y, enemyInfluence, GetEnemyInfluenceRadius(enemy), 0, 0);
        }

        return(map);
    }