Run this program to see a transcript of a simulated Monopoly Junior boardgame session! Hours of fun for computers of all ages!
- Six-sided die (simulated)
- Accurate board!
- My own made-up chance cards (stored as lambdas)
- Customizable players (with easy-to-edit source!)
- Less than 300 lines of Ruby in one file!
Why does this exist?
I was playing Monopoly Jr. with my daughter one day and caught myself thinking "I bet I could simulate this pretty easily". The "Junior" version has some rule changes from the regular Monopoly boardgame so that it requires less decisions from the players (you have to buy un-owned properties when you land on them).
I'm only on page 50 of "the pickaxe book" (Programming Ruby by Dave Thomas), so I'm not sure how idiomatic any of this is. But wow, did I ever pick the perfect programming exercise to experiment with Ruby OOP design and solidify what I've learned so far!
To turn this into an accurate simulation:
I forgot to double the cost when you land on a property where the owner owns both properties of that color (e.g. Mom owns both Boardwalk and Park Place, Dad lands on Park Place and should owe $10 rather than $5.) The property colors are already in this simulation, so it should be easy to check that the owner of the landed spot also owns the other property of that color.
It is possible to model the actual chance cards that come with the game.
The would require some simple decision-making on the part of the simulated players and you would also have to figure out what if move to "a" property of color X means "the property of your choice" or "the next property". Perhaps a visit to BoardgameGeek.com will help.