Skip to content

Commit

Permalink
chore: add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasfremming committed Nov 8, 2024
1 parent 7ab2232 commit b90b804
Showing 1 changed file with 16 additions and 3 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

0 comments on commit b90b804

Please sign in to comment.