Compare commits

..

5 Commits

Author SHA1 Message Date
d3ed2d922e armeisen 2025-06-30 08:48:08 +02:00
e0b5a14a55 Update gitignore
Took 1 minute
2025-06-30 08:06:25 +02:00
d28b0d6699 add comments 2025-06-23 09:00:32 +02:00
635b5440d7 Update gitignore 2025-06-23 07:53:28 +02:00
63774c3267 turn fix 2025-06-16 13:43:00 +02:00
29 changed files with 173 additions and 361 deletions

5
.gitignore vendored
View File

@ -1 +1,4 @@
.vscode/launch.json
.vscode
armeisen/bin
armeisen/obj
.idea

View File

@ -1,3 +0,0 @@
{
"dotnet.defaultSolution": "armeisen.sln"
}

133
armeisen/Armeise.cs Normal file
View File

@ -0,0 +1,133 @@
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 MoveRandom()
{
Random rand = new Random();
if (rand.Next(0, 5) == 0)
{
this.TurnLeft();
}
else if (rand.Next(0, 5) == 1)
{
this.TurnRight();
}
this.Move(rand.Next(2, 7));
}
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);
}
}

27
armeisen/Map.cs Normal file
View File

@ -0,0 +1,27 @@
public class Map
{
public int sizeY = 100;
public int sizeX = 100;
// Draws map line by line, replacing the V wit A if ant there
public void DrawMap(Armeise[] armeisen)
{
for (int i = 0; i <= sizeY; i++)
{
for (int j = 0; j <= sizeX; j++)
{
foreach (Armeise armeise in armeisen)
{
if (i == armeise.posY && j == armeise.posX)
{
Console.Write('A');
break;
}
}
Console.Write('.');
}
Console.WriteLine();
}
Console.WriteLine();
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Threading;
namespace meise
{
@ -9,100 +10,20 @@ namespace meise
{
Map mapInstance = new Map();
Armeise armeise = new Armeise();
mapInstance.DrawMap(armeise.posX, armeise.posY);
armeise.Move(2);
mapInstance.DrawMap(armeise.posX, armeise.posY);
armeise.TurnRight();
armeise.Move(2);
mapInstance.DrawMap(armeise.posX, armeise.posY);
}
}
List<Armeise> colony = new List<Armeise>();
colony = Armeise.PrintColonyStateForEachArmeiseInTheColonyExistingIfItHasPositionAndType();
public class Map
while (true)
{
public int sizeY = 10;
public int sizeX = 10;
foreach (Armeise meise in colony)
{
meise.MoveRandom();
}
mapInstance.DrawMap(colony.ToArray());
// 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;
}
}
// Using enums to make turning easier like this
// Prevents ant from doing a U turn in one move
public void TurnRight()
{
directionFacing++;
}
public void TurnLeft()
{
directionFacing--;
Thread.Sleep(1000);
}
}
}
}

View File

@ -1,23 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"armeisen/1.0.0": {
"runtime": {
"armeisen.dll": {}
}
}
}
},
"libraries": {
"armeisen/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View File

@ -1,12 +0,0 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@ -1,4 +0,0 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@ -1,22 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("armeisen")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+101dedca7f0000a6490be72536deb2859167f446")]
[assembly: System.Reflection.AssemblyProductAttribute("armeisen")]
[assembly: System.Reflection.AssemblyTitleAttribute("armeisen")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1 +0,0 @@
aac56502c0079c943a87f6e8bae7d11cd21b0cc50bca17a7839d69eedffc7240

View File

@ -1,15 +0,0 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = armeisen
build_property.ProjectDir = c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@ -1,8 +0,0 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@ -1 +0,0 @@
e8d25f5345b911b7175c8170d0e47038a51514c9c6adc406c328c1398ac11154

View File

@ -1,14 +0,0 @@
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\bin\Debug\net9.0\armeisen.exe
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\bin\Debug\net9.0\armeisen.deps.json
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\bin\Debug\net9.0\armeisen.runtimeconfig.json
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\bin\Debug\net9.0\armeisen.dll
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\bin\Debug\net9.0\armeisen.pdb
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.GeneratedMSBuildEditorConfig.editorconfig
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.AssemblyInfoInputs.cache
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.AssemblyInfo.cs
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.csproj.CoreCompileInputs.cache
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.dll
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\refint\armeisen.dll
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.pdb
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\armeisen.genruntimeconfig.cache
c:\Users\jerome.hebenstrick\dev\armeisen\armeisen\obj\Debug\net9.0\ref\armeisen.dll

View File

@ -1 +0,0 @@
45138e8429f76ae75b3c66239d7fa22ed1172cd6774cb6d65f420bc207d39827

View File

@ -1,69 +0,0 @@
{
"format": 1,
"restore": {
"c:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj": {}
},
"projects": {
"c:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "c:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj",
"projectName": "armeisen",
"projectPath": "c:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj",
"packagesPath": "C:\\Users\\jerome.hebenstrick\\.nuget\\packages\\",
"outputPath": "c:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\jerome.hebenstrick\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.301/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\jerome.hebenstrick\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\jerome.hebenstrick\.nuget\packages\" />
</ItemGroup>
</Project>

View File

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@ -1,74 +0,0 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"C:\\Users\\jerome.hebenstrick\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj",
"projectName": "armeisen",
"projectPath": "C:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj",
"packagesPath": "C:\\Users\\jerome.hebenstrick\\.nuget\\packages\\",
"outputPath": "C:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\jerome.hebenstrick\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.301/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@ -1,8 +0,0 @@
{
"version": 2,
"dgSpecHash": "vSkkojAXr1E=",
"success": true,
"projectFilePath": "c:\\Users\\jerome.hebenstrick\\dev\\armeisen\\armeisen\\armeisen.csproj",
"expectedPackageFiles": [],
"logs": []
}