Skip to content

Add traffic_flow example#343

Open
Nandha-kumar-S wants to merge 2 commits intomesa:mainfrom
Nandha-kumar-S:add-traffic-flow-example
Open

Add traffic_flow example#343
Nandha-kumar-S wants to merge 2 commits intomesa:mainfrom
Nandha-kumar-S:add-traffic-flow-example

Conversation

@Nandha-kumar-S
Copy link

@Nandha-kumar-S Nandha-kumar-S commented Feb 28, 2026

Summary

Adds a new traffic_flow example demonstrating a minimal traffic model in Mesa (tested on Mesa 3.3.1). Includes a CLI runner for ASCII output and a SolaraViz UI entrypoint.

Motive

Developer Experience (DevEx) Audit

Implementation

traffic_flow/agent.py: CarAgent that checks the cell to the right and moves if empty.
traffic_flow/model.py: TraficFlow model.
run.py: CLI runner printing the grid each tick.
app.py: SolaraViz page.
README.md: usage + parameters.

Usage Examples

cd examples/traffic_flow
python run.py

Screenshot

image

@Nandha-kumar-S
Copy link
Author

hi @EwoutH @jackiekazil , Can u look into this new model please, any feedbacks will be helpful. Also i built the base logic to be highly scalable, planning to expand it with:
i.Traffic Lights: Agents that flip states (red/green) and block cells.
ii.Variable Speeds: Implementing a Nagel-Schreckenberg algorithm where cars calculate their speed based on empty space ahead.
iii.Behavioral Logic: Aggressive vs. polite drivers for lane-changing.

@jackiekazil
Copy link
Member

I will take a look in the next 48 hrs or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants