← CT.dev / projects

CO2402 Advanced Programming · UCLan

MONOPO-LISH

A four-player Monopoly simulation I wrote in C++ for a university assignment. My original source code, compiled to WebAssembly, runs in your browser. The board is driven by the program's own console output.

View the code C++17OOP & polymorphismSmart pointersWebAssembly
ROUND -- / 20
Loading the game…
Assignment.exe · stdout0 lines

      

The assignment

Four players (Hamster, Pumpkin, Dog and Jaguar) play 20 rounds on a Preston-themed board read from monopolish.txt. Everything is automatic. Each turn the program rolls a die, moves the player, and calls Land() on whichever square they reach.

It implements buying and rent, rent doubling on a full colour set, stations, bonus and penalty cards, jail, mortgaging and redeeming, bankruptcy, and a bank with limited funds.

Class design

CGame     owns the board and players
CPlayer   money, position, properties
CSquare   base class, virtual Land()
 ├─ CProperty    buy, rent, mortgage
 ├─ CStation     £200 to buy, £10 ticket
 ├─ CBonus       roll for a reward
 ├─ CPenalty     roll for a fine
 ├─ CJail · CGoToJail
 └─ CFreeParking

How this demo runs

The original Visual Studio source is compiled unchanged with clang to a 254 KB wasm32-wasi binary. A small compatibility header covers the MSVC-only calls and supplies Microsoft's rand(), so a seed gives the same game it gave on Windows.

Seed 47 reproduces the console output from my submitted report line for line. Try any other seed for a new game.

Source code

The original files from my submission, exactly as handed in.