Esempio n. 1
0
        private AgentModel[] RunAgents(AgentModel[] agentModels)
        {
            var agents = new List <Agent>(NumberOfAgents);

            foreach (var agentModel in agentModels)
            {
                //Create the agent
                var agent = new Agent(agentModel, _instructionFactory);

                agents.Add(agent);
            }

            var worldSize = new Size(WorldWidth, WorldHeight);

            var foodLocation = new Rect(new Point(FoodX, FoodY), new Size(FoodSize, FoodSize));

            //Create the world viewmodel
            var world = new WorldViewModel(agents, worldSize, foodLocation);

            for (int i = 0; i < NumberOfCycles; i++)
            {
                //IterationNumber = i;

                world.Cycle();
            }

            var lived = world.Agents
                        .Where(a => !a.IsDead)
                        .Select(a => a.GetModel())
                        .ToArray();

            return(lived);
        }
Esempio n. 2
0
 public AgentViewModel(WorldViewModel world, Agent agent, Point location)
 {
     Location = location;
     _world   = world;
     _agent   = agent;
 }