Skip to content

A smart-system project. This system will monitor the current Xiangqi (Chinese chess) game, and stream that game with the suggested moves (ultilizing a Chess engine) to a website hosted on a local web server that is accessible by connecting to the system's private wifi network. Written in Python 3. Designed to run on Raspberry Pi.

Notifications You must be signed in to change notification settings

nvatuan/chinese-chess-assistance

Repository files navigation

Chinese Chess Assistance (CCA) System

This is a Smart System project that:

  1. Applies Artificial Intelligence
  2. Applies Embedded programming
  3. Applies Internet of Things With the purpose of assisting human making decisions.

Summary

The system's process

The system consists of 3 steps:

  1. Monitors the chessboard, taking picture every few millisecs.
  2. Recognizes the pieces, understands the chess board position. Then, search and calculate for the next best moves.
  3. Broadcast those information over LAN via wi-fi. The system has a dedicated web-server to display these information.

As you may know, the hard task is in Step 2, which will be described below.

The Problem and Solution

The problem CCA has to solve can be summed up as follow: "Provided a picture frame that contains a game of Chinese chess, please suggest the next best moves for the two players."

Based on the above problem, the solution must solve these subtasks:

  1. The computer understands the board. (Solved using Computer vision with a Tensorflow Classifier model)
  2. The computer suggests chess moves. (Solved using a chinese chess engine as backend with some modifications)

Here we will describe only the first subtask.

The taken frame will first go through preprocess phase to better isolate the board from the rest of the images. This preprocess has 3 steps:

  1. Find mask of the board
  2. Find contour and four corners
  3. Perspective transform

Below is an example of a frame going through preprocessing:

Preprocess example

After obtaining the top-down view of the board, we attempt to retrieve each position on the board by cutting the image using vertical and horizontal lines. There are total 90 positions on the board. Next, we will use a classifier model (which was specifically made an trained for this taks) to recognize the symbols on the pieces. Below is an example.

Recognition example

Lastly, we pass the board to the engine to retrieve the suggestions.

Photos

Top-down view

Image of the system in action with the chess board

Web-server

Image of the prediction page of the site

Deployment

Our project were deployed on a Raspberry Pi 3B. This device also has a small webserver that is used to deliver/broadcast the current chess game to other devices that connect to the server. If you are wondering how the system runs, please take a look into threaded_webserver.py.

Links

  • We did a small video to demonstate our project/system here.
  • For more on preprocessing, checkout dev-boardPreprocess branch
  • For more on piece recognition, checkout dev-pieceRecognition branch
  • Please check out our report here (Vietnamese and English) if you are interested.
  • The Chinese Chess Engine that made it possible elephantfish.py. Please go and give them a star!

About

A smart-system project. This system will monitor the current Xiangqi (Chinese chess) game, and stream that game with the suggested moves (ultilizing a Chess engine) to a website hosted on a local web server that is accessible by connecting to the system's private wifi network. Written in Python 3. Designed to run on Raspberry Pi.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published