The player receives 2 random cards from the dealer
The player can request new cards until they stop or lose
If sum of card values is greater than 21 then they lose
If sum of card values is lower than 19 then they lose
If sum of card values is 19, 20 or 21 then they win
Here, Secret network will be the dealer and players can come from any Cosmos zone.
The game's flow:
A user with an account in any Cosmos zone opens the game's web-page.
The web-page initializes a wallet (it can be Keplr).
The user is presented with [new_game] button.
Upon clicking [new_game], new game is created and the user's address is saved into the contract's variable.
At the same time, 2 cards are dealt to the user (the player).
See https://scrt.network/blog/secret-vrf and https://github.com/scrtlabs/random-ibc-exampleThis step is the essence of our test. It must be impossible to predict the cards beforehand for anybody. It also must be impossible for anyone to reveal remaining cards in the deck, i.e. the deck must be stored privately. The randomness used to generate the deck must not be faked e.g. it must not be hash of the account address or current block.
The player is presented with 2 buttons: [one_more] and [enough].
If [one_more] is pressed, another card from existing deck is dealt to the player in addition to already known cards. State of the deck must be updated. If sum of values of dealt cards is more than 21, the game ends. If it's less than 21, the buttons are displayed again.
If [enough] is pressed, the game ends.
To determine if it's a win or loss, we sum-up all cards. It's not possible to modify game state after the game ends.
Possibility to discover the deck after the game is "nice to have" but not required, at this moment.
The user is presented with [new_game] button again.
Let's create a tiny game for testing Secret network capability to provide us with private randomness.
The game's rules should be the simplest version of https://en.wikipedia.org/wiki/Twenty-One_(banking_game):
Here, Secret network will be the dealer and players can come from any Cosmos zone.
The game's flow:
[new_game]
button.[new_game]
, new game is created and the user's address is saved into the contract's variable.[one_more]
and[enough]
.[one_more]
is pressed, another card from existing deck is dealt to the player in addition to already known cards. State of the deck must be updated. If sum of values of dealt cards is more than 21, the game ends. If it's less than 21, the buttons are displayed again.[enough]
is pressed, the game ends.[new_game]
button again.Card values: