diff options
| author | Fuwn <[email protected]> | 2025-11-20 19:17:14 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-11-20 19:17:14 -0800 |
| commit | 9858b069ea4264840d98094e2e36ad2517f2215f (patch) | |
| tree | 367ac8bcab6107ef8dfa4be524f834a5336d9bc3 /MorgSimulator/Program.cs | |
| parent | feat: Add Assignment 2 diagrams (diff) | |
| download | cst276-9858b069ea4264840d98094e2e36ad2517f2215f.tar.xz cst276-9858b069ea4264840d98094e2e36ad2517f2215f.zip | |
feat: Implement Assignment 3 functionality
Diffstat (limited to 'MorgSimulator/Program.cs')
| -rw-r--r-- | MorgSimulator/Program.cs | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/MorgSimulator/Program.cs b/MorgSimulator/Program.cs index 29fd971..3cb336b 100644 --- a/MorgSimulator/Program.cs +++ b/MorgSimulator/Program.cs @@ -11,7 +11,7 @@ int id = 1; while (!morgReader.EndOfStream) { - var morg = morgReader.ReadMorg(id++); + var morg = morgReader.ReadEntity(id++); if (morg != null) dish.AddMorg(morg); @@ -21,26 +21,4 @@ morgReader.Close(); const int RUN_TIME = 15; -for (int timeStep = 0; timeStep < RUN_TIME; timeStep++) - foreach (var morg in dish.GetAllMorgs()) - if (morg.IsAlive) - { - if (morg.Prey == null || !morg.Prey.IsAlive) - { - var nearestPrey = dish.FindNearestPrey(morg); - - if (nearestPrey != null) - { - nearestPrey.Attach(morg); - - morg.Prey = nearestPrey; - morg.Direction = morg.CalculateDirectionToTarget(nearestPrey.Location); - } - } - - morg.Move(); - morg.Notify(); - - if (morg.Prey != null && morg.Prey.IsAlive && morg.DistanceTo(morg.Prey.Location) <= 1.0) - morg.Feed(); - } +dish.Run(RUN_TIME); |