ethicalgardeners.gridworld.Flower¶
- class ethicalgardeners.gridworld.Flower(position, flower_type, flowers_data: dict, growth_stage=0)[source]¶
Bases:
objectRepresents a flower that can be planted and harvested in the environment.
Flowers grow through several stages and reduce pollution in their cell. Different flower types have different growth patterns, prices, and pollution reduction capabilities.
- __init__(position, flower_type, flowers_data: dict, growth_stage=0)[source]¶
Create a new flower.
- Parameters:
position (tuple) – The (x, y) coordinates where the flower is planted.
flower_type (int) – The type of flower to create.
flowers_data (dict) – Configuration data for flower types; a dictionary mapping flower type IDs to a dictionary of properties, containing
keysandpollution_reduction.growth_stage (int, optional) – The number of growth stages for this flower. Defaults to 0 (the initial stage).
Methods
__init__(position, flower_type, flowers_data)Create a new flower.
Return the current pollution reduction provided by the flower.
grow()Advance the flower to the next growth stage if not fully grown.
is_grown()Check if the flower has reached its final growth stage.
- get_pollution_reduction()[source]¶
Return the current pollution reduction provided by the flower.
The pollution reduction depends on the current growth stage and the flower type.
- Returns:
The amount of pollution reduced by this flower at its current stage.
- Return type: