コード例 #1
0
ファイル: Ant.cs プロジェクト: calebthompson/School
 private void ReleasePheromoneOnFood(Location foodLocation)
 {
     world.pheromone[foodLocation.x, foodLocation.y] += pheromoneStore * .25F;
 }
コード例 #2
0
ファイル: Ant.cs プロジェクト: calebthompson/School
 private void GetFood(Food food)
 {
     hasFood = true;
     Location foodLocation = new Location(food.location.Left, food.location.Top);
     ReleasePheromoneOnFood(foodLocation);
     food.GetFood();
 }
コード例 #3
0
ファイル: Ant.cs プロジェクト: calebthompson/School
        /// <summary>
        /// Finds the closest direction from one point to another in an 8 neighbor system.
        /// </summary>
        /// <param name="start">Starting position</param>
        /// <param name="end">End position</param>
        /// <returns>Float direction 0-7 for use in an 8 neighbor system.</returns>
        private float GetSecondaryDirection(Location start, Location end)
        {
            // Find direction in radians from start to end points
            double direction = GetDirectionInRadians(start, end);

            // Convert from radians to secondary direction denoted by 0-7.
            // Get direction + pi/8 then divide by pi / 4
            direction += Math.PI * .8;
            direction = (direction * 4) / Math.PI;
            return (float)direction;
        }
コード例 #4
0
ファイル: Ant.cs プロジェクト: calebthompson/School
 /// <summary>
 /// Finds direction in radians from a start to an end point
 /// </summary>
 /// <param name="start">Starting position</param>
 /// <param name="end">End position</param>
 /// <returns>Direction in radians from start to end as double.</returns>
 private double GetDirectionInRadians(Location start, Location end)
 {
     if ((start.x - end.x) != 0)
         return Math.Atan((start.y - end.y) / (start.x - end.x));
     else if (start.y < end.y)
         return 3 * Math.PI;
     else return Math.PI / 2;
 }