From d28b0d6699af61ecbb5dd33c0848a7b4da05730e Mon Sep 17 00:00:00 2001 From: vaeris Date: Mon, 23 Jun 2025 08:59:28 +0200 Subject: [PATCH] add comments --- .gitignore | 5 +- armeisen/Armeise.cs | 118 ++++++++++++++++++++++++++++++++++++++++++++ armeisen/Map.cs | 26 ++++++++++ armeisen/Program.cs | 92 ++-------------------------------- 4 files changed, 149 insertions(+), 92 deletions(-) create mode 100644 armeisen/Armeise.cs create mode 100644 armeisen/Map.cs diff --git a/.gitignore b/.gitignore index 79e5f6d..bc586fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .vscode -.idea -dist -build +armeisen/bin +armeisen/obj \ No newline at end of file diff --git a/armeisen/Armeise.cs b/armeisen/Armeise.cs new file mode 100644 index 0000000..06d2c5a --- /dev/null +++ b/armeisen/Armeise.cs @@ -0,0 +1,118 @@ +public class Armeise + { + public int posY { get; set; } + public int posX { get; set; } + + public int age { get; set;} + public int agedSinceLastMove { get; set; } + + public ArmeiseType type { get; set; } + public Directions directionFacing { get; set; } + // Enum to have it obviousè what way turning + public enum Directions + { + North, + East, + South, + West + } + + public enum ArmeiseType + { + Queen, + MaleWorker + } + + public Armeise(ArmeiseType _type = ArmeiseType.MaleWorker) + { + Random rand = new Random(); + posX = rand.Next(0, 100); + posY = rand.Next(0, 100); + directionFacing = Directions.North; + type = _type; + } + + public void MoveRandom(int borderX, int borderY) + { + int minMove = 2; + int maxMove = 6; + int test = 3; + } + + public static void ShowStats(List meisen) + { + foreach (Armeise meise in meisen) + { + Console.Write("Position X: " + meise.posX); + Console.Write(" Position Y: " + meise.posY); + Console.Write(" Type: " + meise.type); + Console.WriteLine(); + } + } + /** + @returns + Outputs all of the Armeisen that exist in a List of Armeisen, printing Position and type in the format of + Position X: [Position X] Position Y: [Position Y] Type: [Type]. Method will crash the whole ass program if + there is a Armeise without either Type, Position Y or Position X because i am and always will be too lazy + to actually error handle this program, it is way too annoying and I dont have the motivation to do it, i + mean like programming is fun and all but this is too much, i never want to do annoying work like this + Anyways, yeah this is what the method does. I hope whoever reads this has a nice day. + @Params amount: naja also wie soll ich sagen, ist halt relativ offensichtlich oder? Schau dir am besten + nochmal die methode an haher. Dann siehst du das vielleicht. Doch nicht? dann kann ichs dir auch verraten + Es ist ein Integer. Eine Zahl. Und naja der name davon ist halt amount. Zu deutsch ist es anzahl. 금액. määrä. + summa. сумма. Wenn du es jetzt nicht verstanden ist kann ich auch nicht helfen. + **/ + public static List PrintColonyStateForEachArmeiseInTheColonyExistingIfItHasPositionAndType(int amount = 100) + { + List colony = new List(); + for (int i = 0; i <= amount; i++) + { + colony.Add(new Armeise()); + } + return colony; + } + + // public (Armeise, bool) Sex(List armeisen) + // { + // foreach (Armeise armeise in armeisen) + // { + // if ((armeise.posX - this.posX == 1 || armeise.posX - this.posX == -1) && (armeise.posY - this.posY == 1 || armeise.posY - this.posY == -1)) + // { + // return new Armeise(); + + // } + // return false; + // } + // } + + public void Move(int steps) + { + switch (directionFacing) + { + case Directions.North: + posY -= steps; + break; + case Directions.East: + posX += steps; + break; + case Directions.South: + posY += steps; + break; + case Directions.West: + posX -= steps; + break; + default: + break; + } + } + // Moves the direction one up or down in the enum + // Prevents ant from U-Turn and need modulo wrapping for north to west + public void TurnRight() + { + directionFacing = (Directions)(((int)directionFacing + 1) % 4); + } + public void TurnLeft() + { + directionFacing = (Directions)(((int)directionFacing - 1 + 4) % 4); + } + } \ No newline at end of file diff --git a/armeisen/Map.cs b/armeisen/Map.cs new file mode 100644 index 0000000..0df52f0 --- /dev/null +++ b/armeisen/Map.cs @@ -0,0 +1,26 @@ +public class Map + { + public int sizeY = 10; + public int sizeX = 10; + + // Draws map line by line, replacing the V wit A if ant there + public void DrawMap(int armeiseX, int armeiseY) + { + for (int i = 0; i <= sizeY; i++) + { + for (int j = 0; j <= sizeX; j++) + { + if (i == armeiseY && j == armeiseX) + { + Console.Write('A'); + } + else + { + Console.Write('V'); + } + } + Console.WriteLine(); + } + Console.WriteLine(); + } + } \ No newline at end of file diff --git a/armeisen/Program.cs b/armeisen/Program.cs index 597855b..547421e 100644 --- a/armeisen/Program.cs +++ b/armeisen/Program.cs @@ -9,97 +9,11 @@ namespace meise { Map mapInstance = new Map(); Armeise armeise = new Armeise(); - mapInstance.DrawMap(armeise.posX, armeise.posY); - armeise.TurnLeft(); - armeise.TurnLeft(); - } - } + List colony = new List(); + colony = Armeise.PrintColonyStateForEachArmeiseInTheColonyExistingIfItHasPositionAndType(); + Armeise.ShowStats(colony); - public class Map - { - public int sizeY = 10; - public int sizeX = 10; - - // Draws map line by line, replacing the V wit A if ant there - public void DrawMap(int armeiseX, int armeiseY) - { - for (int i = 0; i <= sizeY; i++) - { - for (int j = 0; j <= sizeX; j++) - { - if (i == armeiseY && j == armeiseX) - { - Console.Write('A'); - } - else - { - Console.Write('V'); - } - } - Console.WriteLine(); - } - Console.WriteLine(); - } - } - - public class Armeise - { - public int posY { get; set; } - public int posX { get; set; } - public Directions directionFacing { get; set; } - // Enum to have it obviousè what way turning - public enum Directions - { - North, - East, - South, - West - } - - public Armeise(int x = 0, int y = 0) - { - posX = x; - posY = y; - directionFacing = Directions.East; - } - - public void MoveRandom(int borderX, int borderY) - { - int minMove = 2; - int maxMove = 6; - int test = 3; - } - - public void Move(int steps) - { - switch (directionFacing) - { - case Directions.North: - posY -= steps; - break; - case Directions.East: - posX += steps; - break; - case Directions.South: - posY += steps; - break; - case Directions.West: - posX -= steps; - break; - default: - break; - } - } - // Moves the direction one up or down in the enum - // Prevents ant from U-Turn and need modulo wrapping for north to west - public void TurnRight() - { - directionFacing = (Directions)(((int)directionFacing + 1) % 4); - } - public void TurnLeft() - { - directionFacing = (Directions)(((int)directionFacing - 1 + 4) % 4); } } } \ No newline at end of file