Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            int borderX = 120;
            int borderY = 40;

            Console.SetWindowSize(borderX + 10, borderY + 10);
            ant[] ameisen = new ant[20];
            food  essen   = new food()
            {
                limitX = borderX, limitY = borderY
            };



            for (int i = 0; i < ameisen.Length; i++)
            {
                ameisen[i] = new ant()
                {
                    limitX = borderX, limitY = borderY
                };
                ameisen[i].Spawn();
            }

            essen.Spawn();


            while (true)
            {
                foreach (ant ameise in ameisen)
                {
                    ameise.SeekFood(essen);
                }
                essen.Show();

                System.Threading.Thread.Sleep(200);
            }


            //Console.ResetColor();


//			Here is the comment section for remembering stuff:

//			Console.SetWindowSize(borderX, borderY);
//	        Console.SetCursorPosition(10, 10);
//	        Console.WriteLine("A");
//	        System.Threading.Thread.Sleep(500);
//	        Console.Clear();
//	        //System.Threading.Thread.Sleep(500);
//	        Console.SetCursorPosition(11, 10);
//	        Console.WriteLine("A");

//	        for (int i = 0; i < borderX; i++)               // Move from left to right
//	        {
//		        Console.SetCursorPosition(i, 10);
//		        Console.WriteLine("A");
//		        System.Threading.Thread.Sleep(200);
//		        Console.Clear();
//	        }
        }
Exemplo n.º 2
0
        public AmeisenSimulation(int grenzeX = 120, int grenzeY = 40, int ameisenAnzahl = 20)
        {
            ameisen = new ant[ameisenAnzahl];
            essen   = new food(grenzeX, grenzeY);
            zuHause = new home(grenzeX, grenzeY);
            Console.SetWindowSize(grenzeX + 10, grenzeY + 10);

            for (int i = 0; i < ameisen.Length; i++)
            {
                ameisen[i] = new ant(grenzeX, grenzeY);
            }

            while (true)
            {
                foreach (ant ameise in ameisen)
                {
                    ameise.Seek(essen, zuHause);
                }

                if (essen.foodLeft > 0)
                {
                    essen.Draw("F");
                }
                else
                {
                    essen = new food(grenzeX, grenzeY);
                }

                zuHause.Draw("H");
                Console.SetCursorPosition(0, grenzeY + 5);
                Console.WriteLine("food: " + zuHause.foodCount);
                System.Threading.Thread.Sleep(100);
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            int borderX = 80;
            int borderY = 25;

//			Console.SetWindowSize(borderX, borderY);
//	        Console.SetCursorPosition(10, 10);
//	        Console.WriteLine("A");
//	        System.Threading.Thread.Sleep(500);
//	        Console.Clear();
//	        //System.Threading.Thread.Sleep(500);
//	        Console.SetCursorPosition(11, 10);
//	        Console.WriteLine("A");

//	        for (int i = 0; i < borderX; i++)               // Move from left to right
//	        {
//		        Console.SetCursorPosition(i, 10);
//		        Console.WriteLine("A");
//		        System.Threading.Thread.Sleep(200);
//		        Console.Clear();
//	        }

            //ant Ameise01 = new ant();
            ant Ameise02 = new ant();

            //Ameise01.Spawn();
            Ameise02.Spawn();
            //Console.SetCursorPosition(Ameise01.GetPosX(), Ameise01.GetPosY());
            //Ameise01.ShowAnt();
            Console.SetCursorPosition(Ameise02.GetPosX(), Ameise02.GetPosY());
            Ameise02.ShowAnt();



            while (true)
            {
                //Ameise01.Move();
                Ameise02.Move();
                //Ameise01.ShowAnt();
                Ameise02.ShowAnt();
                System.Threading.Thread.Sleep(200);
            }


            //Console.ResetColor();


            // TODO: Implement Functionality Here

            //Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }