moved max linear and angular accelerations and velocities for default cells over to constants.py and increased the max angular velocity and acceleration
Some checks failed
Build Simulation and Test / Run All Tests (push) Failing after 33s
Some checks failed
Build Simulation and Test / Run All Tests (push) Failing after 33s
This commit is contained in:
parent
9f0d6a6925
commit
91fef15572
@ -54,6 +54,12 @@ ARROW_TIP_SIZE = 5
|
|||||||
ANGULAR_TIP_SIZE = 2.5
|
ANGULAR_TIP_SIZE = 2.5
|
||||||
DIRECTION_TIP_SIZE = 3
|
DIRECTION_TIP_SIZE = 3
|
||||||
|
|
||||||
|
# Cell physics settings
|
||||||
|
MAX_ACCELERATION = 0.1
|
||||||
|
MAX_ANGULAR_ACCELERATION = 0.25
|
||||||
|
MAX_VELOCITY = 0.5
|
||||||
|
MAX_ROTATIONAL_VELOCITY = 6
|
||||||
|
|
||||||
KEYMAP_LEGEND = [
|
KEYMAP_LEGEND = [
|
||||||
("WASD", "Move camera"),
|
("WASD", "Move camera"),
|
||||||
("Mouse wheel", "Zoom in/out"),
|
("Mouse wheel", "Zoom in/out"),
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from config.constants import MAX_VELOCITY, MAX_ACCELERATION, MAX_ROTATIONAL_VELOCITY, MAX_ANGULAR_ACCELERATION
|
||||||
from world.base.brain import CellBrain
|
from world.base.brain import CellBrain
|
||||||
from world.behavioral import BehavioralModel
|
from world.behavioral import BehavioralModel
|
||||||
from world.world import Position, BaseEntity, Rotation
|
from world.world import Position, BaseEntity, Rotation
|
||||||
@ -298,8 +299,8 @@ class DefaultCell(BaseEntity):
|
|||||||
output_data = self.behavioral_model.tick(input_data)
|
output_data = self.behavioral_model.tick(input_data)
|
||||||
|
|
||||||
# clamp accelerations
|
# clamp accelerations
|
||||||
output_data["linear_acceleration"] = max(-0.1, min(0.1, output_data["linear_acceleration"]))
|
output_data["linear_acceleration"] = max(-MAX_ACCELERATION, min(MAX_ACCELERATION, output_data["linear_acceleration"]))
|
||||||
output_data["angular_acceleration"] = max(-0.1, min(0.1, output_data["angular_acceleration"]))
|
output_data["angular_acceleration"] = max(-MAX_ANGULAR_ACCELERATION, min(MAX_ANGULAR_ACCELERATION, output_data["angular_acceleration"]))
|
||||||
|
|
||||||
# 2. Apply drag force
|
# 2. Apply drag force
|
||||||
drag_coefficient = 0.02
|
drag_coefficient = 0.02
|
||||||
@ -329,10 +330,9 @@ class DefaultCell(BaseEntity):
|
|||||||
self.velocity = (velocity_x, velocity_y)
|
self.velocity = (velocity_x, velocity_y)
|
||||||
|
|
||||||
# # clamp velocity
|
# # clamp velocity
|
||||||
max_speed = 0.5
|
|
||||||
speed = math.sqrt(self.velocity[0] ** 2 + self.velocity[1] ** 2)
|
speed = math.sqrt(self.velocity[0] ** 2 + self.velocity[1] ** 2)
|
||||||
if speed > max_speed:
|
if speed > MAX_VELOCITY:
|
||||||
scale = max_speed / speed
|
scale = MAX_VELOCITY / speed
|
||||||
self.velocity = (self.velocity[0] * scale, self.velocity[1] * scale)
|
self.velocity = (self.velocity[0] * scale, self.velocity[1] * scale)
|
||||||
|
|
||||||
# tick velocity
|
# tick velocity
|
||||||
@ -347,7 +347,7 @@ class DefaultCell(BaseEntity):
|
|||||||
self.rotational_velocity += self.angular_acceleration
|
self.rotational_velocity += self.angular_acceleration
|
||||||
|
|
||||||
# clamp rotational velocity
|
# clamp rotational velocity
|
||||||
self.rotational_velocity = max(-3, min(3, self.rotational_velocity))
|
self.rotational_velocity = max(-MAX_ROTATIONAL_VELOCITY, min(MAX_ROTATIONAL_VELOCITY, self.rotational_velocity))
|
||||||
|
|
||||||
# tick rotational velocity
|
# tick rotational velocity
|
||||||
self.rotation.set_rotation(self.rotation.get_rotation() + self.rotational_velocity)
|
self.rotation.set_rotation(self.rotation.get_rotation() + self.rotational_velocity)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user