# Flow Lobbies

## Create Lobby

User creates lobby by calling the contract from the game interface

<figure><img src="/files/ENddYAdm3izXRBqDEvLu" alt=""><figcaption><p>creation of a lobby</p></figcaption></figure>

### Unique Race Generator

Each lobby is unique. It uses a combination of multiple formulas to generate a random road that is in the set parameters. By doing so, 2 lobbies with exact same input for creation will be different.

<figure><img src="/files/6mxT5sHEMfHXV4ZhXwcn" alt=""><figcaption><p>Scheme displaying the variables in the formula</p></figcaption></figure>

## Join Lobby

Players can pay to enter the lobby using the smart contract by joining the lobby with the id from the game interface

<figure><img src="/files/jZ5AzrKgDRY30KkW5NP2" alt=""><figcaption></figcaption></figure>

## Waiting for Confirmation on-chain

The lobby is in `checking state`. It waits to get confirmed on-chain. Till then, for increased security, it cannot be joined,  because it may fail before it gets confirmed on-chain.&#x20;

<figure><img src="/files/GRev1oafNvOVc5vsfJ9G" alt=""><figcaption></figcaption></figure>

## Race Time

The game checks the on-chain contract's read-only function that gives a list of the users that paid the entry price. If the read-only of `get-score` returns any value it means the join got confirmed for that player on that lobby. After the check confirms, the player can race as many times as he wants before the time of the lobby ends.

<figure><img src="/files/ufYi8j6HitAhLgv034MH" alt="lobbies created &#x26; started with join &#x26; race options"><figcaption></figcaption></figure>

## DB - Server - Blockchain Combo

The results are published on-chain every 10 minutes \~ 1 stacks block.

<figure><img src="/files/ZlmOtGe63QDJNrJxESYG" alt=""><figcaption></figcaption></figure>

## Rewarding players

A pre-determined formula determines how much in rewards each player receives based on the scores and places they got of their best run in the lobby. Any type of formula can be used, paying only the first 5 or only the first to increase competitiveness, paying everybody in smaller amounts to incentivize participation. We picked one in the middle that rewards the first few places the most, while also sending a piece of the rewards to the other players.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.degenlab.io/gamefistacks/trustless-rewards-m1/flow-lobbies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
