Turn Based Multiplayer Beer Game
Since I need to organize a systems thinking workshop in the near future, I need a beer game to start it off.
The beer game itself consists of four characters: Retailer, Wholesaler, Distributor and Factory. Through the time-delay nature of the logistics to understand the system perspective, and can have a better understanding of the system boundaries.
As this is a few hours workshop, I want this beer game to fulfill the following features.
It's a multiplayer game.
The beer game itself will have many participants playing various roles in the supply chain, but I'd like to be able to have multiple supply chains competing at the same time to see who scores higher. Thus, we can learn about their system strategies at the same time.
The game host should be able to see everyone's status.
Since there are multiple teams competing at the same time, as a host I need to be able to see how each team is progressing and scoring at the moment.
The game flow has to be simple and easy to control the pace.
As I said at the beginning, this is a short workshop, so I need to get everyone up to speed quickly and I need to be able to control the details of each round.
Moreover, a timer appears in the player's UI at the beginning of each round, advancing the game pace by counting down.
Be able to customize the characters.
A classic beer game consists of four characters, but the more characters there are, the longer the game will be. So I'd like to adjust the game pace so that it's better to have three characters.
After searching around, I found that neither open source projects nor projects that are already online can satisfy these requirement perfectly. So, I'd better make one myself.
Beer Game Project
https://github.com/wirelessr/beer_game
Host UI
Player UI
The entire project is business driven developed and tested with over 90% coverage, so please feel free to use it.
Preparedness
Create a file for secrets in the project folder. You should see me copy it in the Dockerfile.
.streamlit/secrets.toml
[mongo] uri = "<your mongo connection>" [admin] key = "<your admin key>" [player] key = "<your player key>"
Since this project is using MongoDB, you have to fill in the link with your account password. In addition, admin.key and player.key correspond to the key fields on the UI.
After all, I'm uploading the app to the public cloud, so I still need a basic authentication mechanism. If you're running locally only and find authentication troublesome, you can remove the corresponding source code.
Installation and Use
This project has a Dockerfile attached, so it can be run directly with docker.
docker build -t beer_game . docker run --rm --name beer -p 8501:8501 beer_game
For development, in addition to requiremnts.txt, requirements-test.txt, which runs the unit tests, should also be installed. Then you can run all the unit tests through the Makefile.
pip install -r requiremnts.txt pip install -r requirements-test.txt make test
Game Flow
The whole game is divided into a host mode and a participant mode, which correspond to the options in the top corner of the UI.
The host first assigns a game_id to create the game, and all participants have to fill in the player_game with this id.
All players on the same supply chain need to use the same player_id, so this id is also known as the supply chain ID, and participants with the same player_id are separated into roles by player_role.
You can see the status on the host's screen when a participant joins.
Let's look at what a full iteration would look like from the host's point of view.
All the components that need to be manipulated are in this picture, and each turn starts by pressing the Refresh button and ends by pressing Next Week.
As for how many orders to send to all the supply chains in this round, they will be triggered by Place Order.
It's worth mentioning that the Place Order itself is idempotent, so it's fine to change the number and press it again, the last number will be used. The Place Order of each participant's interface will be idempotent as well.
Once the host has placed the order, the shop player can take the order.
Similarly, each role in the supply chain starts with Refresh and ends with Place Order, with the shop player taking the action followed by the retailer player, and so on.
Finally, back to the host, who can press Refresh again to see all the statuses for the round, and Next Week to end the round.
Game Detail
There are a couple of things actually done during Refresh.
- it refills inventory from downstream based on orders placed four weeks ago.
- it receives orders from upstream.
- decides how much to sell based on what inventory it can sell.
Since Place Order is idempotent, Refresh itself is idempotent too.
Future work
It basically meets all of my needs now, but there are some enhancements that could be made.
For example, although the host can see the status of all the participants, it would be helpful to have a graph to show the change of inventory and cost information over time, which would be useful for reviewing the game after it is over.
There's also a more basic problem: the current UI has no test coverage at all, mainly because the current game flow is quite simple. Just a few clicks on the UI will cover all the UI flow, so I don't rely so much on auto-testing. However, if there is a UI modification, it will still be a bit tedious, so it would be better to have a UI unit test.
Overall, these requirements are optimizations, but their lack does not affect the functionality.
If you have additional ideas, you can also just submit a pull request, contributions are welcome.
The above is the detailed content of Turn Based Multiplayer Beer Game. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

In Python, how to dynamically create an object through a string and call its methods? This is a common programming requirement, especially if it needs to be configured or run...

Using python in Linux terminal...

Fastapi ...
