Skip to content

A mini-game demo of BonsaiDb + Gooey

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

khonsulabs/minority-game

"Minority Game" Demo

CI Status HTML Coverage Report for main branch Documentation for main branch

Why build this?

This repository originally was created for a presentation at the December Rust Gamedev Meetup. @ecton recorded the entire process of creating and deploying the app starting from the Gooey + BonsaiDb example and a fresh Ubuntu 20.04 virtual server.

The deployed version of this repository is available at minority-game.gooey.rs.

The video of the creation through commit b9f80e4 is available to view on YouTube or on Odysee.

What is this?

This demo is an exploration of the Minority Game. Every player has a happiness score that can range from 0% happy to 100% happy. If less than 50% of players elect to go out instead of staying in, the players that go out will have a great time and their happiness will increase. If too many players go out, however, the players that go out will have a bad time and lose happiness. Players that elect to stay in will gravitate towards neutral happiness (50%).

The game also features a "tell" mechanic, which allows players to tell other players what they plan on doing. Players don't have to tell their intentions, and they don't have to tell the truth.

This game can be played in the web browser or natively, and features a minimal leaderboard webpage.

What is this a demo of?

This demo combines two large projects that we at Khonsu Labs are working on: BonsaiDb and Gooey.

How is BonsaiDb being used?

BonsaiDb is providing these features:

  • Storage of player data + Querying for leaderboard statistics
  • All network connectivity, including:
    • TCP connections over port 80/443:
      • Delegates connections to an TcpService, which this example uses Axum to process HTTP requests
      • Provides logic to allow upgrading an existing connection to a BonsaiDb WebSocket, allowing for browser apps to communicate with the database server.
      • Handles TLS-ALPN-01-based ACME certificate acquisition via LetsEncrypt over port 443.
    • QUIC connections (UDP-based) over port 5645:
      • Provides the same API as the WebSockets, but over a superior protocol to TCP + TLS.
  • The main server executable functionality via the built-in cli.
  • Role-based access control: This example doesn't have any roles or multi-user support (yet), but the permissions system is enforcing that clients that connect to the server cannot perform any database operations.

How is Gooey being used?

Gooey's goal is to create applications using as little platform-dependent code as possible. This example was able to only use one set of compile-time dependent code: when building for WASM, the client needs to connect to a different URL because the browser doesn't support non-HTTP QUIC connections.

At the time of building this example, Gooey is incredibly early in development, and the layout utilities included are severly lacking. This example is not meant to be much of a demo of Gooey, but more an ends-to-a-means of being a simple way to show using BonsaiDb both natively and in the browser using the same client library and code.

Open-source Licenses

This project, like all projects from Khonsu Labs, are open-source. This repository is available under the MIT License or the Apache License 2.0.

To learn more about contributing, please see CONTRIBUTING.md.

About

A mini-game demo of BonsaiDb + Gooey

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Packages