Games

Smart contracts have a lot in common with games. They have clearly defined rules, and outcomes. Once players agree to join a game they have a specific set of moves they can make. A few of the examples we've seen already are clearly games, such as the patience game. Others are not so obviously games, but even they can be modeled as games. For example the click counter was a game where players could go in any order and the two kinds of moves they could make were increment and reset. Some games, like patience, have final results while others, like counter, continue forever.

Because so many real-world interactions can be modeled as games, we will take a look at a few more here. After this unit, the tutorial continues primarily as example programs with exercises commented in. The majority of those exercises are games of one variety or another.

Randomness

Although this technique for generating randomness will often work in practice remembe that in a blockchain context the "random" result is entirely up to the network validators. If the validators have a stake in your game, they can influence the result from outside the obvious rules of the game. How to get true randomness into blockchains is an open question.

Edit this page on GitHub