Jump to content
Christian Pichler

Basic question about blockchain games

Recommended Posts

Hello!

I don't know much about blockchain game programming- only have some experience with c/c++... but I'm interested in this subject and would like to understand how it works. So my question about that:

A blockchain game needs to know the position of every unit on a map- the players units and the enemy units, so that it can compute whether 2 units come close enough for a fight. So every node, I think, needs to have this information, although not all information should displayed for the player. Because in every game, there is information that the player is not allowed to have. This would be the information about the position of enemy units, or parts of the map that he has not discovered yet... so how can you prevent that this information is extraced from the node by someone with advanced computer skills. The blockchain prevents changing the game state to your favour... can it also prevent someone to write a 'cheating tool' that shows you all enemy units on the map? Is there a simple answer to this question or does this fact mean you can only implement blockchain games, where every player is allowed to have all the information of the whole game, like chess or risk, where you can see all your own and all the enemy units?

Perhaps I ask this question because I don't understand how blockchain gaming works in detail, and there is an easy answer to this question...

Regards, Chris

  • Like 1

Share this post


Link to post
Share on other sites

That is a very good question.  In some sense, you are right that you have to design games in such a way that it is ok for everyone to have all the information.  However, there are still ways to implement hidden information.  For instance, using a "commit / reveal" scheme.

For instance, you may want to give players the ability to set "traps" on a hidden location on the map that then attack someone who comes close.  You can implement that by having players publish a (salted) hash  of the location when they set the trap; this ensures the data is "fixed", but the location itself cannot be determined from it.  Then if someone gets in range, they can publish the preimage (real location), and it can be verified that it matches indeed the hash they published previously (so they are not claiming a trap to be in a wrong spot).

This is of course a very basic design, but you can build more sophisticated game features with this (or similar) concepts as well.

  • Like 1

Share this post


Link to post
Share on other sites

ok, so there will also be information (the real position of the traps in your example) that stays in the local computer of the player and is not published on the blockchain... this information should be stored safely of course- and in the best case encrypted! But it might be hard to implement a game where it's important that the players don't know the map before they discovered it, e. g. because there are treasures hidden on a map and you should not know the position of that treasures... poker would also be hard to implement because- how can the blockchain give out the cards secretly without the player's nodes knowing which cards are out already and which remained in the stack... for such games it still needs classic client- server applications, where sensitive data is securely stored in a server.

But you are right, at least sensitive information that one player should know and noone else, can be treated safely by using salted hashes. Information that noone should know, only the game itself, might get a challenge though! But perhaps someone can find a well working solution for that problem as well...

Share this post


Link to post
Share on other sites

Yes, that is actually a very interesting question - can mental poker be implemented in Xaya?

Share this post


Link to post
Share on other sites

yes, it is... I must admit, I just had to google the term "mental poker" and found something about it on wikipaedia... because it's quite a time ago that I did some programming- I'm quite out of my subject (computer science), but still interested.

So this is a known cryptographic problem and not something just I thought about. And for most known problems there is a known solution... maybe something with multiple key cryptography in this case, where every node has its key and only all keys together can decrypt the hidden information- but it's quite complex though. And of course, only information may be decrypted that is confirmed for decryption by the blockchain! But it's quite complex though...

This problem is not a problem of Xaya, it's a problem in all blockchain games on any chain!

Share this post


Link to post
Share on other sites

You can also use the same method for invisibility.. so people don't know where you are.

e.g.

you enable your "cloaking device" in Taurion, and then all your moves are encrypted (you are invisible).. it may last something like 100 blocks. If you don't reveal the key before 100 blocks you  automatically die.

  • Like 2

Share this post


Link to post
Share on other sites

ah ok, then games where you don't have all the information of the game should be possible to implement for a blockchain somehow- and you are already using this technique- that was my question. Your feature for XAYA sounds interesting- you can make yourself visible again on a different location and the opponent is completely unprepared! I'm looking forward to more games coming out for the XAYA- platform, then CHI price and volume should get better as well...

Share this post


Link to post
Share on other sites

Hi,

I created a little test-game yesterday "rock-paper-scissors". It was my concern too, that the player can view his opponents move. So I decided to encrypt the moves with AES and a secret only visible by the player submitting the transaction and the server. 

After both have made their moves, the server running my JavaScript-Xaya-Libgame implementation decrypt the hash and insert the real move into the DB, as well as sending it to the players.

Regards

  • Like 1

Share this post


Link to post
Share on other sites

I've also just very recently started working on game channels (finally!).  Together with the core framework, we will build a battleships-like game as the tech demo / initial example.  For that, we also use hash commitments to ensure provably fair gameplay without the need of any central servers.  You can find some preliminary informations about how that game will work exactly in our repository.  (This is still heavy under development, though.)

In general, hash commitments work very well to do all kinds of things between a known set of players (e.g. a game channel game).  For determining random events in a full game world (like disasters in Huntercoin), however, things look a bit different.  I've recently written a paper about that as well, using an entirely different approach.

  • Like 1

Share this post


Link to post
Share on other sites

@casp0or: so you still need a neutral server as a third party in your example... but then it's not fully decentralized, and you still have to trust the server that he is fair. Or did I undertand something wrong here?

Share this post


Link to post
Share on other sites
Posted (edited)

@domob
 I just read your article about battleships on github... isn't there still the possibility that if Bob wins the game (and should be rewarded with Chi from Alice), then Alice could prevent the  message "Alice lost" from being sent to the xaya network from her local computer... Bob will of course send the message "I won" to the blockchain... how do you solve this dispute then? Is this done by the xaya main chain?

Edited by Christian Pichler

Share this post


Link to post
Share on other sites
1 hour ago, Christian Pichler said:

so you still need a neutral server as a third party in your example.

No, my first approach was to use a server. But I think I can manage to switch over the code from the server to the client.

Regards

Share this post


Link to post
Share on other sites

ok, so you used a server to be able to test the game... in a decentralized game, you will need to do a lot of cryptographics- but if it works, it's better than a client server app, because you don't need to ask the question whether the server can be trusted or not.

Share this post


Link to post
Share on other sites
3 hours ago, Christian Pichler said:

I just read your article about battleships on github... isn't there still the possibility that if Bob wins the game (and should be rewarded with Chi from Alice), then Alice could prevent the  message "Alice lost" from being sent to the xaya network from her local computer... Bob will of course send the message "I won" to the blockchain... how do you solve this dispute then? Is this done by the xaya main chain?

What you are talking about is the situation that Alice (actually for a variety of reasons) might just stop responding to Bob (or might refuse to send a next valid move).  That's the core issue solved by game channels.  Basically, Bob would then post the state of the game on chain, and through that prove that he won (but read the paper if you are interested in the details).

  • Like 1

Share this post


Link to post
Share on other sites

yes, you are right- didn't keep this in mind after reading through the paper- it's quite complex stuff but of course interesting how such problems can be solved...

Game channels are a good solution to implement blockchain games- they seem to be a similar concept as the payment channels for the lightening network in bitcoin.

Share this post


Link to post
Share on other sites
10 hours ago, Christian Pichler said:

Game channels are a good solution to implement blockchain games- they seem to be a similar concept as the payment channels for the lightening network in bitcoin.

Yes exactly, they are modelled after payment channels.  However, one key difference is exactly this "proving that your opponent stopped responding".  With payment channels, you circumvent this issue by simply allowing anyone to just settle the current state at any time.  That is also the approach taken e.g. by Ethersips.  I've not yet seen anyone else who actually goes for "complex" games where you can't simply determine an intermediate payout.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Your use of this site is governed by our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.