Dojo Chess

Chess game engine written with Dojo stack (ECS, Cairo)

  • 16,129 Raised
  • 24 Views
  • 1 Judges

Categories

  • Main track - $45.500

Gallery

Description

Dojo Chess is a chess game engine designed using the Entity-Component-System (ECS) template, Dojo. It aims to provide a robust and efficient implementation of chess gameplay for an enjoyable chess experience in a digital environment.


Working Test : check tests.cairo

- Initialize game 

- Execute Move

(Whit pawn) : move (0,2)

(Black pawn) : move (1,5)

(Whit pawn) : move (0,3)

(Black pawn) : move (1,4)

(Whit pawn) : move (1,4) -> Generate Board, check there is Black pawn -> kill Black pawn

- Give up ( White ) 


Design

Components 

  •  Piece Component: Represents chess piece properties (type, color, etc.).
  • Position Component: Stores current piece positions on the chessboard.
  • GameTurn Component: Tracks the current turn (white/black) in the game.
  •  PlayersId Component: Identifies and assigns unique IDs to players.

Entities

  1.  Chess Pieces Entities: Separate entities for each chess piece on the board.
  2.  Game Entity: Represents the overall game state (chessboard, players, settings).

systems

  • Initiate System: Sets up a new chess game, generates the board, and initializes pieces.
  • Execute Move System: Handles executing valid player moves.
    • Generate Board Cache: Creates a cache to efficiently manage the board state.
    • Generate Possible Moves: Calculates possible moves for each chess piece.
    • Capture and Kill Pieces: Handles capturing opponent pieces during moves.
    • Check Valid Move: Checks if the move is valid based on the rules of chess.
    • Update Piece Position: Updates the position of the moved chess piece.
  • Give Up System: Handles player resignation, declares the opponent as the winner.

Front-End
Connecting contracts with front-end app was difficult.
`@dojoengine/core` would benefit from a documentation.
I found hard to get the entities ID from the `sozo component` commands.
Calling functions was pretty straight forward.
---
Working features
- Landing games index page.
- Game page.
- Initialise a chess board from a json object.
- Position pieces from a json object.
- History display for game moves.

Pending features
- Drag and drop pieces to move.
- Contract calls - initialize, execute_move, give_up.
- Receive entities positions from contract.

Future features
- Login with web wallet.
- Spectate game.
- Rotate chess board.
- Cool animations for killing pieces.

Attachments

Comments