I’m considering building a SafeChess app (similar to the email app) that lets two people play chess over the safe network. You don’t really need the security, but it could be fun and iron out a few architecture patterns.
I’m struggling with where I should put the logic that validates the players are playing legal moves? If I put it into the app, then potentially a player could create there own ‘evil’ version of the app that lets them play illegal moves. Normally you validate user input server side, but I don’t have a server!
I’m hoping to write the moves of the game to storage as they are played and then keep the game as a whole once finished.
I thought that the app could have two personas, one for playing and one as a third party ‘arbiter’ of games in progress.
When two players agree to play, they also agree upon an arbiter. When a move is made, it is written to appendable data and change permissions allocated to the arbiter. The arbiter checks the move and then changes the permissions to the opposing player, if the move is illegal, the arbiter would delete the last move and change the permissions back to the original player.
Also I’d like to do this in a ‘cheap’ way so that when we get SafeCoin it’s not going to cost $$$ just to play a simple game, so I’m interested in the data types to use (one structured data object vs appendable data with each move). It might be cool to define use a custom tag structured data type for chess games.
Simple, if I was writing it I would not try to prevent this.
The other player and any others watching the game will use good apps and they detect the illegal move and call foul. This requires keeping history of at least one previous position.
People will not play with cheaters so the APP that makes illegal moves will be shunned. Just like happens in “real life” in person games.
On another note, I have thought about an APP that learns from people playing it around the world. So rather than trying algos for winning it does what the masters do, learn board positions and what the best moves are from them.
You may be interested in this article by a research team who implemented a chess game on Ethereum: Lessons learned from making a Chess game for Ethereum | by Paul Grau | Medium
Their approach was to use direct p2p messages for the players to send the moves back and forth, while the blockchain contracts are used for settlement and dispute resolution. Your arbitrator idea is pretty similar to the contracts. Perhaps a network of arbitrators would be better than one specific person, with the network consensus determining the outcome.
If your games are just for fun instead of for money, maybe you just need some reputation system so people can say ‘this person is a cheater, don’t waste your time playing them’.
You could also invite “non-players” , people who just let the app ( or an arbiter-only version ) run and check for illegal moves between real players .
Arbiters register when they are online in a mutable. They don’t need to actually watch the game.
When 2 players prepare for a game, the app scans the list of online arbiters and connects to them. I suppose the app could check that the arbiters are not evil arbiters by asserting for a valid key, too.
i would do the same, build a reputation system around it. People with bad rep wouldn’t find games to play.
I would keep this very simple for the first version. Each move within its own immutable data. A chain of immutable data would be a game, each player adding one move at the time. The app would make sure a player doesn’t play twice. The app would also publish the game in a kind of forum so they are easy to find. Then I would run a program on my own computer to check all games and publish player stats on a safe site.
It’s a neat project with a lot of different challenges, good luck!