Skip to content
Settlers Journal
Go back

Building a Python CLI Tool and Automated Game Scenario Runner

Edit page

TLDR

Automating the process of testing the Catan system end-to-end. This is done by stepping through game commands / moves via Python scripts and text files containing the list of game moves to apply.

This testing is still manual, since I personally validate that the frontend is displaying what I expect after each call. It greatly increases my speed though, since I can quickly design new test scenarios, repeat older ones, and skip commands I do not want to execute.

Ideally, working with these CLI commands will subconsciously let me develop a formal notation for game moves. This will be important once I need to implement game history and persist it to the Postgres DB.

The automated commands are achieved via two python scripts which

  1. Implement a CLI tool for the backend REST service (settlers-cli.py).
  2. Read and run a list of CLI commands from a file <game-scenario>.txt via (testing.py).

The below screenshots show how we could start up the game service, then run through the process of a player starting a game and having others join.

join-game.txt contains the following CLI commands to do this:

python3 settlers-cli.py start 1 Alex
python3 settlers-cli.py join 2 Ryan
python3 settlers-cli.py join 3 Nick
python3 settlers-cli.py join 4 Stevie

alt text alt text alt text

Main work

Challenges

Learnings


Edit page
Share this post on:

Previous Post
Adding Player Join Order, Colors, and a Game Event Log
Next Post
Connecting Angular Frontend to Spring Backend with a Randomized Board