![[Dept of Engineering]](http://www.eng.cam.ac.uk/images/house_style/engban-s.gif)
srandom(time(0)) and graphics,
create some dodgems, then for 100 time intervals move each dodgem in
turn, checking each time to see if the dodgem has crashed into another.
If the dodgem crashes into another team's dodgem, the latter is
eliminated and the first dodgem gains a point. If a dodgem crashes into
a fellow team member the former loses a point and is shoved 90 degrees clockwise.
At the end the scores of the remaining dodgems are printed out and
wait_for_key() called.
If you store the dodgems in a list<dodgem> then its easy to
add, remove and loop through them.
And that's it! you can develop this simulation if you want, changing the direction and speed to make the dodgems more predatory, and making the dodgems bounce off walls.
A solution is in the anwers section at the end of the document (page
).