An ant walking simulation using concepts of randomness at discipline Probability & Statistics
The python version was wrote using pygame for handling the window events, graphics and logic. The coding-style was used Programming Object-Oriented and as more modular as possible. The script whose has the main-loop
is: simulation.py
. The other scripts was spited into:
automaton.py
- Our specific entities, as Automaton (base),
Ant
andTrack
- Our specific entities, as Automaton (base),
base.py
- Abstract class called
Entity
designed to inherit from automaton specific classes
- Abstract class called
colors.py
- Some colors constants, like WHITE and BLACK
graphics.py
- 8bit-like graphics for
Ant
andTrack
(the footprint)
- 8bit-like graphics for
grid.py
- about block size and the amount of blocks on screen (the size of matrix)
motion.py
- directions definitions, like
UP
,DOWN
,RIGHT
andLEFT
. - All directions definitions are in function of BLOCKSIZE variable in grid.py
- directions definitions, like
main.py
- a script helper, only calling the simulation.py
AntSimulation.run()
- a script helper, only calling the simulation.py
To execute this you need Python3.x >= (3, 4) or Python2.x >= (2.6). Beyond that you need too the Pygame library. If you are using Ubuntu, you can type this:
sudo apt-get install python-pygame
orsudo pip install pygame
If pip was not installed try: sudo apt-get install python-pip
.
If you are using Windows, you need eternal suffering. Ow, I'm kidding. You can try installing using the pre-compiled lib binaries here
keeping attention with your python version.
After that, only execute at terminal in proper directory: python simulation.py