Berlin University Students Build Chess Game on Ethereum

One of the world’s oldest games is joining the virtual world; the decentralized virtual world, that is.

A group of students from the Technical University of Berlin (TU) have developed a chess game on the Ethereum blockchain. Their goals were to test Ethereum development tools and to identify any issues as the experiment progressed.  

The project, consisting of students with web development experience, was supervised by the TU department of Information Systems Engineering and Dr. Christian Reitwiessner from the Ethereum Foundation.

Selecting the game of chess was an easy choice for the group since it is well-known and used within Computer Science. The experiment needed reliable computation in order to verify moves and end game conditions, and to calculate data. This made Ethereum the perfect candidate since the code is public and executes smart contracts. Using Ethereum made the game uncheatable.

In a Medium post, student Paul Grau explains:

“We abstracted all code that applies to turn-based games in general into an abstract base class. Chess is the main contract the clients interact with. Game rules (state and move validation) are in a sub-library ChessLogic. Some helper functions like signature validation (Auth) and Elo score calculation are also outsourced into libraries. A complete game of Chess can be played reliably on-chain, meaning no other communication is involved except messages from and to the Smart Contract.”

The group did hit a few drawbacks, such as verifying the game’s winner. Grau said it would be impossible to calculate and verify every possible move as well as its outcome. Even by implementing Solidity, they discovered it “exceeded the current limits of a transaction.” Their biggest issue was creating a game that allowed real time play. The game of chess can move pretty fast, especially for those who play with a time clock. Although Ethereum generates blocks every 14 seconds, it is still not quick enough for the game.

Alternate solutions had to be developed by the students. Certain features will either rely on clients verifying each other’s moves and possible off-chain structures. The group believes Ethereum’s own Whisper will be a better option for them in the future. Still, they concluded that smart contracts are a necessity for the decentralized web. Developers should still look at other solutions if needed.

“The Ethereum virtual machine is turing-complete, but that doesn’t mean that everything should be computed on it. Since there is a clear cost assigned to every operation, we have to model our applications in creative ways to use the available resources effectively. In conclusion, we think that it is definitely feasible to implement decentralized games using Ethereum, but one needs a smart model to make them efficient and usable,” Grau writes.

The experiment’s code is open source and can be found on GitHub.