Pi Chess

Software


All code can be found at github

File descriptions

Chess_Main.py

Main Program to control the system.  At the moment it just plays very basic chess, with some save and load game functionality.

Chess_Hardware.py

Program used to test hardware.  It currently supports movement for player and pi and gets the players move.  Most of the code will be added to Chess_Main.py at a later date.

Gamestate.py

Class to hold the current game condition used by Chess_Main.py

McpBoard.py

Class to control the hardware e.g. the chessboard using a MCP23017 chip to expand the raspi's I/O ports. Used by Chess_Hardware.py

StockfishEng.py

Class to interact with stockfish program used by Chess_Main.py

Chessboard.py

ChessBoard v2.05 is created by John Eriksson - http://arainyday.se
Used for game logic


Hardware





Small stripboard to be fixed under each space under the chessboard, with a wiring harness to go between each board to build the matrix.  


Breadboard layout for testing of leds and reed switch matrix

Yes, breadboards can get messy!


The real breadboard

The development circuit is a 3 x 3 matrix of 9 LEDs and 9 reed switches.  This should be ok for testing the basic code to read the reed switches and light LEDs as needed.  I'm not sure that it would be possible to get all 64 LEDs and switches on this size of breadboard :-).


The development matrix circuit diagram

This is an easier to follow of the circuit used in development.  I have used schottky diodes to prevent key ghosting, and 330ohm resistors for the LEDs.  Not all 64 LEDs will be on at the same time, as the current draw on the MCP23017 and Pi could be too much.

These are the requirements for Raspbian


Install Stockfish

sudo apt-get install stockfish

Enable i2c

sudo apt-get install python-smbus

sudo nano /etc/modprobe.d/raspi-blacklist.conf
comment out the line blacklist i2c-bcm2708

sudo nano /etc/modules
Add i2c-dev to the last line

sudo reboot

Information taken from raspi.tv

Wiringpi2

sudo apt-get install python-dev python-pip
sudo pip install wiringpi2

Chessboard

Used for game logic
Download from pygame