https://github.com/guptaanmol184/baboon-crossing-problem
Graphical demonstration of the baboon crossing problem
https://github.com/guptaanmol184/baboon-crossing-problem
python2 synchronization threading vpython
Last synced: 7 months ago
JSON representation
Graphical demonstration of the baboon crossing problem
- Host: GitHub
- URL: https://github.com/guptaanmol184/baboon-crossing-problem
- Owner: guptaanmol184
- Created: 2017-11-10T02:46:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-24T09:57:09.000Z (almost 8 years ago)
- Last Synced: 2025-03-24T07:56:49.980Z (8 months ago)
- Topics: python2, synchronization, threading, vpython
- Language: Python
- Homepage:
- Size: 13.4 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Baboon Crossing Problem
## Problem description:
Baboons can cross the canyon by swinging hand-over-hand on the rope, but if two baboons going in opposite directions meet in the middle, they will fight and drop to their deaths. Furthermore, the rope is only strong enough to hold 5 baboons. If there are more baboons on the rope at the same time, it will break.
The following properties are ensured:
1. Once a baboon has begun to cross, it is guaranteed to get to the other side without running into a baboon going the other way.
2. There are never more than 5 baboons on the rope.
3. A continuing stream of baboons crossing in one direction should not bar baboons going the other way indefinitely (no starvation).
## Running the gui for ubuntu:
1. Install vpython
```python2
sudo apt-get install python-visual
sudo apt-get install libgtkglextmm-x11-1.2-dev
```
2. Install pygame
```python2
sudo apt-get install python-pygame
```
3. Run gui.py file
```python2
python2 gui.py
```
## User options:
### These options can be set by the user by editing the source gui.py file.
```python2
# default values
max_on_rope = 5
left_baboon_count = 15
right_baboon_count = 15
# uncomment to select music
#mixer.music.load('songs/five-little-mokeys.mp3')
mixer.music.load('songs/mowgli-sahara-theme.mp3')
#mixer.music.load('songs/monkey.mp3')
```
## Note:
Currently only _python2_ is supported. Support for _python3_ may be added in future.