Skip to main content

Cartesian Battleship

Cartesian Battleship

Fully on-chain battleships game
In progress - Pre-AlphaGames

Team

Dimitar Angelkov
dimitar#3019
Lachezar Gorchev
LA40#9971
Milena Tomova
George Georgiev

Languages, Libraries & Stacks

Share project

About Cartesian Battleship

This is a fully decentralized / on-chain version of Battleships. The goal is to sink boats on the opponents' board without seeing them. The board configuration is encrypted and sent when the game begins so that no one can see the board but they also can’t lie about what was the initial setup of the ship’s positions.

Gameplay

  • Player creates game by positioning fleet on the board, game id is generated
  • Second player joins the game by positioning fleet on the board
  • Players send guess coordinates on each turn
  • Games continues until one players fleet is fully guessed (shot down)
  • When game ends the result is updated and the winner is announced

Game Play



Technical Details

Architecture

Instant Server

In the Battleship game we are using the Cartesi rollup as a game server and every player turn is sent as a transaction through the blockchain. We have encountered a problem with this approach in cases where the network is slow then every player turn has unacceptable lag. We came with the solution to route all the time critical communication through an external fast server that is not on the blockchain at all. This is a concept that is called “state channel” by Cartesi. We come with our implementation which we call “Instant server”, it is built with Node.js and MongoDB. Currently the messaging goes over HTTP/HTTPS but different protocols such as Web Sockets might be also supported.

The Instant server has the following purposes:

  1. To just deliver messages between players in the fastest possible way
  2. To organize the communication in containers so the players may send messages between themselves only in the context of a certain game (in similar projects this could be called channel, room, group, etc.)
  3. To apply additional custom business logic to validate the player messages; in this case it is programmed to enforce the rules of the Battleship game but it might be repurposed for other applications

Instant Server



MiniBlockchain

With the introduction of the Instant server the communication between the players is moved outside the blockchain therefore it can no longer be trusted. At the end of the game both players return to Cartesi rollup for game verification by providing the entire history of their communication that happened on the Instant server. However there is no guarantee that any player has not forged their own version of history and there is no way to tell who is right and who is wrong. In order to solve this problem we came up with a concept called “MiniBlockchain”. This method allows the players to sign every message and include the signature of the previous message (sent by the other player) and this way the entire communication history is formed as a blockchain of its own that cannot be changed or forged by any of the players. By having both players’ public keys the authenticity of the communication history can be easily verified. This MiniBlockchain is formed at client level (it has nothing to do with any real blockchain network) and then it is provided to the Cartesi rollup for verification.

  • supports chaining using hash or user signatures
  • supports verification
  • supports key pair generation
  • written in JavaScript and works on Node.js using its crypto library

The purposes of the MiniBlockchain concept are:

  1. to provide means of securing and granting authenticity of communication history or similar sequence of messages or events sent by untrusted parties in an untrusted environment
  2. to provide methods for verification
  3. to provide support library for different platforms

What's next

In the near future, we imagine seeing multi-player versions, or versions with a variety of customized rules. For example, players could decide to alter the size of the board, change the kinds of ships they’re allowed to play with, add additional submarines, and create special boats with specific powers, such as taking 2 hits on each specific section before they blow up, or bombs that blow up two squares at a time.

Read more

Gallery

Productive Decentralized Battleship Logo | Built with Cartesi Rollups
Productive Decentralized Battleship - Join or create new game screen | Built with Cartesi Rollups
Productive Decentralized Battleship - Create game screen | Built with Cartesi Rollups
Productive Decentralized Battleship - Place your ships screen | Built with Cartesi Rollups
Productive Decentralized Battleship - Waiting for player move | Built with Cartesi Rollups
Productive Decentralized Battleship - Gameplay Miss | Built with Cartesi Rollups
Productive Decentralized Battleship - Gameplay Logs | Built with Cartesi Rollups
Productive Decentralized Battleship - Enemy Hit | Built with Cartesi Rollups
Productive Decentralized Battleship - Gameplay Hit 2 | Built with Cartesi Rollups
Productive Decentralized Battleship - Gameplay Hit | Built with Cartesi Rollups
Productive Decentralized Battleship - Verify gameplay | Built with Cartesi Rollups
Productive Decentralized Battleship - Winner screen | Built with Cartesi Rollups
Last updated: Oct 20, 2023
Anyone is free to submit information about their project. Do your own research and use your best judgment when using or interacting with any of the projects listed in this directory. Being listed in this directory is not an endorsement from the Cartesi Foundation or any other related entity.

Explore similar projects

Ballaum
Proof of concept

Ballaum

Betting system for prediction of the world cup matches

Last updated: Oct 20, 2023
Dazzle
In progress - Pre-Alpha

Dazzle

A strategic, competitive online game that blends the aesthetics of puzzle game with RPG elements.

Last updated: Oct 20, 2023
Ultrachess
In progress - Pre-Alpha

Ultrachess

Fully on-chain chess DApp. Wager real money and play against other chess pros. Or deploy your own chess bots to compete in AI chess battles

Last updated: Oct 20, 2023