ethicalgardeners.agent.Agent¶
- class ethicalgardeners.agent.Agent(position, money=0.0, seeds: dict = None)[source]¶
Bases:
objectRepresents a gardener agent in the environment.
Agents can move around the grid, plant and harvest flowers, manage seeds, and accumulate money from harvesting flowers.
- flowers_harvested¶
Counter of flowers this agent has harvested by type. (Note that, because an agent can harvest flowers planted by another agent, this counter can be very different from the
flowers_plantedcounter.)- Type:
Methods
__init__(position[, money, seeds])Create a new agent.
add_money(amount)Add money to the agent's wealth.
add_seed(flower_type, num_seeds)Add seeds of a specific flower type to the agent's inventory.
can_plant(flower_type)Check if the agent has seeds available to plant a specific flower type.
move(new_position)Move the agent in the specified direction.
use_seed(flower_type)Use a seed to plant a flower of the specified type.
- add_money(amount)[source]¶
Add money to the agent’s wealth.
- Parameters:
amount (float) – The amount of money to add.
- add_seed(flower_type: int, num_seeds)[source]¶
Add seeds of a specific flower type to the agent’s inventory.
- can_plant(flower_type: int)[source]¶
Check if the agent has seeds available to plant a specific flower type.
- move(new_position)[source]¶
Move the agent in the specified direction.
Updates the agent’s position based on the direction action.
- Parameters:
new_position (tuple) – The (x, y) coordinates of the agent in the grid.