summaryrefslogtreecommitdiff
path: root/MorgSimulator/Dish.cs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-10-30 17:01:14 -0700
committerFuwn <[email protected]>2025-10-30 17:01:14 -0700
commit5cdde428a7f966f17f0a94eca7b94fbf1e499838 (patch)
tree5f94122032752e2561009ef1c5e5b6641c5fb73c /MorgSimulator/Dish.cs
parentrefactor(diagrams): Move present diagrams to assignment folder (diff)
downloadcst276-5cdde428a7f966f17f0a94eca7b94fbf1e499838.tar.xz
cst276-5cdde428a7f966f17f0a94eca7b94fbf1e499838.zip
feat: Implement Assignment 2 functionality
Diffstat (limited to 'MorgSimulator/Dish.cs')
-rw-r--r--MorgSimulator/Dish.cs6
1 files changed, 4 insertions, 2 deletions
diff --git a/MorgSimulator/Dish.cs b/MorgSimulator/Dish.cs
index d81fc8a..1813d5a 100644
--- a/MorgSimulator/Dish.cs
+++ b/MorgSimulator/Dish.cs
@@ -23,8 +23,10 @@ namespace MorgSimulator
Morg? nearestPrey = null;
double nearestDistance = double.MaxValue;
- foreach (var potentialPrey in _morgs.Where(m => m.IsAlive && m != predator))
- if (predator.CanEat(potentialPrey.Type))
+ foreach (var potentialPrey in _morgs)
+ if (potentialPrey.IsAlive &&
+ potentialPrey != predator &&
+ predator.CanEat(potentialPrey.Type))
{
double distance = predator.DistanceTo(potentialPrey.Location);