Mbates97402
Posts: 1
Joined: Thu Feb 13, 2014 5:49 pm

Tracking movement of game pieces on a board

Thu Feb 13, 2014 6:00 pm

So I only recently learned about Raspberry Pi, and love the idea, and have wanted to come up with a project to use it for. I've been thinking of making a chess board that would automatically track all the movements of the game and record them. I can't come up with a good idea on how to track the game pieces though. Anyone have any thoughts? I would like this to not be to expensive an idea.

moritzewert
Posts: 1
Joined: Thu Feb 13, 2014 9:08 pm
Contact: Website

Re: Tracking movement of game pieces on a board

Thu Feb 13, 2014 9:18 pm

You should take a look at OpenCV http://opencv.org wich is a computer vision library written in C, but with interfaces for Python, Java and objC. There are many tutorials and exmples on object tracking and opencv's documentation helpful.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Tracking movement of game pieces on a board

Fri Feb 14, 2014 11:22 am

Someone posted on the forum a long time ago, about trying a chess board with switches built in - one per square. Only one piece moves at a time, so it should be possible to keep track of them.

It may have been reed switches, meaning a magnet in each chess piece, but I can't remember (and can't find it now.)

Another possibility would be to use just one raspi camera and some clever software to recognise the pieces - or at least recognise which squares have pieces on them at any one time. That would in theory be cheaper as only one sensor is used, but it may need the camera mounting directly above the board and it would need a lot of work on the software.

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Tracking movement of game pieces on a board

Sat Feb 15, 2014 4:28 am

I would say the thing to do is to use an array of switches. As Ravenous said, only one piece moves at a time, and since you know where each piece starts, you should know where each piece is at any given time. You have a lot of options Reed switches or hall effect sensors to sense a magnet, tactile switches, photoresistors, or even continuity sensors could do what you're looking for. I'd recommend something digital, so probably not the photoresistor.

In order to not need to use port expanders, you will probably want to use some form of multiplexing to read which switches are pressed, and then scan the board every second or two. I haven't seen it, but I'm sure it's already been done to use Charlieplexing, similar to what you'll find in an LED cube or LED matrix. Wire one lead of each sensor in a column together, and the other lead to the row, so that you can apply a voltage to a column, and then read whether you have continuity in any given row. This way for any NxN board, you only need 2n GPIO pins, not N^2 pins.
Conveniently, a chess board is 8x8, which means that using this method, you need 16 GPIO pins, one less than the Pi's standard header has. That still leaves you one more for something like a light to use as a turn or timer indicator, or as a switch (e.g. reset) if you like. If you have a Rev. 2 board, there's a second header that you can solder in for an additional 4 GPIO pins in case you want more than one extra for your purposes.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Tracking movement of game pieces on a board

Sat Feb 15, 2014 9:36 am

Switch sensing seems the most promising approach, but could get relatively expensive with 64 switches/sensors.

You could easily pay >£1 per reed switch or hall-effect ic & magnet, taking the total >£64 just for sensing.
How about a PCB capacitive matrix and metal discs on the bottom of the pieces so that a piece in place couples signal between row and column pads? No moving parts. Mods to the pieces could be as simple as sticking a but of aluminium tape or a coin to the base of each one.

A Pi camera could well be cheaper, but more complex to program.
The simple method would be to measure the image contrast on each square and use board colours that contrast with both black and white pieces. Empty squares would be one colour with low contrast. Squares with pieces on them would be different contrasts.
You would have to watch out for hands blocking the view and causing detection errors, but that is probably tractable.

There are various options for identifying pieces by shape or marking, but that gets quite a lot more complex. A view from below through a glass board avoids problems of occlusion and you could consider OCR-like symbol detection or barcode / QRcode detection libraries to ID and locate pieces.


User avatar
perfo
Posts: 95
Joined: Mon Jan 30, 2012 2:42 am

Re: Tracking movement of game pieces on a board

Mon Aug 10, 2015 11:24 am

what about rfid's a small rfid in each chess piece then a coil under each square. The coils would have to be connected to then sampled so some sort of multiplexing would be needed or maybe have 64 inputs and try and read them in software. This isn't a highly thought out idea of mine :) but it would mean put a piece anywhere and you'd find it. knock a load over and you'd know where to put them...

maxchess42
Posts: 14
Joined: Thu May 23, 2013 1:11 pm
Location: Guildford, UK
Contact: Website

Re: Tracking movement of game pieces on a board

Tue Oct 13, 2015 10:06 pm

See http://www.chess.fortherapy.co.uk for a comprehensive description of how to build a chessboard with piece detection using reed switches. When bought in bulk on ebay reed switches are cheap and work reliably.
Pi A's, Bs, 2s, 3s & zeros 's in Birdboxes, Chess Sets, games, RuneAudio servers Arduinos everywhere else

See: http://www.chess.fortherapy.co.uk\

User avatar
perfo
Posts: 95
Joined: Mon Jan 30, 2012 2:42 am

Re: Tracking movement of game pieces on a board

Wed Oct 14, 2015 12:13 pm

The reed switch idea works of course but relies on a memory map in the controller to know where the pieces are it will know a piece is on this square but which piece is there will be unknown. Unless you could use maybe five reed switches under each square and identify the 32 pieces with a binary signature. Some chess games take days or even weeks so an absolute system would be better if possible IMO. I like the Qcode and camera idea PiGraham....

Slackware
Posts: 131
Joined: Mon Jan 18, 2016 3:45 pm

Re: Tracking movement of game pieces on a board

Sun Feb 14, 2016 3:12 pm

I think your best bet would be magnet on each piece, and a simple 8 x 8 wire loom. only intersecting wire point would be effected. Sort of how the old memory for computers were done running wire through a magnet. 64 pressure sensors would be an option, though my ivory chess set would need VERY sensitive ones.
You could do the read when chess clock is hit. one piece will be missing from known location, and a new one will have show up, OR there is a piece no longer on table. Special check for king swapping exception. As long as you track all pieces you can tell what one is which from where they are at. Or camera overhead snapshot, and some video processing. Fixed grid will make that fairly simple.

madutch
Posts: 1
Joined: Wed Oct 19, 2016 5:19 am

Re: Tracking movement of game pieces on a board

Wed Oct 19, 2016 5:27 am

Sorry to comment on an old thread but did you get this worked out?

I ran across the thread while looking for something similar and had a thought i wanted to impart.
Card Access Systems for building entry is exactly what you're talking about. just on a small scale.

Every person (a piece) has a card. which contains a small coil and chip with an identification code. No batteries!
Each door (or place on the board) has designation and a small reader..

seems to me that all these pieces are already the size you need and a prototype could be easily made from used equipment.

just thought is comment... cheers...

James

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Tracking movement of game pieces on a board

Wed Oct 19, 2016 7:18 am

I think the key idea is that the board is not fixed by a geometry of sensors, so that the board can take any form and pieces can be tracked on any position over the whole screen. I think that RFID coils or magnetic memory coils would limit that.

A new possibility has occurred to me. The digitizers used in graphics tablets or, presumably, Surface Pro tablets, locate a stylus to pixel accuracy over the entire screen. If the stylus device could be embedded in the paying piece it could be located wherever it was on the board. It might be possible to track multiple styli, or to disable all but one stylus (active player).
I don't know how large such a digitiser can be.

User avatar
karrika
Posts: 1072
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: Tracking movement of game pieces on a board

Wed Oct 19, 2016 11:12 am

Did you see the technique for reading the light under the peg? I actually did this for HeroQuest at Ropecon 2016.

viewtopic.php?p=1017452#p1017452

Now after the event I know a lot more. It is easier to read high intensities than low intensities. So by rapidly scanning for a playing piece in the possible locations for a turn you can easily detect where the playing piece is. Light to frequency chips are extremely small. If you have many pegs on the board at once then make the screen black under all the pegs except the one that has moved to a different location. The black pegs will transmit a very slow frequency so they will not interfere. The peg with a white spot under it will emit a very high frequency.

The next problem is what to use for transmission. 433MHz, IR, coloured LED, sound? For power a 3V 12mm battery works a very long time.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Tracking movement of game pieces on a board

Wed Oct 19, 2016 12:22 pm

[quote="karrika"]Did you see the technique for reading the light under the peg? I actually did this for HeroQuest at Ropecon 2016.

viewtopic.php?p=1017452#p1017452

Yes, nice job. We are digressing.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Tracking movement of game pieces on a board

Thu Dec 06, 2018 7:03 pm

Resurrecting this topic to post a link to an interesting device. A large format display which can sense game pieces. Not Pi related AFAIK.

https://www.smartboard-gaming.com/?fbcl ... MQYGt1af-o

Return to “Automation, sensing and robotics”