Wizard’s Chess

A GUI application to play 2-player chess using speech recognition.

Tools used

  • Java for GUI development and controlling the game of chess.
  • CMU Sphinx4 library(for Java) for speech recognition.

Speech Recognition

Wizards’ Chess uses CMU’s Sphinx4 library for this purpose. It is an open source library based in Java for speech to text conversion. Input is taken through the microphone. It is converted to text by Sphinx4, and this text is further used to determine what move the user wants to make in chess.

Making a move in the game

You need to specify the initial and final position of the piece using standard board coordinates. However, we have changed the A-H and 1-8 notation to 1-8 and 1-8 notation as speech recognition of letters is less accurate compared to numbers.
Example : Suppose queen is at position a4 and you want to move it to a6 (which is assumed to be a valid move), you simply say 1 4 1 6 into the microphone.

Code for chess

This part of the code controls all other parts including GUI, speech recognition, and the game itself. This code is divided into several classes:
Validation – Contains methods to check whether input move is valid or not.
Convert  – As board coordinates, array indexing and GUI coordinates do not match, this class contains methods to convert coordinates from one type to another.
Checking – Contains methods to check if either side suffers from a check, checkmate, draw, stalemate, etc. These checks are performed after every move.
Tracking – Contains methods to keep track of the game i.e. contains the 2D array which represents the board, keeps track of which piece is alive, keeps flags for check, and helps for checking conditions for special conditions like castling, 50 moves rule, en passant rule, etc.
Main – Contains the main method which controls the flow of the program by calling methods from other classes mentioned above and also controls speech recognition and GUI.

The algorithms for the main program and for any validation method are :

GUI

The GUI is built in Java using the Java AWT (Abstract Window Toolkit)  which is an API used to develop GUI or window-based applications in Java. A chessboard was designed using this and images of pieces were added. Animations were also developed for movement of pieces. Once the main method validates the input move using the validation methods, it calls the animation method and gives it the parameters of the move to perform the same in the GUI. Then, the move is performed on the GUI. There are also profiles for each player where users can add their images. The color of the user’s name changes according to which side is to move next.

You can check out our code from this GitHub repository​.

Team

  • Akshay R Kulkarni
  • Archana Gahiwad

Mentors

  • Kartik Paigwar
  • Anish Gupta​