Null Games

This thread is aimed at games that are done directly on the chain using OP_RETURN null data. I will attempt to be very general at first and end in some examples

Cost
Each 80 byte message will cost 0.01 PPC. This is more about the time resolution than the txn size, so this action will be deemed a single “turn” or “move”. A target that I will pick somewhat arbitrarily will be 30 ppc burned per 100 games per person. This implies that a single game will average 30 turns per player.

Initiation
A veteran player will send a P2TH tagged txn that specifies a game mode and tweakable game constants. Another player will send a txn that accepts the challenge. The tag will let people search for recent unaccepted challenges more easily.

An initiator may send the call to battle to a specific address, allowing players to game against their friends directly instead of random strangers. This can be done by including an extra output sending 0.01 ppc to your friend’s address.

Turns
A turn will be tagged and include null data that encodes the player’s turn. Essentially, the turn will contain commands with some known consequence on the state of the game. Generally, one player will go first and wait for the other to respond. Who goes first will be chosen by the game mode, either the initiator or using some random function of the blockchain.

Good game properties

[ol][li]The game should aim to end in 30 blocks. It should have clear motivation to end or have a max number of blocks between turns or else a player forfeits. This is done to ensure a victor for each game. As the game requires a cost to complete, a game should have clear definitions for ending after some upper limit number of moves.[/li]
[li]The game should seek to be “fun”. This includes graphics and GUIs, i.e. a website front end. As the turns can’t happen faster than once a block, it would even be better as a smartphone app. It could function as a custom client. We could easily add micro transactions to some “pay to win” game modes.[/li]
[li]Having variety without complexity. Competitive and engaging, but not frustrating due to the wait time between turns. Ideally, each turn will require some thought on the part of the player.[/li]
[li]Everything must be discrete and slim. While a null game of dungeons and dragons would be awesome, the cost would be inhibitor for everyone involved.[/li][/ol]

Playing off of zero conf
Technically, a game can be played instantly without waiting for confirmations. Most of the time, this is secure because nodes will reject a double spend based on chronology of received txns. Only in the event of say a tournament would I worry about foul play via a compromised minter.

Winner’s pool
A particular centralized null games client can release a peerasset that is only created upon successful completion of a game. People can use the addresses with these tokens in them as pseudo identities, with all the prestige that comes with having won a lot. There could even be exclusive events where people can come with a mask on and without ID other than a signed message. The tokens could be awarded based on different game criteria, and awards or prizes or what have you could be issued based on them. Of course, the centralized client can have its own PeerAsset that represents stock.

Examples:
Chess
With an average game length of 40 moves (~0.2 ppc cost per player per game without initiation) and a board that can be encoded easily in hexidecimal, chess is perhaps the ideal null game. Simply feed the rules of chess into the client, encode piece names into hexidecimal, and you’re basically done.

Settlers of Katan
Dice rolls can be done using the blockchain during or after the person’s turn for a random seed. Turns have a finite number of potential actions and the board is discrete, it should be possible to find a way to contain a full turn in 80 bytes. The biggest complexity here is trading, but that can be done by providing or accepting standing offers on your turn.

Card Games
You can get your cards from a hash, like a die roll. From there it is fairly straight foreward, though the gambling bit leads to some interesting topics. For example, having an arbitrating ppc address that will pay out to the winner.

Trading Card Game
We can blend a null game with peerassets and create a series of collectable peerassets that can be used to play a null game. The cards can even be real peerassets with multi issuance instead of custom. So an address would hold a set of peerassets and call it a ‘deck’. Then, you draw with complex rules, but the “turn” can totally be made finite if we correctly craft the rules of the game.

Custom made games
If you try to make your own game, you will find that you need to make your own client and you are cut off from the network. This defeats the purpose of null games, and so is not supported. The market will naturally gravitate to one or two centralized clients, and getting a game included there would be much more efficient. Of course, in the case where the community knows the rules to a game that isn’t in a client (a removal of a game, for example) individual forks of the client that specify the rules to that game properly can gain traction.

So there you have it. Happy to hear thoughts.

Great stuff!
Let’s make Peercoin the most fun blockchain!

Integration in PeerKeeper would be cool. Or the other way round, using the PeerKeeper framework to power the web UI’s.

[quote=“Nagalim, post:1, topic:4075”]Chess
With an average game length of 40 moves (~0.2 ppc cost per player per game without initiation) and a board that can be encoded easily in hexidecimal, chess is perhaps the ideal null game. Simply feed the rules of chess into the client, encode piece names into hexidecimal, and you’re basically done.[/quote]

Hexadecimal? OP_RETURN just stores binary, which is half the size of hexadecimal.

A turn can be up to 80 bytes. I was just noting that a turn in chess is almost human readable whereas other games would almost necessitate a front end for usability.

For example a chess turn could be:
05e4
Representing kings pawn forward.

Ah ok, checkers would be a good candidate too! (https://en.wikipedia.org/wiki/English_draughts)
You can encode the board as 16 bytes.
pieces encoded as 01 (player 1) and 10 (player 2)
kings encoded as 11 (players are differentiated by move history, should be easy enough to remember or implement in a commandline client)

01 00 01 00 01 00 01 00
00 01 00 01 00 01 00 01
01 00 01 00 01 00 01 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 10 00 10 00 10 00 10
10 00 10 00 10 00 10 00
00 10 00 10 00 10 00 10

You can have multiple moves into one block using the mempool if you reference the previous move: 32 extra bytes (txnid), resulting in a total of 48 bytes per move!

Another simple one, battleship!
Let’s take an 8x8 grid like checkers per player (32 bytes for the two grids + 32 bytes of the previous turn reference = 64bytes per turn).
A shot is encoded by 01
A miss is encoded by 10
A hit is encoded by 11

First each player puts ships on his board (encoded using 11), signs it and publishes the signature so cheating can be detected after the game. (we should do some brute force protection using a salt or by publishing a high N-factor scrypt hash of the signature, to be scoped out further).

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Player one starts by shooting at player two’s board (upper right corner):

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Player two indicates a miss and shoots at player one’s board (upper left corner):

01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Player one indicates a hit and shoots at player one’s board (lower right corner):

11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01

But what is the purpose? We already have good ways to play these games online. For example, https://lichess.org. Is the goal to have a kind of censorship-resistant chess? :))

Trustless chess :slight_smile:

I don’t think this project is about filling a hole in the market, but rather just about having some fun and prototyping PA implementations.

Totally. Seems like an quick and easy implementation to demonstrate the practicality of pa. Should be a great recruiting tool for PC. Awesome stuff.

Sure, it’s censorship resistant. If the main client gets rid of a game but people refuse to update their client they can keep playing the game. But there are lots of other applications, such as the equivalent of trading card games, which can easily use PA or something similar. Betting on games is definitely up there on the potential real applications for null games, because the games are 100% verifiable as long as peercoin is secure, and players are anonymous.

Null games are not in and of themselves PAs, but they would use P2TH.