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,
Gwins and claims the entireADAlocked to the contract script. - In case of a successful second attempt,
CandGcan claim their own respective stake back. - Otherise,
Cwins and claims the entireADAlocked 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,
Gmust respond within a certain deadline known as the guess deadline. IfGdoes not respond within this time, thenCcan claim his/her own stake backclaimChallengerStake. - Incase, both the choices of
Gare wrong,Cmust provide a valid proof to the blockchainproveFwithin a certain deadline known as the prove deadline to unlock the entire reward. - Incase, only the first choice of
Gis wrong, thenCstill must provide a valid proof to the blockchainprovePwithin prove deadline to unlock his/her own stake back. - Incase,
Cdoes not respond afterGmakes the guess,Gcan 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.