add comments

This commit is contained in:
2025-06-23 08:59:28 +02:00
parent 635b5440d7
commit d28b0d6699
4 changed files with 149 additions and 92 deletions

5
.gitignore vendored
View File

@ -1,4 +1,3 @@
.vscode .vscode
.idea armeisen/bin
dist armeisen/obj
build

118
armeisen/Armeise.cs Normal file
View File

@ -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<Armeise> 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<Armeise> PrintColonyStateForEachArmeiseInTheColonyExistingIfItHasPositionAndType(int amount = 100)
{
List<Armeise> colony = new List<Armeise>();
for (int i = 0; i <= amount; i++)
{
colony.Add(new Armeise());
}
return colony;
}
// public (Armeise, bool) Sex(List<Armeise> 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);
}
}

26
armeisen/Map.cs Normal file
View File

@ -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();
}
}

View File

@ -9,97 +9,11 @@ namespace meise
{ {
Map mapInstance = new Map(); Map mapInstance = new Map();
Armeise armeise = new Armeise(); Armeise armeise = new Armeise();
mapInstance.DrawMap(armeise.posX, armeise.posY);
armeise.TurnLeft(); List<Armeise> colony = new List<Armeise>();
armeise.TurnLeft(); 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);
} }
} }
} }