ada-guess
is a simple game inspired from the British television quiz show Who Wants to Be a Millionaire?
It consists of two players -C
the challenger and G
the guesser. C
chooses an option out of four possible choices A
,B
,C
,D
and challenges G
to guess the secret choice. G
can make two choices. For example 'A, B' means that G
thinks option A
is most likely the correct answer and if not, then falls back to option B
. The three possible outcomes are tabularized below:
Challenger | Guesser | Result |
---|---|---|
A |
A, B |
G wins |
B |
A, B |
DRAW |
C |
B, D |
C wins |
The distribution of the rewards are based on the following rules:
- In case of a successful first attempt,
G
wins and claims the entireADA
locked to the contract script. - In case of a successful second attempt,
C
andG
can claim their own respective stake back. - Otherise,
C
wins and claims the entireADA
locked to the contract script.
As one can infer, both C
and G
have 25% probability of winning the game and 50% chance of claiming their original stake.
stateDiagram-v2
[*] --> hash(secret_choice)||nonce : challenger
hash(secret_choice)||nonce --> guess_secret_choice : guesser
hash(secret_choice)||nonce --> UTXO: claimChallengerStake
guess_secret_choice --> UTXO: claimGuesserStake
guess_secret_choice --> UTXO: claimFullReward
hash(secret_choice)||nonce --> UTXO: proveF
hash(secret_choice)||nonce --> UTXO: proveP
UTXO --> [*] : Script
- Once the challenge is initiated,
G
must respond within a certain deadline known as the guess deadline. IfG
does not respond within this time, thenC
can claim his/her own stake backclaimChallengerStake
. - Incase, both the choices of
G
are wrong,C
must provide a valid proof to the blockchainproveF
within a certain deadline known as the prove deadline to unlock the entire reward. - Incase, only the first choice of
G
is wrong, thenC
still must provide a valid proof to the blockchainproveP
within prove deadline to unlock his/her own stake back. - Incase,
C
does not respond afterG
makes the guess,G
can unlock the entire reward anytime after the prove deadline.
A brief description of the source code and how to test the same can be found here.
e-UTXO diagram can be found here.