My latest project is not quite a game. (Not yet, at least.) But it is kind of fun to play around with. Smart Dots is a simple, physics-based simulation of a multi-agent system – each agent is autonomous, has a limited view of the system, and is decentralized. For Smart Dots, this means that each dot contains its own kinematics equations and behavioral algorithms, each dot only can “see” a limited distance away, and there is no higher level logic controlling what goes on. (The only thing the higher level UI and “world” classes do is set dot behaviors.)
When the smartdots.py script is run, you will see several dots bouncing around in a window. They each have their own velocity, assigned randomly at the start of the simulation. The user can select a dot to see its position (pixel location), velocity (pixels/sec), and acceleration (pixels/sec^2). There are several inputs the user may enter:
- Left click on a dot to select it (the selected dot will turn green.) Then, by pressing F2, the “Search and Follow” behavior is enabled. The dots will start to follow the selected dot, if they can “see” it (ie, if it is in what I call in the program the “comm range”). If the selected dot is traveling sufficiently slower than the others, then they kind of dance around it.
- Right click on any spot of the window to set the “action point” (designated by a yellow point). Nothing will happen unless F4 is pressed and the “Move to Action Point” behavior is enabled for the dots. The dots will then move to the action point.
- p will toggle pausing for the simulation
- c will toggle a display of the comm range for each dot (displayed as a red circle)
- s will “scatter” the dots, giving each one a new random velocity
- the mouse wheel can be used to apply positive or negative gravity
- Escape will cancel any gravity settings
I have place holders for adding an “Avoid Obstacles” behavior (avoid other dots), and also an “Orbit Action Point” behavior…to be completed in a future version.
Rather than a single screenshot, check out this youtube video I made of Smart Dots:
What is so cool about Smart Dots? Well, it’s not much right now. But I think it can be an interesting framework for testing out simple multi-agent algorithms…and just maybe it can be useful in a future game. We shall see….
Download: smartdots_v0.1.zip. Prerequisites are Python and Pygame. Main script to run is smartdots.py. Controls are listed in the status area above the dot box; also run with the -h option to see all other command line options.