Post

A chess game

This project is a self-made chess game built with :

Backend

scala http4s

Frontend

react typescript

Deployment

docker googlecloud

Versioning

github

The goal of the project is to make a workable chess game that you can play on your computer.

Project situation :

  • Scala backend
  • Scala API
  • React frontend
  • Deployed on Google Cloud

You can find the project source code on GitHub.

You can play with the application on this link.

Why this project

Early 2023 I attempted to learn how to play chess. Since then I practice regularly and I found my interest for the game growing day after day. I play solely on Lichess, which is an open source chess application that allow you to play, analyse, study and pratice chess entirely for free.

On the other hand, I always like to learn new skills and tools to enhance my software engineering skills. I stood upon the Scala language which appeals a lot to me for its Object Oriented/Functional Programming hybrid paradigm. I therefore decided to create my own chess game application with this technology.

I plan to make a React-based Frontend in the near future to allows easy use of the application.

Chess rules

The game of chess is played by two players (white and black) on a 8x8 board. Each player has 8 pawns, 2 rooks, 2 bishops, 2 knights, 1 queen and 1 king. The goal is to checkmate the opponents’s king, which means the opponent king is threatened with capture and has no espace.

For reminder, pieces move like this :

pawn
Pawn movements
rook
Rook movements
bishop
Bishop movements
knight
Knight movements
queen
Queen movements
king
King movements

Scala backend

The backend of the application is made in Scala. You can find the documentation of the backend at this link.

A game of chess can be created using the Game class. A game contains a Board which contains all the Pieces.

The game goes on like this :

  • The player choose its piece to move.
  • The player choose the square it wants to move the piece on.
  • It’s the opponent turn.
  • It goes on until one of them wins, or a draw appears.

To debug the main game, it was usefull to print the board in the terminal : BDD The chess board in the terminal

React Frontend

The frontend of the application is made in React and TypeScript.

BDD The chess board of the React application. Here white has its king in check and must defend it. It can for example move the selected knight on e4 on the only two valid squares d2 and c4

Deployment

Both the backend and the frontend are built with docker and deployed to Google cloud.

This post is licensed under CC BY 4.0 by the author.