diff --git a/src/animals/fluffles.ts b/src/animals/fluffles.ts index 86a252f..651fb29 100644 --- a/src/animals/fluffles.ts +++ b/src/animals/fluffles.ts @@ -258,7 +258,7 @@ export class Fluffles extends Animal { ]; // Check each adjacent position for food - let bestFoodPosition = null; + let bestFoodPosition: Position | null = null; let bestFoodValue = 0; for (const pos of adjacentPositions) { @@ -309,7 +309,7 @@ export class Fluffles extends Animal { if (nearbyAnimals.length > 0) { // Find the closest fluffles - let closestFluffles = null; + let closestFluffles: Animal | null = null; let closestDistance = Infinity; for (const animal of nearbyAnimals) { @@ -368,7 +368,7 @@ export class Fluffles extends Animal { if (potentialTargets.length > 0) { // Find the closest target - let closestTarget = null; + let closestTarget: Animal | null = null; let closestDistance = Infinity; for (const animal of potentialTargets) { diff --git a/src/animals/rabbit.ts b/src/animals/rabbit.ts index fedf038..9391365 100644 --- a/src/animals/rabbit.ts +++ b/src/animals/rabbit.ts @@ -181,9 +181,10 @@ export class Rabbit extends Animal { private seekCompany(): void { const nearbyAnimals = this.world.getAnimalsInRadius(this.position, 3); + let closestRabbit: Animal | null = null; + if (nearbyAnimals.length > 0) { // Find the closest rabbit - let closestRabbit = null; let closestDistance = Infinity; for (const animal of nearbyAnimals) { @@ -214,6 +215,8 @@ export class Rabbit extends Animal { private searchForMates(): void { const nearbyAnimals = this.world.getAnimalsInRadius(this.position, 2); + let closestRabbit: Animal | null = null; + for (const animal of nearbyAnimals) { if (animal.getId() !== this.id) { // Not self const pos = animal.getPosition();