Beispiel #1
0
    public void Execute(Actions action)
    {
        TEventEntity objective;

        switch (action)
        {
        case Actions.Wait:
        default:
            return;

        case Actions.Heal:
            HealMyPlanets();
            return;

        case Actions.Upgrade:
            LevelUpMyPlanets();
            return;

        case Actions.AttackNeutral:
            //print("Hay neutrales");
            if (ThereAreNeutralPlanets())
            {
                objective = TEffector.GetNearestPlanet(myPlayer, map, true);
                Attack(objective, rand.NextDouble() > 0.25f);
            }
            return;

        case Actions.AttackEnemy:
            objective = TEffector.GetNearestPlanet(myPlayer, map);
            Attack(objective, rand.NextDouble() > 0.25f);
            return;
        }
    }
Beispiel #2
0
    public Actions Decide()
    {
        bool attack       = false;
        bool attackNeutal = false;

        if (PlanetsNeedHealing())
        {
            return(Actions.Heal);
        }

        if (PlanetsNotAtMaximmumLevel() && rand.NextDouble() > 0.5f)
        {
            return(Actions.Upgrade);
        }

        if (rand.NextDouble() > 0.4f)
        {
            if (rand.NextDouble() > 0.5f)
            {
                attack = true;
            }
            else
            {
                attackNeutal = true;
            }
        }

        TEventEntity objective;

        if (ThereAreNeutralPlanets() && !attack)
        {
            //print("Hay neutrales");
            objective = TEffector.GetNearestPlanet(myPlayer, map, true);
            if (myPlayer.GetCurrentUnitsNumber() > TEffector.CountNecessaryUnitsToConquer(objective, myPlayer) * 1.5f || attackNeutal)
            {
                return(Actions.AttackNeutral);
            }
        }
        else
        {
            objective = TEffector.GetNearestPlanet(myPlayer, map);
            if (myPlayer.GetCurrentUnitsNumber() > TEffector.CountNecessaryUnitsToConquer(objective, myPlayer) * 1.5f || attack)
            {
                return(Actions.AttackEnemy);
            }
        }
        return(Actions.Wait);
    }
Beispiel #3
0
    private void initializeAI(TEventEntity[] level)
    {
        switch (typeAI)
        {
        case AIType.Dumb:
            this.AI = new DumbAI();
            break;

        case AIType.Random:
        case AIType.Montecarlo:     //to avoid overloading the simulation
            this.AI = new RandomAI();
            break;

        case AIType.Classic:
            this.AI = new TClasicAI(this, level);
            break;
        }
        effector = new TEffector(this, level);
    }
 public EffectorProxyImplementation(TEffector effector)
 {
     this.effector = effector;
 }