The first Cartesi-powered Decentralized Application

What is Creepts?

Creepts is the world’s first decentralized tower defense tournament game. It is built on top of Cartesi’s Layer 2 solution for blockchains, which is available as an open-source software stack that is under active development. Currently, Creepts is playable on the Rinkeby Ethereum testnet.

The Creepts game welcome screen.

In Creepts, players compete against each other to see who can claim the highest score in a fully-featured, real-time, browser-based Tower Defense game map. Players join a tournament by committing their high-scores and game moves to the blockchain, at a negligible cost. The game’s smart contracts then decide who the winner of the tournament is.

The Cartesi technology stack features several on-chain and off-chain software components, which provides the Creepts game with its support for decentralized and cheat-resistant tournaments. Cartesi enables all Creepts players to automatically reproduce the gameplay of any other player’s score, off-chain. If anyone attempts to cheat by reporting an inflated score, some other player in the tournament will automatically use Cartesi to obtain the real score based on the game moves committed by the cheater. The honest player will then automatically challenge and publicly defeat the cheater using Cartesi smart contracts, causing their disqualification.

Not only does Cartesi provide Creepts with cheat-resistance, but it actually makes it possible for a complex game like Creepts to run on the blockchain. A Creepts game session involves the computation of billions of program instructions, and that kind of workload is several orders of magnitude greater than what a public blockchain can handle. By leveraging Cartesi, Creepts is able to run its game logic entirely off-chain while retaining the strong security guarantees and decentralization of the underlying blockchain. And, to achieve that, the game developers did not have to design the Creepts software to run on a restricted virtual machine environment. The Layer 2 Cartesi Machines can run software developed in any language or with any software library, as long as the entire stack compiles to RISC-V and Linux.

Playing Creepts

Creepts is a browser-based, graphical, real-time, decentralized action game that is ultimately coordinated by the blockchain. To play the game, the player must point their web browser to a Creepts Client. Players can download and run their own local copy of the Creepts Client, which comes with a web server that provides the game to the player’s web browser. The Creepts Client then interfaces with the Cartesi contracts in the blockchain on behalf of the player. In the future, players will be able to play Creepts by pointing their browsers to a trusted remote Creepts Client, without needing to download and install anything themselves.

The Creepts tournament selection screen.

After the player points their web browser to a Creepts Client, they are shown the several tournaments that are available for them to join. Upon selecting a tournament, the player can then play the Creepts tower defense game map of that tournament without actually committing to a multi-player competition. The game runs entirely client-side, on the player’s own browser, as the game is written in Typescript. The tower defense game is single-player, so the player can play the same game map for as long as they like. They can play at their own pace, and they can go back and select a different tournament to play on as many times as they like.

A tower setup, waiting for the next wave of enemies.

Whenever a player finishes playing a Creepts tournament map, the player’s Cartesi Node (which is part of the Creepts Client) then automatically commits (submits), to the blockchain, a secure hash of their gameplay, which is a log file that lists all of the game moves that they have made. While players keep their exact game plans secret, their committed gameplay hash will indirectly bind them to a specific actual score in the game that can be independently verified. That’s because Creepts is deterministic: any party can replay the game moves listed in a game log file and reproduce a score from that log file.

Defending against a wave of enemies.

If no players join a given tournament, then no player wins it. If only one player joins a tournament, then that player wins it by default. If two or more players join the same tournament, then the player’s machines, running the Cartesi dispute resolution system, will automatically check each other’s scores to determine the tournament winner.

After playing a tournament game map, the player is done interacting with the tournament as a game player. Everything that follows is negotiated automatically by the player’s local Cartesi Node. The player will then just wait for the tournament brackets to resolve over time as the Cartesi system works to determine the winner.

The selected tournament, while it is being resolved automatically.

After the tournament is closed for gameplay commitments, all players will gradually reveal their actual gameplay logs and submit an unverified final score claim to the blockchain. Players who fail to upload their game logs for the blockchain, for whatever reason, are eliminated.

We won the tournament, on-chain!

After a while, the gameplay reveal phase will end, and the player will wait as the Cartesi Nodes, running at every player’s local machine in a fully decentralized manner, verify each other’s actual scores. Cheaters who have reported inflated scores to the blockchain are automatically eliminated.

Preventing cheating with Cartesi

When a player finishes playing the game in one of the game’s Tower Defense maps, they know their own score in that map, and the complete sequence of moves they made to achieve that score in that map, which is known as a Creepts gameplay log. The Creepts game engine, written in Typescript, runs inside of a deterministic Cartesi Machine, so it always produces the same score given the same log of player commands over a given game map.

Since there is no authoritative server anywhere that will be automatically replaying player’s game logs to reproduce their scores, all that the game’s on-chain code has access to is what players report as their own score, as well as the game log files of all players that are submitted automatically to Ethereum by the Cartesi Logger component. The party that is going to verify whether a player’s game log actually produces the score that they claim is another player that is competing directly against them across a tournament instance bracket. In other words, another interested party in that Layer 2 computation.

To verify another player’s score claim, your Cartesi Node downloads the other player’s game log from the blockchain and replays it inside of a Cartesi Machine, which is a deterministic RISC-V machine emulator running a Linux OS, which in turn runs the Creepts game engine written in Typescript (without the graphical interface). If the Cartesi Machine obtains a different score than the one reported by the other player (that is, the other player is lying about that game log of theirs resulting in the score they have reported for it), your Cartesi Node will submit a dispute to a smart contract on-chain, starting an interactive Verification Game that is mediated by Cartesi smart contracts. Your Cartesi Node is mathematically guaranteed to win that dispute on your behalf, as the smart contract knows how to correctly assess the various cryptographic proofs about how the deterministic computation of the game score from a given game log is supposed to evolve over time. Since you are telling the truth, and your opponent is not, you will disprove their claimed score, and you will win.

Note that when players are matched to the same tournament instance, they all reveal their game log hashes and claimed scores simultaneously. The bracket structure of the tournament is solely for the score verification phase! That’s why the tournament brackets resolve automatically: the verification phase is entirely resolved by the DApp running on top of Cartesi. The DApp will match players pairwise in brackets so that they verify each other’s scores, and if there are no disputes, the blockchain will assume the player with the highest reported score is the winner, and move on to match the winner with another winner in the following verification bracket — or declare a tournament winner, if all other players have been verified out already.

Illustration of a sample Creepts tournament instance resolving itself.

The figure above illustrates how a network of Creepts players participating in the same tournament instance can determine the winner over several rounds with at most log(N) verifications carried out per game log, where N is the total number of players in a tournament. In the figure, Player C is a cheater whose real score is below that of all other players, though it reports it as 999,999. After the first round of Verification Game matches, Player C advances over Player D due to the latter going offline and not defending their score, which is actually higher than Player C’s real score. Meanwhile, honest players A and B both reproduce each other’s correctly-reported scores, allowing Player A to advance by merit. During the second round, Player A verifies that Player C has reported an inflated score, which disqualifies Player C and allows the blockchain to finally crown Player A as the winner.

Note that Cartesi will allow a future version of Creepts to not require players to stay online to reproduce other player’s scores and to defend their own victories. Cartesi will be extended with dispute delegation providers that will allow players to completely forget that computation disputes exist.

Conclusion

Cartesi frees blockchain Layer 2 development from restrictive programming environments. The Creepts game logic that determines player’s scores is implemented in Typescript and runs over a Linux OS. The blockchain components of Cartesi do not care what the software used to write the Creepts DApp is. All it cares about is that Creepts can run inside of the Cartesi RISC-V machine emulator to produce verifiable and disputable game logs and player scores to the tournament contracts.

Cartesi also allows Creepts to be the first blockchain-based multiplayer game that is able to mathematically prevent one of the most impacting cheating vectors in decentralized and competitive virtual worlds from being exploited, which is the injection of arbitrary content into the persisted game state. Creepts can do so while accepting arbitrary off-chain (Layer 2) game logic, written for a Linux OS, incurring massively reduced computational costs for the Layer 1 components of the DApp.

Creepts is not exactly a massively-multiplayer online game (although the game does accommodate an arbitrary number of players by spawning as many tournaments as needed), but because of its blockchain nature, it is native to one of the central aspects of most massively multiplayer online games, which is support for persistent-state virtual economies. For example, Creepts tournaments can be extended to issue and pay a CREEPTS token to winners, or to distribute unique items that can be equipped and that change gameplay, or even prizes in ETH or CTSI. In any case, Creepts showcases the mathematical prevention of arbitrary modifications to the game state, which is an open problem in decentralized MMO support research. That is an extremely important milestone on the way of supporting complex blockchain games that want to spawn functioning virtual economies.

Creepts is the first DApp to showcase the power of Cartesi, and it is already a first of its kind among the universe of applications. And it is just the beginning of Cartesi for blockchain-based games, and for all other DApps that need verifiable off-chain computation. We cannot wait to see the innovative applications developers will build with on top of Cartesi, taking advantage of the extra convenience and computational power it provides.

You can submit your technical questions about the Creepts game, the Creepts implementation, or the Cartesi system as responses to this Medium article or our Discord channel, and we will do our best to answer them. We will be continuously publishing multiple forms of documentation that offer technical insight into the evolving Cartesi software stack.