Provably Fair
A way to ensure all battles are fair and unriggable.
Last updated
A way to ensure all battles are fair and unriggable.
Last updated
We define a function getHash
that computes the SHA256 hash of an input string and returns the bytes as a hex string:
When a game is created, the server_seed
and battle_id
are generated. battle_id
is publicly shared, and the hash of the server_seed
is displayed on the battle. The server_seed
is revealed only after a battle has finished. You may verify that the server_seed
and hash match
player_number
is assigned 1 for the creator, and 2 for the joiner.
Moves can be randomly chosen in two scenarios:
For a user who runs out of time in a round
By the bot (if called by the battle creator)
The move is chosen with the following procedure:
Generate the input string.
Compute the SHA256 hash of the input.
Convert the first 4 bytes of the hex string to an integer and apply modulo 3.
Choose fire for result 0, grass for result 1, and water for result 2.
After every round that isn't a draw, the winning player assigned a chance to either miss, hit a normal attack, or land a super active attack. The attack type is chosen with the following procedure:
Generate the input string.
Compute the SHA256 hash of the input.
Convert the first 4 bytes of the hex string to an integer and apply modulo 100.
Ticket ranges for the result (inclusive) and respective attack types:
0 - 19: Miss
20 - 51: Super Active
52 - 99: Regular
This is a bit more nuanced due to the slightly more complicated rules of battling and attack types. The damage ticket is generated with the following procedure:
Generate the input string.
Compute the SHA256 hash of the input.
Convert the first 4 bytes of the hex string to an integer.
The ticket must now be confined within a range between the minimum and maximum possible attack damage values for the move type.
They do 0 damage regardless.
Take the ticket modulo 21 and add 25 to confine the normal attack damage possibilities between 25 and 45 inclusive.
Take the ticket modulo 15 and add 46 to confine the super active attack damage possibilities between 46 and 60 inclusive.