Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.65 KB

README.md

File metadata and controls

48 lines (35 loc) · 1.65 KB

Concurrent programming experiment with hyper simplistic "crowd" simulations

I want to learn more about concurrency and don't want to just play with trivial examples. So, this project is to serve as a test bed for my concurrency experimentation.

This project allows dozens of Bots to move around the screen and collide with each other. There are several kinds of Bots, each with its own simple pre-programmed logic that defines how it moves about the screen.

The thought is to see how hard/easy it is to implement these different bots with different approaches to concurrency. Some possibilities:

  • step based simulation
  • threads
  • generators
  • asyncio
  • Twisted
    • async
    • threads

In addition to running the simulation (letting the Bots run around), the app also provides keyboard controls to interact with the simulation (pause time, advance frame by frame, add and remove bots, move bots, etc.)

Project Setup

# Create venv
py -3 -m venv venv
source venv/Scripts/activate
# Install dependencies
pip install -r requirements.txt
cd src/
python -m crowd.crowd_sandbox

PyCharm

  • Set venv/ as project interpreter in PyCharm
  • Mark src/ directory as "sources root"

Repo layout

  • src/
    • minimal/: minimal example apps comparing the use of synchronous code, threading, multiprocessing and asyncio
    • common/: shared utilities
    • crowd/: original implementation of crowd_simulation
    • crowd_thread/: thread-based implementation of crowd_simulation
    • crowd_multiproc/: multiprocessing-based implementation of crowd_simulation
    • crowd_async/: asyncio-based implementation of crowd_simulation