Ejemplo n.º 1
0
        public void Update(MapState state, GameManger Manager)
        {
            List<Fleet> fleets = state.Fleets;
            foreach (Planet myPlanet in state.GetMyPlanets(PlayerType.AI))
            {
                Planet Attack = null;
                float LowestScore = float.PositiveInfinity;

                foreach (Planet planet in state.GetEnemyPlanets(PlayerType.AI))
                {
                    float Score = Vector2.Distance(planet.Position, myPlanet.Position) * (((float)planet.Forces[planet.Owner]) / myPlanet.Forces[myPlanet.Owner])/myPlanet.Growth;
                    if (Score < LowestScore)
                    {
                        Attack = planet;
                        LowestScore = Score;
                    }
                }

                if (Attack != null)
                {
                    if ((Attack.Forces[Attack.Owner] + 1) / Manager.AIAttackBias < myPlanet.Forces[myPlanet.Owner])
                    {
                        Manager.SendFleet((int)((Attack.Forces[Attack.Owner] + 1) / Manager.AIAttackBias), myPlanet, Attack);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Update(MapState state, GameManger Manager)
        {
            List<Fleet> fleets = state.Fleets;
            foreach (Planet myPlanet in state.GetMyPlanets(PlayerType.AI))
            {
                Planet Attack = null;
                float LowestScore = float.PositiveInfinity;

                foreach (Planet planet in state.GetEnemyPlanets(PlayerType.AI))
                {

                    bool Flying = false;
                    foreach (Fleet f in fleets)
                    {
                        if (f.Owner == PlayerType.AI)
                        {
                            if (f.Destination.ID == planet.ID)
                            {
                                Flying = true;
                                break;
                            }
                        }
                    }

                    if (Flying)
                        continue;
                    float Score = 2*Vector2.Distance(planet.Position, myPlanet.Position)*(((float)planet.Forces[planet.Owner])/myPlanet.Forces[myPlanet.Owner]);
                    if (planet.Owner == PlayerType.Player)
                    {
                        Score *= 10;
                    }
                    if (Score < LowestScore)
                    {
                        Attack = planet;
                        LowestScore = Score;
                    }
                }

                if (Attack != null)
                {
                    if ((Attack.Forces[Attack.Owner]+1)/Manager.AIAttackBias < myPlanet.Forces[myPlanet.Owner]/2)
                    {
                        Manager.SendFleet(myPlanet.Forces[myPlanet.Owner] / 2, myPlanet, Attack);
                    }
                    return;
                }
            }
        }