type declaration semantic fixes

This commit is contained in:
tcsenpai 2025-03-30 22:57:21 +02:00
parent d3a19c7989
commit 4c84792f3b
2 changed files with 7 additions and 4 deletions

View File

@ -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) {

View File

@ -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();