Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/CogitoNTNU/CrawlAI
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniavm committed Nov 11, 2024
2 parents 2aa3ee3 + b90b804 commit b1faaa8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
19 changes: 16 additions & 3 deletions src/agent_parts/creature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@ class Creature:
motors: list[MotorJoint]

def __init__(self, space):
"""Initialize a creature with an empty list of limbs and motors."""
"""
Initialize a creature with an empty list of limbs and motors.
"""

self.space = space
self.limbs = []
self.motors = []
self.relative_vectors = []

def add_limb(self, width: float, height: float, position: tuple[float,float], mass=1, color=(0, 255, 0)) -> Limb:
"""Add a limb to the creature."""
"""
Add a limb to the creature.
Args:
- width: The width of the limb.
- height: The height of the limb.
- position: The position of the limb.
- mass: The mass of the limb
- color: The color of the limb.
"""
limb = Limb(self.space, width, height, position, mass, color)
self.limbs.append(limb)
return limb
Expand Down Expand Up @@ -54,7 +67,7 @@ def local_to_global(self, limb: Limb, anchor: tuple[float,float]) -> tuple[float



def add_motor(self, limb_a: Limb, limb_b: Limb, anchor_a: tuple[float,float], anchor_b: tuple[float,float], rate = 0.0, tolerance = 30) -> MotorJoint|None:
def add_motor(self, limb_a: Limb, limb_b: Limb, anchor_a: tuple[float,float], anchor_b: tuple[float,float], rate = 0.0, tolerance = 10) -> MotorJoint|None:
"""Add a motor connecting two limbs."""
global_a = self.local_to_global(limb_a, anchor_a)
global_b = self.local_to_global(limb_b, anchor_b)
Expand Down
7 changes: 3 additions & 4 deletions src/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,15 @@ def update(
x2 = x1 + self.sight_width
try:
y1=ground.get_y(x1+scroll_offset)
self.near_periphery = Point(x1, y1)
except:
pass
try:
y2=ground.get_y(x2+scroll_offset)
self.far_periphery = Point(x2, y2)
except:
pass
if not y1 is None:
self.near_periphery = Point(x1, y1)
if not y2 is None:
self.far_periphery = Point(x2, y2)

self.render_vision(screen)

def render_vision(self, screen):
Expand Down

0 comments on commit b1faaa8

Please sign in to comment.