> For the complete documentation index, see [llms.txt](https://trueodds.gitbook.io/trueodds/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trueodds.gitbook.io/trueodds/dice-game/verifying-your-bet/our-algorithm.md).

# Our Algorithm

Or how to know your seed is actually your seed.

Once you have confirmed the hash shown before payment equal to the seed shown after payment, you can proceed to run that seed through the following function:

```
func genRandomNumTo6(seed : Blob) : Nat {
    let randomNat1 : Nat = Random.rangeFrom(3, seed);
    return randomNat1;
};
```

Which will return a natural number corresponding to the winning side chosen by the True Odds canister.

### How does it work?

If you obtain a fresh, new `32 byte` seed through the random beacon and run it through that generator there is a chance you get either 0 or 7, as the rangeFrom function distributes the outcome in the range $$\[0 \quad ... \quad2^p - 1]$$, with $$p$$ being the other argument passed to the function, in our case 3.\
\
Our canister thus, filters through each fresh seed and deems it apt or not to be used, in the following manner:&#x20;

```
var seed : Blob = here an empty blob to assign the seed to, so its in the whole scope
var num1 = 0;
while (num1 == 0) {
    let entropy : Blob = await Random.blob(); //fresh entropy
    var numTo6 = genRandomNumTo6(entropy);
    if(numTo6 == 7) {
        numTo4 := 0;
    }; //excludes 7 from the possibilities, generates a new seed
    num1 := numTo6; 
    seed := entropy;
};
```

This way, we only work with seeds contained in the set of seeds $$o$$ that return outcomes in the mathematical range $$\[1,6]$$.\
\
We will deploy soon an open-sourced canister with two implementations of both functions for ease of access, in the meantime feel free to copy that code and deploy it yourself locally.
