summaryrefslogtreecommitdiff
path: root/MorgSimulator/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MorgSimulator/Program.cs')
-rw-r--r--MorgSimulator/Program.cs26
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);