A Chess Solitaire Clock

A year ago this month I returned as Editor of Texas Knights, the official publication of the Texas Chess Association.   And just last month, I signed up to play in an over-the-board (OTB) tournament in Arlington.  I thought I hadn't played in an OTB tournament for about 4 years.  But, after looking at my OTB games database, realized it has been literally 5 years this month since I had played in a tournament that wasn't online.   This may not have a lot of relevance to my Arduino programming activities ... but if I continue that story by saying that ... I got to thinking ... there isn't really a way to easily practice in a way similar to the way an OTB tournament works ... for example, you don't have an opportunity to stop a clock after you move ... or capture moves on a score sheet (although you certainly easily do so easily with a piece of paper and a writing instrument ... a pen, pencil, crayon, etc).  Heck, maybe even a Boogie Board or similar would be appropriate.  I will say I have a PlyCounter chess notion recording device, and if I'm going to practice tournament play, I'd be using it.  And, while I could certainly dig out a Chess clock and stop it for both players ... while playing an AI opponent on an e-Board ... wouldn't it be neat if I could create a device that would automatically stop the AI opponent's clock using some sort of motion detection when I move the opponent's piece (the only thing that would be different (and necessary ... unless you have an e-board that has self-moving capabilities than playing in an OTB tournament).  

 So, I set out investigating what I might need.   

 I started by thinking an LCD Module, a PIR Sensor and a button or two would probably work.   Then I started investigating a TM1638 module that has eight LEDs, eight buttons and basically eight 7-Segment displays ... and thought, both sides (White and Black) use four LEDs and four 7-Segment Displays and I'd have some flexibility with the eight buttons for controlling the device.   Then maybe a Touch sensor for the Stop Clock button and again a PIR Sensor (especially one that gave me the ability to adjust sensitivity) and may this could work.   I also decided an Arduino Nano would work for the brains of the device.

After weeks of building and testing the device, I think it actually works pretty well.

Below you see the Player's clock counting down. The dot between the minutes and seconds blinks.  All four LEDs above the clock indicate that it's white's turn to move.



Tapping the Touch Sensor stops the Player's Clock... and turns off the LEDs for White.  It then turns starts blinking the dots of the four right 7-segment display on/off and just one LED for Black is illuminated ... why just one?  ... there is a delay in allowing the Motion Sensor to pick up moving giving the Player time to record his last move.   

 
Once the delay ends ... all four of Black's LEDs will illuminate.  
 

Once the black piece is moved, the motion detector will see the movement, stop the black clock and start the white clock. 

I have added functionality by using the buttons to be able to select which color the player plays, change the clock time (range 5 minutes per game to 95 minutes per game),  movement check delay time (5 seconds to 15 seconds), ability to pause the clock, ability to save the default start clock minutes/seconds and movement check delay time (in EEPROM memory) and Reset (basically followed by selecting which side to play to start a new new game) and Reset to the preprogrammed start clock minute/seconds and movement check time (60 minutes/6 seconds and 10 seconds respectively) ... if you followed this by a Save, it would reset to default factory settings ... so-to-speak.  Note: The initial 6 seconds is just to allow a pause before starting the game if White is selected as the color the user plays (and since 1 second is subtracted before the clock is initially shown ...  so it would start with 5 seconds and start counting down).  If the player starts as the black , the value for seconds is set to 1 (but the movement check delay still starts with the defined delay ... giving the player a chance to make the opponents to get settled and prepare to make the first move for white). 

So, with the above in mind, all eight buttons, all eight LEDs and all eight 7-Segment displays are used on the TM1638.

I still need to print (and make use of) an enclosure for the TM1638, Arduino and possibly the Touch Sensor.  Although I haven't convinced myself yet that the Touch Sensor shouldn't be separate ...much like the PIR Sensor is.  

Just so you can see my USE CASE ... here's what I do:

First ... I have a Square Off Pro e-Board.  I like it for it's tournament size. I literally feels like playing in an OTB tournament. 

I use a driver for Deep Shredder 13 from Graham's Programs found here: https://goneill.co.nz/chess.php#eboard to allow control of Deep Shredder 13 with the Square Off Pro.  

The tournament I played in, and might do it more often, has a time control of 40G;d5 ... so I have to make all my moves in 40 minutes with a delay for each move of 5 seconds (so after my opponent stops his clock, my clock counts down 5 seconds then start removing actual time).  Chess Apps don't support delay ... they support adding time for very move .. this isn't really the same.    So, what I do is set the Chess Solitaire Clock to 40 minutes (because if I get used to that time ... I'll always have time left on my clock) ... I also set the clock in Deep Shredder 13 to 45 minutes (allowing for the Movement Check Delay).   I also turn off the  'Coach is Watching' feature ... because I don't want the program to wait for a response from me.   Note: I've also used Fritz 18 similarly.  Honestly, you can use pretty much any app you want or no app at all if the board supports playing without an app.   My goal is to not care about the application AI playing against me.  In fact, after I am setup to play in the application and start the game, my first move will kick off my clock in Deep Shredder 13, I don't have to see the computer/application from that point on (in my setup the computer is literally behind me and the screen goes blank after about a minute) the Square Off Pro show's me my AI Opponent's moves. 

So, I get my Plycounter setup up for a new game (for recording the moves ... again, a scoresheet and pencil or really anything that allows you to record moves will work), then I get the Solitaire Clock ready, and select which side I want to play.  Then ... I make the first move (for whichever side is playing White) ... and continuing playing 'til the end of the game. It's important to remember...   Make your move, stop the clock, record your move ... wait for your opponent to move (move piece for opponent is the only thing I wouldn't do in an actual tournament game) and record opponent's move ... and continue 'til game's end.   The Chess Solitaire Clock allows me to practice all of these actions. 

At the end of the game, if you are using an application for the AI, you should be able to save your game to a PGN file. You should also verify that you recorded the moves properly because you should want to bring home those recordings and study them for mistakes (analysis) ... and if you didn't record the moves properly, it's much harder to be able to study the games you played.  In addition, for example:  even with a Plycounter (or MonRoi, etc), while you think it would make things easier, they do allow you to make invalid moves (certified devices must not give you any advantage than what you would have recording with a scoresheet and writing utensil) ... so even with the electronic recording devices, it's possible to incorrectly record moves ... example ... move a pawn from the initial space and put it on top of one of your or your opponent's pieces ... moving diagonally without capturing a piece, etc.  So, it's important to get used to using one if you have it ... and if not, you still need to verify the accuracy of what you have written. The point here is the more comfortable you are with the process of stopping the clock and recording moves, the more you can focus on winning games!   

You can find the code to the Chess Solitaire Clock here:  https://github.com/arduinocodedog/CSClock



 




Comments

Popular posts from this blog

Fun with the SolidDigi Color Image LCD Shield

Parallax Smart Card Reader - Revisited

Parallax Smart Card Reader Samples for Arduino