/// <summary> /// Simulate the generic actions that both normal and robber ants undertake when /// they are either wandering around or about to move to food source or nest. /// </summary> /// <param name="ant">The AntAgent to simulate it's generic actions.</param> private void GenericAntAction(AntAgent ant) { // Based on if the ant is currently carrying food or not. if (!ant.IsCarryingFood) { // If the ant knows where the location of the food is, then go there. if (ant.IsFoodKnown) { ant.IsMovingToFood = true; } else { ant.Wander(); } } // If it is carrying food.. else { // ..and if the location of the nest is known, then go there. if (ant.IsNestKnown) { ant.IsMovingToNest = true; } else { ant.Wander(); } } }
private void timer_Tick(object sender, EventArgs e) { SOFT152Vector tempPosition; // one each time tick each of the two agents makes one movment // set some values for agent1 // before it moves agent1.AgentSpeed = 1.0; agent1.WanderLimits = 0.25; // keep the agent within the world agent1.ShouldStayInWorldBounds = true; // let agent1 wander agent1.Wander(); // again set some values for agent2 before moving // agent2 is slower than agent1 to show some following behaviour agent2.AgentSpeed = 0.9; agent2.AvoidDistance = 100; agent2.ShouldStayInWorldBounds = true; agent3.AgentSpeed = 1.0; agent3.WanderLimits = 0.25; agent3.ShouldStayInWorldBounds = true; agent3.Wander(); // get agent1 position tempPosition = agent1.AgentPosition; // agent2.FleeFrom(tempPosition); agent2.Approach(tempPosition); // or get the agent to approach or flee from the stationary object // agent2.Approach(someObject); // after making a movement, now draw the agents // DrawAgents(); DrawAgentsDoubleBuffering(); }