Decentralized Sums and Cows(D-SnC) is a modified version of classical code-breaking mind game Bulls and Cows incentivized by blockchain.
Tow characters each game: 1 player and 1 server
- The server chooses
d
ofn
non-repeating letters as setS
. - The server assigns
d
consecutive numbers starting from 0 to each element inC
. - The player chooses
d
ofn
non-repeating letters as setC
. - The player assigns
d
consecutive numbers starting from 0 to each element inC
. - We call
C
and its assigned numbers as a guess. The player sends its guess to the server. IfC
is exactly the same asS
and the assigned numbers are also the same, the game ends and the player wins. Otherwise, go to Step 6. - The server calculates the intersect set
R
ofS
andC
. Each element inR
inherits the corresponding assigned number toS
. - The server calculates the sum
sum(R)
of the assigned numbers toR
. - The server sends
|R|
andsum(R)
, called the result to the guess, to the player. Go to Step 3. Otherwise, the game ends and the player loses.
- The player is charged the starting fee to start a new game with the server.
- Step 5 charges the player the requesting fee.
- If the player loses, nothing happens.
- If the player wins, the player is rewarded the prize.
- Deposit: Exchange built-in token to game token at a certain rate.
- Withdraw: Exchange game token to built-in token at a certain rate. It is allowed if and only if for all games of the account, there is no one's state is end.
- Initial a game: One account consumes a certain amount of game token to start a game G along with a unique game id. The state of one game can be on or end. One account can initial multiple games at the same time.
- Handle game end claims: Verify claims. If passed, change the state of the game from on to end and update the client's account balance.
- Handle server misbehavior claims: Verify claims. If passed, the client wins the game. Otherwise, the game comes to the end immediately.
- Handle server failure claims: Store claims from clients and create time windows respectively waiting for the server to respond. Verify a respond and corresponding claim. If no response from the server within the time window or the verification fails, the client wins the game.
- Guess: Send a guess request to the server. Refer to Step 5.
- Verify: Verify responses from the server. If failed, claim server misbehavior.
- Claim the end of a game: Submit all the guesses and results within one game to Layer 1, so that to bring a game to the end.
- Claim server failure: If the server doesn't respond for a certain time, push a claim to Layer 1.
- Claim server misbehavior
- Respond to clients' requests: Upon receiving a guess request from a client, respond to the client with the result. Refer to Step 8. The server will check if the client's account balance is sufficient.
- Respond to server failure claims on Layer 1: Push the corresponding result to Layer 1.