mayankkejriwal / GNOME-p3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MONOPOLY SIMULATOR

Full code for the Monopoly simulator is in GNOME-p3/monopoly-simulator/ and is written using OOP methodology.

The following steps have to be followed before running the simulator:

  • Install python3.
  • Clone the GNOME-p3 repository - $ git clone git@github.com:mayankkejriwal/GNOME-p3.git
  • All the python packages required to run a game instance can be installed using $ pip install -r requirements.txt (--user may be required for some systems).

Repository branches:

"master": The "master" branch of this repository works ONLY if Pycharm is installed. Pycharm is highly recommended to run the monopoly simulator and the instructions given below are to be followed only if running the simulator using Pycharm IDE.

"serial_com_over_socket": This branch can be used while developing a player agent not implemented in python to be plugged into the simulator. Information transfer happens via a server-client architecture over a socket. More information regarding this branch can be found in the README.md of that branch. To switch branch to "serial_com_over_socket" - $ git checkout serial_com_over_socket

"modified_imports": If Pycharm is NOT installed and the simulator can be run only on the terminal, then switch branch from "master" to "modified_imports" and follow the instructions given in that branch. To switch branch to "modified_imports" - $ git checkout modified_imports

To run an instance of the game:

Firstly, open GNOME-p3 repo as a project in Pycharm.

Following changes have to be made to file GNOME-p3/monopoly_simulator/gameplay.py before running a game instance:

  • Within the play_game() function, log folder path and log file path have to be specified for logging of game details in lines 370 and 375 respectively.
  • In lines 385 and 440, modify the default path to the game schema json file with the path where it is saved on your system (give complete path).
  • Uncomment the last line play_game() (line 476).
  • The game can then be run by running GNOME-p3/monopoly_simulator/gameplay.py file on the Pycharm IDE.
  • When Pycharm is installed, the game can also be run on the command line using the master branch. Open the command line at the GNOME-p3 project level and run the following command - $ python3 monopoly_simulator/gameplay.py

Other useful tips/features:

  • Logging of the game can be onto console and and into log file. This can be enabled/disabled in GNOME-p3/monopoly_simulator/logging_info.py file in line 22.
  • The seed defined in the simulate_game_instance() function argument ensures game replication (default seed is already set, pass in new seed in line 407 for a different game instance to be played out).
  • The simulator package comes with a few pre-implemented agents (agent implementation in files with names background_agent_v[x].py and baseline_agent.py). You are free to plug in any of the implemented agents into each player in lines 380-383 in GNOME-p3/monopoly-simulator/gameplay.py (default agents are set). The latest updated background agent is GNOME-p3/monopoly-simulator/background_agent_V3_1.py and the baseline agent is GNOME-p3/monopoly-simulator/baseline_agent.py.
  • (Optional) You can implement your own custom agent and replace any of the existing player agents with the new agent. In order to do so, all functions in the Agent class as specified in GNOME-p3/monopoly_simulator/agent.py has to be implemented and imported into GNOME-p3/monopoly_simulator/gameplay.py. (See existing agent implementations for reference.)
  • (Optional) The gameplay can also be viewed in 2D GUI by running GNOME-p3/monopoly_simulator/gameplay_GUI.py following the same instructions as above. The packages for the GUI can be installed using $ pip install -r requirements_GUI.txt.

About


Languages

Language:Python 100.0%