This repository contains a Reinforcement Learning (RL) project in which a bee collects pollen from flowers and returns it to a hive. The agent uses Q-learning to discover efficient foraging strategies under various vision constraints.

- Grid Environment: A 6×6 board with a hive and multiple flowers.
- Health Mechanic: Bee loses health with each move; dying ends the episode.
- Pollen Delivery: Collect pollen from flowers and earn a large reward upon hive return.
- Vision Modes:
- Full Vision: Bee knows its exact (x,y) location and carrying status.
- 3×3 Partial Vision: Bee only sees a local 3×3 window around its position.
- Single-Tile Vision: Bee sees only the tile it stands on.
bee_foraging_simulation.py
: Main Python script running Q-learning with adjustable vision modes.bee.png
,flower1.png
,flower2.png
,flower3.png
: Images for rendering the bee and flowers.- Dependencies:
pygame
for renderingmatplotlib
for real-time plottingpython 3.7+
- Install dependencies:
pip install pygame matplotlib
- Launch the simulation:
bash python bee_foraging_simulation.py
- Adjust parameters (episodes, learning rate, vision mode) in the script to experiment with different settings.

State can be:
(x, y, carrying_flag)
for full vision, or(local_3x3_view, carrying_flag)
for partial vision, or(single_tile_view, carrying_flag)
for single-tile vision.
Actions: Move up/down/left/right (or turn/move if orientation-based).
Rewards:
- Small penalty for each step.
- Positive for picking up pollen.
- Large bonus for delivering pollen to the hive.
- Penalty for running out of health.
Even with partial or single-tile vision, the bee can eventually learn routes back to the hive in a small environment, because Q-learning’s table effectively encodes the path from each state to the hive.
Feel free to fork or modify the project for your own experiments. Happy foraging!