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>" </your></your></your>
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!

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.

Choosing Python or C depends on project requirements: 1) If you need rapid development, data processing and prototype design, choose Python; 2) If you need high performance, low latency and close hardware control, choose C.

By investing 2 hours of Python learning every day, you can effectively improve your programming skills. 1. Learn new knowledge: read documents or watch tutorials. 2. Practice: Write code and complete exercises. 3. Review: Consolidate the content you have learned. 4. Project practice: Apply what you have learned in actual projects. Such a structured learning plan can help you systematically master Python and achieve career goals.

Methods to learn Python efficiently within two hours include: 1. Review the basic knowledge and ensure that you are familiar with Python installation and basic syntax; 2. Understand the core concepts of Python, such as variables, lists, functions, etc.; 3. Master basic and advanced usage by using examples; 4. Learn common errors and debugging techniques; 5. Apply performance optimization and best practices, such as using list comprehensions and following the PEP8 style guide.

Python is suitable for beginners and data science, and C is suitable for system programming and game development. 1. Python is simple and easy to use, suitable for data science and web development. 2.C provides high performance and control, suitable for game development and system programming. The choice should be based on project needs and personal interests.

Python is more suitable for data science and rapid development, while C is more suitable for high performance and system programming. 1. Python syntax is concise and easy to learn, suitable for data processing and scientific computing. 2.C has complex syntax but excellent performance and is often used in game development and system programming.

It is feasible to invest two hours a day to learn Python. 1. Learn new knowledge: Learn new concepts in one hour, such as lists and dictionaries. 2. Practice and exercises: Use one hour to perform programming exercises, such as writing small programs. Through reasonable planning and perseverance, you can master the core concepts of Python in a short time.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools