Our First Unstoppable Game : Tug Of War
Back in June, we decided to participate in the status hackathon. We wanted to make a game that would run on the Status.im app. But more than anything we wanted a fully decentralised game, a game that can’t be censored, a game that run entirely on the blockchain. An unstoppable game.
Even though it runs on the blockchain, we of course wanted to provide a smooth experience to the players as we do with our skill game platform at http://etherplay.io (UPDATE: our skill platform is no more active)
We thought to use state channel over some peer to peer protocol (or at least for the hackathon use a server as the message delivery mechanism). But it was not necessarily the best approach for the kind of game we wanted to build.
We wanted to build a game that can be played on players own schedule. An asynchronous turn based game where turn can be as long as 24 hours or more.
The game we chose to implement is the game of Tug of war. Its simplicity made it a perfect choice for a blockchain only game and its sense of depth make it a fun and thrilling game to play.
While our hackathon submission was buggy and its smart contract had flaws, it was a working game running on the blockchain with a nice interface made in a week. Unfortunately, we did not win any prize but that did not make us give up on the idea.
While we were planning to rewrite our current skill game platform to optimise its gas usage and extra features (still the plan by the way), we decided to focus on Tug of War for the time being and re-implement it from scratch.
That was a fun adventure and we now have a cool looking unstoppable game running on Ethereum! Depending of success we might consider building more of these.
It has beenrunning on the 3 testnet: ropsten, kovan and rinkeby. But due to the high average gas price on the ropsten network, the game has a higher cost that does not represent the gas price we should have on the mainnet and we disabled the interface for it for now.
You could back then grab a web3 browser and have a go at the game but it is no more active . You had to be patient though as there might not be so many players when you try it the first time. Since this is is on the testnet, do not expect all the players to keep playing too.
To start a game, 2 players agree to bet a certain amount of ether. Both players start with a equal number of units and for each round, players decide how many units they want to send. After both players determine the quantity of units to send, battle is initiated, and the player who sent more units wins the round. The first player to win 3 rounds more than the other player wins the game. If both player run out of units before having a 3-round advantage, the player with more rounds won wins the game.
In regard to web3 browser compatibility, some have few problems and we are looking forward to getting feedback. Also if your are one of the developers behind these browsers, take our game as a good test case. Looking especially at Uport and Status. Status web browser in particular has a broken local storage implementation whose data get deleted upon quitting the app. Bear this in mind when using it.
For those that don’t want to be bothered use Metamask or Mist.
In term of decentralisation we wanted to get as far as we could. We actually published our game on swarm and registered it’s hash on ENS. Note though that swarm is not ready for prime time yet and the data did not get replicated.
If it did you could use Mist and navigate to bzz://tugofwar.eth . Really Looking forward to the time when smarm will be ready. We would not need to exist anymore and the game would still be alive. An onlinegame without server!
Our experience building the game has really been amazing. The power of web3 was felt all the way. We hope this game give you a sense of what web3 is all about.
If you are interested in the details, there is the smart contract code here : https://rinkeby.etherscan.io/address/0x8242e199f7d0559403f668e8d75db7c90c49a2af#code
We did not release the source code for the game interface but we might publish some info if there is interest.
As we mentioned the game currently run on the testnets only, but we are looking forward to seeing it run on the mainnet. We want to gather as much feedback as possible first though.
Thanks for reading and we hope you will enjoy Tug Of War!
If you want to have a look at what it looks like here is a video :
https://www.youtube.com/watch?v=_2FYlDFIHVk
Stay tuned
The Etherplay team