Monopyly

A Python framework to allow AI algorithms to compete at playing Monopoly

This project is maintained by richard-shepherd

Creating Your Monopyly AI

Create a Python package for your AI

You should create a Python package for your AI and put it in the AIs folder under the root folder of the project. Your AI class should be exposed by the __init__.py file.

If you are familiar with Python packages you can skip the rest of this section.

A Python package is roughly the equivalent to a library in other languages. In practice, it is just a folder containing some Python files and an __init__.py file. It is the existence of the __init__.py file that makes it a package.

You should create a file containing your AI class in your package. You can also create any other modules and classes in your package that you need to support your AI. Note that if you reference other modules in your package, you must use intra-package references. For example:

from .my_monopyly_utilities import HouseBuilder

The __init__.py file should 'expose' your AI class. This allows the Monopyly framework to 'discover' your AI. For example:

from .rockefeller import RockefellerAI

See also the sample AIs provided.

Creating your AI class

You can import the Monopyly API into your code by importing:

from monopyly import *

Your AI class should have PlayerAIBase as a base class, ie it should derive from it or be derived from a class that ultimately derives from it.

You must implement the get_name() method from PlayerAIBase, but all other overrides are optional. You can override the methods in PlayerAIBase to buy, sell and mortgage properties, build and sell houses, take part in auctions and make deals with other players.

If you do not override PlayerAIBase methods, the default behaviour is usually 'boring'. That is, your player will just move around the board without buying properties or taking part in the game, except to pay fines and collect money when passing Go.

See the comments in PlayerAIBase (monopyly/game/player_ai_base.py) and the API reference for more details.

Time and turn limits for games

Games are limited to a maximum of 500 rounds.

Each AI is given a maximum of twenty seconds of processing time in each game. If an AI runs out of time, it is removed from the game and is considered bankrupt.