evaneill / PandemiCpp

C++ implementation of pandemic board game for testing MCTS agents
2 stars 0 forks source link

PandemiCpp

C++ implementation of pandemic board game for testing MCTS agents.

Disclaimer: This was created as a means to explore and test MCTS (and tree based stochastic planning) rather than develop or try state-of-the-art methods. So it's lacking some functionality that would help towards these ends.

Status

As of Jul 6, 2020 this has been through a decent amount of testing. I'm inclined to call this v0.

Also this is my first time with C++, so you'll have to overlook all of the breaches of best-practice. Further, I'm certain that there are probably inefficiencies or impracticalities that would be obvious to a real practitioner, but I don't know about.

Requirements

I believe that you only need a C++ compiler that's capable of compiling the C++17 standard. This standard is required because I've used some inline statements to define global variables. The commands in makefile require g++, specifically, and have been developed on an OSX system. It takes my compiler ~30-60 ish sec to build a full experiment.

Hello World Playtest

Right now Playtest.cpp holds the logic to call the random agent in a playthrough of the game. It draws actions uniformly over types of legal actions, and then uniformly over legal actions of the chosen type. You can compile a binary and run it with make playtest, which makes a ./playtest.out binary you can call over and over.

Run an experiment

I've made Experiments to encapsulate all of the specification of an agent, initial board state, etc. required to run and log an experiment. By default experiments will be written to results/ in the form of a .header and .csv file, which describe meta information about the experiment and experimental results describing game-level information, respectively.

An experiment can be built with make experiment EXPERIMENT="experiments/ByGroupRandomAgentGameExperiment", for example. It can be ran by running the binary created in experiments/, for example with experiments/ByGroupRandomAgentGameExperiment.out. That particular experiment will run many many games using the same random agent used by Playtest.cpp.

Modifications to the game rules

Roles

Movement and Actions

Pandemic Board Game

The rules can be found here, which is nice because you can also see a game map.

Further optimization and improvements (probably never will be done)

Known bugs

When a disease is already cured, infect cards should not result in the placement of that disease at the location of the medic. Right now the logic will still place disease there. I don't suspect this has a significant impact on games, since this circumstance is relatively rare. In addition, once a disease is cured the medic's position will properly be cleared of disease (as well as after each movement action), so this inappropriate placement could only ever be placing a single disease cube on a 0-cube city.