示例#1
0
        /// <summary>
        /// This is the entry point to the AI proper.
        /// Currently this does not use anything recognized by Computer Science as AI,
        /// just functional programming to complete a list of tasks.
        /// </summary>
        public override void DoMove()
        {
            aiPlan = new DefaultAIPlanner(clientState);

            // create the helper AIs
            foreach (Star star in clientState.EmpireState.OwnedStars.Values)
            {
                if (star.Owner == clientState.EmpireState.Id)
                {
                    DefaultPlanetAI planetAI = new DefaultPlanetAI(star, clientState, this.aiPlan);
                    planetAIs.Add(star.Key, planetAI);
                }
            }

            foreach (Fleet fleet in clientState.EmpireState.OwnedFleets.Values)
            {
                if (fleet.Owner == clientState.EmpireState.Id)
                {
                    aiPlan.CountFleet(fleet);
                    DefaultFleetAI fleetAI = new DefaultFleetAI(fleet, clientState, fuelStations);
                    fleetAIs.Add(fleet.Id, fleetAI);

                    // reset all waypoint orders
                    for (int wpIndex = 1; wpIndex < fleet.Waypoints.Count; wpIndex++)
                    {
                        WaypointCommand command = new WaypointCommand(CommandMode.Delete, fleet.Key, wpIndex);
                        command.ApplyToState(clientState.EmpireState);
                        clientState.Commands.Push(command);
                    }
                }
            }

            turnData = clientState.InputTurn;

            HandleProduction();
            HandleResearch();
            HandleScouting();
            HandleColonizing();
        }
示例#2
0
 /// <summary>
 /// Initializing constructor.
 /// </summary>
 /// <param name="newStar">The planet the ai is to manage.</param>
 public DefaultPlanetAI(Star newStar, ClientData newState, DefaultAIPlanner newAIPlan)
 {
     planet      = newStar;
     clientState = newState;
     aiPlan      = newAIPlan;
 }