⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ant.cs

📁 包括Pheromones Algorythm、Memory Algorythm和Hill Climbing Algorythm I
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;


namespace PathFinder
{
	/// <summary>
	/// Simple ant class
	/// </summary>
	public class Ant : Critter
	{

		/// <summary>
		/// is the ant in search of food
		/// </summary>
		private bool bFindFood;

		/// <summary>
		/// has the ant found the food
		/// </summary>
		private bool bHasFoundFood;

		/// <summary>
		/// Ant drawing stuff
		/// </summary>
		private bool bIsStart;


		private bool bDontAlwaysFollowStrongestPheromone;

		/// <summary>
		/// array required for algorythms that require memory
		/// </summary>
		private ArrayList arrayMemory;

		/// <summary>
		/// are we remebering where we have been
		/// </summary>
		private bool bUseMemory;

		/// <summary>
		/// remember where we are through the memory array
		/// </summary>
		private int nCurrentMemoryPosition;

		/// <summary>
		/// don't want to remember every move 
		/// </summary>
		private bool bRememberWayHome;

		/// <summary>
		///  array used to keep track of the hill climbing data
		/// </summary>
		private Hashtable hashHillClimbing = null;


		/// <summary>
		/// Number of Times the ant has found a food square
		/// </summary>
		private int nFoundFoodSquare;

		/// <summary>
		/// Number of Times Ant has found the nest square
		/// </summary>
		private int nFoundNestSquare;

		/// <summary>
		/// Number of times the ant has returned to the nest square with food
		/// </summary>
		private int nReturnedWithFood;



		/// <summary>
		///  is the ant at the start?
		/// </summary>
		public bool IsStart 
		{
			get
			{
				return bIsStart;
			}
			set
			{
				bIsStart = value;
			}
		}

		public ArrayList Memory
		{
			get
			{
				return arrayMemory;
			}
		}


		public bool UseMemory
		{
			get
			{
				return bUseMemory;
			}
			set
			{
				bUseMemory = value;
			}
		}

		public int CurrentMemoryPosition
		{
			get
			{
				return nCurrentMemoryPosition;
			}
			set
			{
				nCurrentMemoryPosition = value;
			}
		}

		public bool RememberWayHome
		{
			get
			{
				return bRememberWayHome;
			}
			set
			{
				bRememberWayHome = value;
			}
		}

		public bool DontAlwaysFollowStrongestPheromone
		{
			get
			{
				return bDontAlwaysFollowStrongestPheromone;
			}
			set
			{
				bDontAlwaysFollowStrongestPheromone = value;
			}
		}

		public bool FindFood
		{
			get
			{
				return bFindFood;
			}
			set
			{
				bFindFood = value;
			}
		}

		public bool HasFoundFood
		{
			get
			{
				return bHasFoundFood;
			}
			set
			{
				bHasFoundFood = value;
			}
		}

		public Hashtable HillClimbingTable
		{
			get
			{
				return hashHillClimbing;
			}
			set
			{
				hashHillClimbing = value;
			}
		}


		public int FoundFoodSquare
		{
			get
			{
				return nFoundFoodSquare;
			}
			set
			{
				nFoundFoodSquare = value;
			}
		}

		public int FoundNestSquare
		{
			get
			{
				return nFoundNestSquare;
			}
			set
			{
				nFoundNestSquare = value;
			}
		}

		public int ReturnedWithFood
		{
			get
			{
				return nReturnedWithFood;
			}
			set
			{
				nReturnedWithFood = value;
			}
		}

		public string Identifier
		{
			get
			{
				return "Ant " + CritterIdentifier.ToString();
			}
		}

		public Ant()
		{
			//
			// TODO: Add constructor logic here
			//

			bIsStart = true;

			bDontAlwaysFollowStrongestPheromone = true;

			bFindFood = true;
			bHasFoundFood = false;

			arrayMemory = new ArrayList();
			bUseMemory = false;
			nCurrentMemoryPosition = 0;
			bRememberWayHome = false;

			hashHillClimbing = null;


			FoundNestSquare = 0;
			FoundFoodSquare = 0;
			ReturnedWithFood = 0;
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -