Niels Zeilemaker is a Data Hacker at GoDataDriven, where he works for a wide range of companies where he spends his time doing feature engineering and building models. Before joining GDD, he finished his PhD thesis at the Technical University of Delft. In this talk he will explain how to 'solve' Monopoly with a genetic algorithm. He will first go into the official rules of Monopoly, as nobody seems to actually play according to the rules. Then into how to use a genetic algorithm to optimize a general buying rule, and finally how to optimize the number of houses to buy.
2. About me
• PhD in Parallel Computing @ TUDelft
• Data hacker at GDD
• Data scientist and/or data engineer
• Basically, drink coffee a lot while waiting for
3. Monopoly
• Boardgame created in 1935
• For 2-6 players
• Buy houses/hotels –>
• Last man standing wins
• Pronounced in dutch as moonoopooly
4. Terminology
• Players traverse the board by rolling two dice
• When landing on an unowned property, a
player can decide to buy it
• If a player owns all properties of a single color,
he can buy houses
• Visiting a property owned by another player
you will need to pay rent
5. Rules
• A player passing Go receives $200
• All fines are paid into the free parking space
• When a player does not buy an unowned property an auction is
held
• Rolling doubles three times in a row results in goto jail
• If a player lands on Go he receives $400
• Rolling doubles will release a player from jail
• Paying $50 will release a player from jail
6. Rules
• A player passing Go receives $200
• All fines are paid into the free parking space
• When a player does not buy an unowned property an auction is
held
• Rolling doubles three times in a row results in goto jail
• If a player lands on Go he receives $400
• Rolling doubles will release a player from jail
• Paying $50 will release a player from jail
7. How much free time do you have?
• Interesting game,
• still doesn’t explain why you would attempt to “solve it”
• GDD Friday + = “Monopoly Simulations”
• He implemented a small python script which would roll dice + go
to jail
See: http://koaning.io/monopoly-simulations.html
10. How much free time do you have?
• Implemented
• Board object
• Player object
• Deed object
• BankruptException ;)
• Unit-tested, coverage ~80%
11. Player object
class Player(object):
def buy_position(self, deed, amount):
# after landing on a deed
def bid_position(self, deed, amount, current_bid):
# while in an auction
def anything_else(self):
# at the end of the turn
def raise_amount(self, amount):
# when we need to pay for something
15. Next up, genetic algorithms
• Manually selecting which deeds to buy/how many houses to build
isn’t a lot of fun
• Enter, the GAPlayer
16. Genetic algoritms?
• Search heuristic which mimics natural selection
• Convert search space into chromosome
• Eg 1,1,0,3,3, etc.
• Evaluate performance of chromosome using fitness function
• 1,1,0,3,3,… = 42
• 1,2,0,3,3,… = 42
I'm no expert on genetic algoritms, feel free to correct me
17. Genetic algoritms?
• After each round (or population)
• Select top X chromosomes
• Append some mutations
• Generate offspring by combining those
• Stop after X generations
21. Fitness function, vs BuyAll
• Play 1000 matches against BuyAll
• Score = #times won
• Evaluate 10 generations
• Population size = 56
• Select 20% best perfoming
• Mutate 1% of the solutions
• Single generation takes 1 minute to evaluate
23. But wait
• So, GaPlayer '[0, 6, 0, 5, 0, 1, 2, 0, 3, 2, 0, 5, 1, 5, 4, 1, 1, 0, 0, 1, 0, 0, 0,
0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 4, 0, 4]‘ is a better strategy than
buying everything….
• But is it the best monopoly strategy?
BuyAll GaPlayer….
24. TrueSkill
• A ranking system developed for Xbox player matching
• In my understanding
• Each player has a skill belief, eg a probability distribution
• When you win/lose from another we update the probabilities accordingly
• Let’s hope Vincent is in the room
26. Combining GA + Trueskill
• Have a global leaderbord
• Each new GA chromosome plays against 100 randomly selected
others
• Each game now is best of 10
• Leaderbord is sorted by value of curve descending
29. So
• We get some probable “best” solutions
• But is monopoly rock paper scissors?
• We should be able to notice this by it not converging
• And, TrueSkill has some ”magic” numbers
• Blame vincent
30. Future work/known issues
• We implemented a single behavior to
• Bid in an auction
• Buy/Sell houses
• When to start buying/selling houses
• We did not implement
• Trying to buy streets from other players
• Opensource the stuffs