Fix boids not being spawned with settings values

This commit is contained in:
csd4ni3l
2025-09-14 22:35:32 +02:00
parent c010c41ccd
commit 49add1bc80
2 changed files with 10 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ class Boid(arcade.Sprite):
self.small_radius = 100
self.large_radius = 250
def calculate_separation(self, neighbours: list[int, arcade.math.Vec2, arcade.math.Vec2]):
def calculate_separation(self, neighbours):
steeraway_vectors = [arcade.math.Vec2(*self.position) - neighbour[2] for neighbour in neighbours]
if not steeraway_vectors:
@@ -26,7 +26,7 @@ class Boid(arcade.Sprite):
return (sum(steeraway_vectors) / len(steeraway_vectors)).normalize()
def calculate_alignment(self, neighbours: list[int, arcade.math.Vec2, arcade.math.Vec2]):
def calculate_alignment(self, neighbours):
directions = [neighbour[1] for neighbour in neighbours]
if not directions:
@@ -34,7 +34,7 @@ class Boid(arcade.Sprite):
return (sum(directions) / len(directions)).normalize()
def calculate_cohesion(self, neighbours: list[int, arcade.math.Vec2, arcade.math.Vec2]):
def calculate_cohesion(self, neighbours):
positions = [neighbour[2] for neighbour in neighbours]
if not positions:

View File

@@ -57,6 +57,13 @@ class Game(arcade.gui.UIView):
def create_boid(self, x, y):
boid = Boid(self.current_boid_num, x, y)
boid.w_alignment = self.settings["boid_simulator"]["w_alignment"]
boid.w_separation = self.settings["boid_simulator"]["w_separation"]
boid.w_cohesion = self.settings["boid_simulator"]["w_cohesion"]
boid.large_radius = self.settings["boid_simulator"]["large_radius"]
boid.small_radius = self.settings["boid_simulator"]["small_radius"]
self.boid_sprites.append(boid)
self.current_boid_num += 1