Skip to content
Snippets Groups Projects
Commit 10c3ec7e authored by Tessaris Sergio's avatar Tessaris Sergio
Browse files

doc: more class documentation

parent 75a78ab0
No related branches found
No related tags found
No related merge requests found
......@@ -410,12 +410,15 @@ class GridWorld(object):
class Food(WorldObject):
"""Food in the EaterWorld, it can be consumed by the Eater agent."""
def charSymbol(self):
return '🍌'
class Eater(Agent):
"""An agent that moves in the EaterWorld. It can move in 4 directions (Eater.Actions) and consumes Food objects that are in the cells where it moves. It sees its position and smells whether there's still food in the world (Eater.Percept). Its goal is to consume all the food in the environment."""
class Actions(Actions):
"""Eater actions for each direction in which the agent can move (N, S, E, W)"""
N = (0, 1)
S = (0, -1)
E = (1, 0)
......@@ -484,6 +487,8 @@ class Eater(Agent):
class EaterWorld(GridWorld):
"""A GridWorld which contains Food and a Eater agent that can move within the world and eat the food when it moves in a cell that contains some food.
"""
@classmethod
def random(cls, map_desc: str=None, size: Coordinate=None, blocks: Iterable[Coordinate]=[], food_amount: float=.1, **kwargs) -> 'EaterWorld':
"""Create a new world from the map description and randomly place food until the given percentage of the free space is filled. If the food amount is greater or equal than 1 then it's interpreted as the number of food objects to include.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment