Sunday, December 6, 2015

Clock Progress - Wood Cut for Case


The wood is all cut out for the clock case.  For this first attempt, I used some cheap 1/2 pine craft board from Lowes so I could make all of my mistakes at a low cost.   If this turns out, I may re-build it with some nicer wood.




Next is sanding, gluing and staining.  Then the lever mechanism and the electronics will be stuffed inside and I will have a real chess clock.

Saturday, November 14, 2015

Clock Progress - Lever mechanism for mechanical buttons

I have started working on my clock again.  Here is a picture of the lever mechanism for the mechanical buttons.   Magnets below each arm give the feel that the buttons are snapping into place.


Friday, September 4, 2015

Reasoning vs. Intuition

Two Types of Thinking

I divide the types of thinking that a chess player uses during a game into two categories:  Reasoning and Intuition.

Perhaps we should start with some definitions.


Reasoning

By reasoning, I mean the concrete calculation that goes on when a chess player is analyzing variations.  Reasoning is when a player is considering moves and consequences.  Reasoning is hard work.

Intuition

Intuition is the mode of thinking that relies on experience, gut feel, instinct, rules of thumb.  Intuition is not exact calculation; instead it is a feeling about a move or position.


How Computers "Think" while playing chess.

To explore the ideas of reasoning is and intuition, I first need to take a look at how computers are programmed to find moves.    This is an overly simplified explanation, but it covers the important points.

The computer first generates a tree of variations.  For my example, the computer will only look 2 moves deep for each player, and will only look at 2 moves at each branch.  In reality, the programs will look at more moves and will look deeper in positions that have forcing continuations.


Next the program will calculate a value that represents an evaluation of the position for each of the final positions.  This score will be based largely on the material balance, but also positional considerations.  For my example I just generated random values between -9 and 9.  A negative score is in Black's favor, and a positive score means White is better.


What follows next is called the Minimax algorithm.  Working from the final position backwards,  the program first calculates the score for the position after White's second move by choosing the minimum score of the two choices of moves for Black.  Then the program calculates the score for the position after Black's 1st move by picking the maximum score of the two choices of moves for White.  This happens two more times until all of the positions have a score.


By applying the Minimax algorithm, the program calculates that the best move White can make is the one marked 'a' above, which has a score of -3.  The alternative has a score of -6 which is even better for Black.   Black's best response to move 'a' is move 'b'.  White's best 2nd move is 'c', and Black's best second move is 'd'.


Now back to Human Thinking

I showed you all that in order to discuss how reasoning and intuition are used when humans play chess.

While generating the "tree of variations" in their heads, humans cannot possibly consider every move at every branch.  Only a limited number of moves can be considered, and to decide which, we use intuition.  Rules of thumb help, which guide use to look at checks, captures and treats.  Experience can play a role if the position is similar to other positions we have seen before.  And gut feel can guide us into considering certain moves.  Intuition also guides us in how deep we follow each line.  Much like with the computer program, we use the rule of thumb to look deeper into lines with forcing moves.

Evaluating the positions at the end of each branch also involves intuition.   We humans don't have the processing power to do a computer-like evaluation, but we can estimate how much we value differences in material, pawn structure, piece activity, weaknesses, etc.  Rules of thumb are useful for the material imbalances.  Instinct may tell us that piece activity may compensate for a weak pawn.

The human equivalent of the Minimax algorithm is where we use reasoning.  Visualizing the possible moves at each branch and assigning mental scores is where we can use pure calculation power.  As I mentioned above,  reasoning is hard work.  It takes mental discipline to do a thorough evaluation of the important moves and the opponent's replies.


The role of Time 

Reasoning also takes a lot of time.  You may notice that at long time controls, you will use reasoning much more than you do at 5 minute chess where it is mostly intuition.  Something else to consider is that your reasoning will often benefit by spending more time,  but your intuition will not.


Improving your Reasoning and Intuition

Reasoning is a skill, and is improved by practice.  Solving tactical positions and working through endgame studies are good ways to improve your reasoning.

Intuition is based in part on your knowledge and experience,  so reading books on strategy and playing over master games are good ways to improve intuition.









Saturday, May 23, 2015

Openings for Beginners


What opening should I play?

I see this question a lot on internet forums.  There are so many openings, with multiple paths and transpositions, it is no wonder beginners are confused.

General Advice

The advice most often given to beginners is to play the open games.  These are the openings that start with White playing 1.e4 and Black responding with 1...e5.  These openings are called the open games because there are usually pawns traded on the center squares resulting in open central files and diagonals.  With all these open lines, the pieces come into play quickly and it is often easy to figure out the best squares for your pieces.  Quick development, king safety, and the fight for the central squares are usually the main priorities of the open games.

All of the above tends to make the open games good for learning, but I think the best reason to play the open games is that when you lose, it will usually be easy to figure out your mistake because it will be punished tactically right away.  In the closed games, your positional mistake may not be exploited for another 10 moves, and the beginner will not be able to make the logical connection.

Who is the target audience of this advice?

The title says openings for beginners, and certainly anybody just learning to play chess should consider the opening advice listed below.  I would think players rated under 1200 should also be trying out these openings.  All the lines I give have been played by masters, so there is no need to worry that these lines are unsound.  If they suit your style you could play them as you progress up through ratings of 1600 to 1800.

I should also note that these recommendations are intended to maximize learning, not increase short term performance.  You may lose a higher percentage of games at first if you adopt these openings, but I am confident that your understanding will improve, and in the long term, so will your results.

Now for some specifics

To cut to the chase, I am recommending the Scotch Game, but using a modified move order.

The Scotch Game is usually reached by:

1. e4  e5
2. Nf3  Nc6
3. d4

when Black almost always plays  3...exd4




The move order I recommend is:

1. e4  e5
2. d4  dxe4
3. Nf3

and if Black responds with 3...Nc6, then we will have reached the same position.


  


Why this move order?

There are a couple of reasons why I recommend this particular move order.

  • Some of Black's best options are avoided with this move order (see notes below)
  • There are more opportunities for Black to make a mistake
Of course nothing comes for free, and Black will have a few options against this move order that are not available otherwise, but these are of little consequence.


What if Black doesn't play those moves?

That is a very good question.  I first want to show some lines in the Scotch Game, then I will give some advice on how to play if Black plays moves other than those that lead to the Scotch Game.

The Scotch Game

We will consider two main variations in the Scotch Game following these moves:

1. e4  e5
2. d4  exd4
3. Nf3  Nc6
4. Nxd4

Black will usually play either 4...Bc5 or 4...Nf6.   You will also need to prepare for 4...Qh4.   Beginners will sometimes play 4...Nxd4, but this should cause you no trouble.


Gambit options for White

White can choose not to re-capture the pawn on move 4.  There are some options where White can sacrifice a pawn to gain a lead in development with lots of open lines that may lead to an early attack.
4.Bc4 is the Scotch Gambit
4.c3 is the Goring Gambit.



When Black does not play 3...Nc6

These are some moves that Black may play instead of 3...Nc6
3...Nf6 is a variation of the Petroff Defense
3...d6 is a line in the Philidor Defense
3...Bb4+ and 3...Bc5 are options that are unique to this move order, but not problems for White.
3...c5 is sometimes played by beginners and is just bad for Black.


What if Black does not play 1...e5?

That will have to be another chapter.  In most cases, the idea of playing 2.d4 will be the right move, and against the Sicilian, you can follow up with 3.Nf3.


Summary

As White, I recommend beginning players aim for the Scotch Game (or possibly the Scotch Gambit) using the 2.d4 move order.   This will lead to positions that beginning players will be able to understand and learn from.  This last diagram is a summary of the lines discussed above.



Saturday, April 25, 2015

Thursday, April 23, 2015

Working Prototype

Here is my working Prototype

It is hard to get a good picture of the displays.





The clock on the left is counting down.  The button on the left is lit indicating which player is on the move.  I will try to post a video soon.


Making all of the wiring cables, and soldering everything to the perf board took a lot more time than I had expected.




Saturday, April 4, 2015

Plastic Prototype Enclosure


It is time to move off the breadboards and into the prototype in a box phase.   I bought a plastic storage box for about $4.  It is made from polypropylene which is easy to cut.  I drilled 1 inch holes in the bottom for the two lighted switches, and cut a large rectangle in the side for the displays.


This box is much larger than the final wood version will be.  The wood version will be shaped much more like a Chronos; a bit wider, lower and narrower, with a sloped front for the displays.  I also plan to use mechanical plungers instead of the buttons, but this will work for the prototype.  These buttons have an LED inside that I will use to indicate who is to move.  The sides of this box are transparent, so I won't have to open the box to show off the electronics inside.

Next step is to make wiring harnesses for the displays.  The headers on the displays have male pins spaced 0.1 inches.  This page has instructions for building the wiring harness.  Since the displays only use 12 of the 16 pins, and they are in groups of 6, I will likely use two 6 pin housings for each display.  I can get all the parts at the local electronics shop.

More pictures to follow.


Friday, March 27, 2015

It's a Clock !


I've got the basic clock sending time output to the displays.  The LEDs show who is on move, and the buttons switch the clocks and LEDs.



What is left to do (software):
- move counter
- increment and delay
- multiple periods
- Setup routine for setting time and choosing options using buttons
- save settings to non-volatile memory

What is left to do (hardware)
- switches (on/off and pause)
- 4 buttons for navigating the menus
- prototype case, probably plastic
- eventually a nice wooden case, with mechanical plungers.


Sketch Update

I modified the printTime() function to convert the time remaining for each player from 1/10 seconds to H:MM:SS and to write that to the displays, by calling a new writeNum() function.


// Function to write the time to the displays
void printTime() {                      // print time function
  int secDis1;
  int secDis10;
  int minDis1;
  int minDis10;
  int hrDis1;
  int secs;
  
  secs = timeR1 / 10;                  // convert 1/10 sec to H:MM:SS
  hrDis1 = secs / 3600;
  secs = secs % 3600;
  minDis10 = secs / 600;
  secs = secs % 600;
  minDis1 = secs / 60;
  secs = secs % 60;
  secDis10 = secs / 10;
  secDis1 = secs % 10;
  
  writeNum(hrDis1,3,1);
  writeNum(minDis10,7,1);
  writeNum(minDis1,10,1);
  writeNum(secDis10,14,1);
  writeNum(secDis1,17,1);
  
  secs = timeR2 / 10;                  // convert 1/10 sec to H:MM:SS
  hrDis1 = secs / 3600;
  secs = secs % 3600;
  minDis10 = secs / 600;
  secs = secs % 600;
  minDis1 = secs / 60;
  secs = secs % 60;
  secDis10 = secs / 10;
  secDis1 = secs % 10;
  
  writeNum(hrDis1,3,2);
  writeNum(minDis10,7,2);
  writeNum(minDis1,10,2);
  writeNum(secDis10,14,2);
  writeNum(secDis1,17,2); 
}




Part of the writeNum() function:




// function to write digits to the displays
void writeNum(int charDigit, int charPos, int turn){
   switch (charDigit){
      case 0:
         if (turn==1){
           lcd1.setCursor(charPos,0);
           lcd1.write(1);
           lcd1.write(2);
           lcd1.write(2);
           lcd1.setCursor(charPos,1);
           lcd1.write(3);
           lcd1.write(32);
           lcd1.write(3);
           lcd1.setCursor(charPos,2);
           lcd1.write(3);
           lcd1.write(32);
           lcd1.write(3);
           lcd1.setCursor(charPos,3);
           lcd1.write(3);
           lcd1.write(2);
           lcd1.write(4);
         }
         else{
           lcd2.setCursor(charPos,0);
           lcd2.write(1);
           lcd2.write(2);
           lcd2.write(2);
           lcd2.setCursor(charPos,1);
           lcd2.write(3);
           lcd2.write(32);
           lcd2.write(3);
           lcd2.setCursor(charPos,2);
           lcd2.write(3);
           lcd2.write(32);
           lcd2.write(3);
           lcd2.setCursor(charPos,3);
           lcd2.write(3);
           lcd2.write(2);
           lcd2.write(4); 
         }
         break;

and this continues for each of the 10 digits, plus a blank space if I want to use that later.

Thursday, March 26, 2015

Functioning Clock and BIG NUMBERS

Working Chess Clock

I now have a functioning chess clock.  Lots of work yet to be done, but the basic functions are all working.

I took the code from the earlier clock test, and changed it from sending the output to the serial port, to writing the time to the displays.  I also made the updates every 1/10 second.

This picture shows the two buttons and the green LEDs which indicate whose turn it is to move:


The buttons are wired to pins 2 and 3, with 10 K ohm pull-up resistors to +5V.  Closing the switch pulls the pin to ground.

The LED anodes are connected to pins 4 and 5, with 560 ohm resistors between the cathode and ground.  (similar to the schematics published earlier, but the pins have changed).

This next picture shows the display for player 2.  Note, it is counting down tenths of seconds.


I will attach the sketch at the bottom of this post.


Big Numbers

I also did some work on making large numbers for the time display.  (I don't know why this blog page insists on turning the image sideways, it is horizontal on my PC, but you can still see the large digits).



These large numbers were made by combining 7 custom characters.  The custom characters are numbered 0 through 7, but I used 1 through 7 because those were the numbers I used when I drew out the patterns on graph paper.  Note, if you use character 0, the data type must be declared something like this:  lcd.write((byte)0);   It has something to do with control codes vs. custom characters.  Luckily, since I used 1-7, I didn't run into this issue, but read about it on other web pages.

Some pieces of the sketch that created these large numbers:

#include <LiquidCrystal.h>
LiquidCrystal lcd1(6,7,9,10,11,12);
LiquidCrystal lcd2(6,8,9,10,11,12);

// create bit maps of the custom characters.  5 columns by 8 rows.
byte customChar1[8] = {
  B00000,
  B00000,
  B00000,
  B00000,
  B00011,
  B00011,
  B00011,
  B00011
};
.
.
.

void setup() {
   lcd1.begin(20, 4);
   lcd2.begin(20, 4);
   lcd1.createChar(1,customChar1);   //  assign the bitmap pattern to character 1
   .
   .
   .
}

void loop() {
   lcd1.setCursor(3,0);
   lcd1.write(1);     // write character 1
   .
   .
   .
}


And now, my most up to date clock sketch (from the photos at the top of this post):



//   
//  Chess Clock Practice Sketches
//
//  Bob Nolan
//  3/26/2015
//

// Include LCD display library and set up pinouts
#include <LiquidCrystal.h>
LiquidCrystal lcd1(6,7,9,10,11,12);
LiquidCrystal lcd2(6,8,9,10,11,12);

// Declare Global Variables
unsigned int timeR1;
unsigned int timeR2;
unsigned long lastMilliS;
int turn;
int ledPin1 = 4;
int ledPin2 = 5;
int switchPin1 = 2;
int switchPin2 = 3;
boolean checkButton;
boolean flag1=0;
boolean flag2=0;

void setup() {
  timeR1 = 150;                // set initial time.  Time is in 1/10 sec
  timeR2 = 150;                // need to add user input routine
  turn=0;
  pinMode(ledPin1,OUTPUT);
  pinMode(ledPin2,OUTPUT);
  pinMode(switchPin1,INPUT);
  pinMode(switchPin2,INPUT);
  lcd1.begin(20,4);
  lcd2.begin(20,4);
  lcd1.print("Player 1");
  lcd2.print("Player 2");
}

void loop() {  
 if (turn==0){              // dont start counting until 1st button press
    lastMilliS=millis();
 }
  if (millis()-lastMilliS >= 100) {   // every 100 msec, update time
    lastMilliS=millis();
    if((turn==1)&&(!flag1)){
      timeR1--;
    }
    if((turn==2)&&(!flag2)){
      timeR2--;
    }
    printTime();
  }
  checkButton=digitalRead(switchPin1);   // player 1 button press
  if(!checkButton && (turn!=2)){
    digitalWrite(ledPin2,HIGH);
    digitalWrite(ledPin1,LOW);
    turn = 2;
    printTime();
    
  }
  checkButton=digitalRead(switchPin2);   // player 2 button press
  if(!checkButton && (turn!=1)){
    digitalWrite(ledPin1,HIGH);
    digitalWrite(ledPin2,LOW);
    turn = 1;
    printTime();
   
  }
  if((timeR1<=0)&&(!flag1)){            // player 1 flag
    lcd1.setCursor(0,2);
    lcd1.print("Flag");
    flag1=1;
  }
  if((timeR2==0)&&(!flag2)){            // player 2 flag
    lcd2.setCursor(0,2);
    lcd2.print("Flag");
    flag2=1;    
  }
}

void printTime() {                      // print time function
   lcd1.setCursor(0,1);
   lcd1.print(timeR1);
   lcd1.print("  ");
   lcd2.setCursor(0,1);
   lcd2.print(timeR2);
   lcd2.print("  ");
}

Wednesday, March 25, 2015

More progress with the displays


I have both displays hooked up and working independently now, and like I had hoped, it only takes 7 output pins to drive both displays.

Here is how they are wired

LCD Pin Arduino Pin
1 Logic Gnd Gnd
2 Logic +5V +5V
3 Contrast Pot sweep
4 RS Pin 6
5 RW Gnd
6 EN (LCD1) Pin 7
6 EN (LCD 2) Pin 8
7
8
9
10
11 DB4 Pin 9
12 DB5 Pin 10
13 DB6 Pin 11
14 DB7 Pin 12
15 Backlight +5V +5V
16 Backlight Gnd Gnd

I used one potentiometer to control the contrast on both displays.  All of the connections go to both displays except the enable which has pin 7 going to display 1 and pin 8 going to display 2.

Sample Sketch

I used the following sketch to test that I had both displays wired correctly.  Notice that I had to define the pinouts for LCD1 and LCD2.


#include <LiquidCrystal.h>

LiquidCrystal lcd1(6,7,9,10,11,12);
LiquidCrystal lcd2(6,8,9,10,11,12);

void setup() {
  // put your setup code here, to run once:
lcd1.begin(20, 4);
lcd2.begin(20, 4);

 lcd1.print("Player 1");
 lcd2.print("Player 2");

}

void loop() {
  // put your main code here, to run repeatedly:
 lcd1.setCursor(0,1);
 lcd1.print(millis()/1000);
 delay(1000);
 lcd2.setCursor(0,1);
 lcd2.print(millis()/1000);
 delay(1000);
}

Tuesday, March 24, 2015

Phase 3 - Integrate the displays

Phase 3 has begun!



The displays arrived today.  First I soldered on the headers.  It has probably been 25 years since I did any precise soldering so it doesn't look like a professional job, but it works.  I tested each connection with my ohm meter to make sure I had a good contact and wasn't shorted to the next pin over.

Next I followed the tutorial from the Adafruit website to wire up the displays.  Then loaded the "Hello World" example.  I swapped the displays to make sure both were working correctly.  That was quicker than running another set of jumpers.

Next steps:
- update my clock sketch to send the time to the displays
- figure out how to do my custom characters for the large digits
- polish up the sketch and add delay, increment, and multiple periods
- create a setup routine so the time and other settings can be set with button presses

I'll post more updates as I make progress.

Tuesday, March 17, 2015

Displays have been ordered


Tonight I ordered two 4x20 LCD displays.



Also, here is a picture from the clock test.


Sunday, March 15, 2015

Clock Project - Progress Update


Phase 2 is moving along nicely.  I have completed all of the projects in the booklet that came with the Arduino kit, and have read all of the relevant chapters in the book Teach Yourself Arduino Programming in 24 Hours by Richard Blum, published by Sams.

Today I started writing and testing some clock code.  I built a simple circuit to test the code:  it has two push button switches, a green LED for each side to indicate whose turn it is, and a red LED for each flag.  The circuit looks something like this (drawn using the Fritzing program which can be downloaded at http://fritzing.org/home/).



Here is a schematic for the circuit:  (drawn using the website http://www.digikey.com/schemeit/# )



The switches are connected to pins 2 and 3 on the Arduino.  A 10 K ohm pull up resistor keeps the pin at 5 volts until the button is pressed which pulls the pin to ground.  In the code you will see that I have to initialize pins 2 and 3 for digital input.

Pins 8 and 9 are connected to the green LEDs and pins 10 and 11 are connected to the red LEDs.  These pins are configured for digital output.


And now... the program

The program, called a sketch is listed below.  It flows something like this:


  • Initialize the variables
  • Setup function that initializes the input and output pins and sets variable states (every sketch has to have this function)
  • Loop function (also required in every sketch)  executes in a never ending loop.  This is where the body of code is.  The basic parts of my code in the loop:
    • Don't start counting until the first button press
    • On a button press, light the correct LED, and assign the "turn" variable to the opponent
    • Check if 1000 milliseconds have gone by,  if so, call the subroutine to print the times to the serial port (can be monitored on the PC)
    • Check to see if either time is down to zero, if so, light the corresponding LED.
  • Any other functions.  I only have one, to print the time to the serial port.  Later, this is where the code to write to the LCD displays will live.
This is what the output looks like on the serial monitor screen:  
(for this example, each player has 15 seconds on their clock)

                                                                     (nothing happens until the 1st button press)
Player 1 button                                             (Green LED for player 2 lights)
2  Player 1 = 15  Player 2 = 15
2  Player 1 = 15  Player 2 = 14
2  Player 1 = 15  Player 2 = 13
2  Player 1 = 15  Player 2 = 12
2  Player 1 = 15  Player 2 = 11
Player 2 button                                             (Green LED for player 1 lights)
1  Player 1 = 15  Player 2 = 11
1  Player 1 = 14  Player 2 = 11
1  Player 1 = 13  Player 2 = 11
1  Player 1 = 12  Player 2 = 11
1  Player 1 = 11  Player 2 = 11
Player 1 button                                             (Green LED for player 2 lights)
2  Player 1 = 11  Player 2 = 11
2  Player 1 = 11  Player 2 = 10
2  Player 1 = 11  Player 2 = 9
2  Player 1 = 11  Player 2 = 8
2  Player 1 = 11  Player 2 = 7
2  Player 1 = 11  Player 2 = 6
2  Player 1 = 11  Player 2 = 5
2  Player 1 = 11  Player 2 = 4
2  Player 1 = 11  Player 2 = 3
2  Player 1 = 11  Player 2 = 2
2  Player 1 = 11  Player 2 = 1
2  Player 1 = 11  Player 2 = 0
Player 2 Flag                                                 (Red LED for player 2 lights)
2  Player 1 = 11  Player 2 = 0


Some thoughts and plans:


  • The way the code is written, if a player hits the clock using less than a second, he will not have any time come off his clock.  (like the old Master Quartz clocks).  I think think the best fix for this is to update the clock every 1/10 second.  I tested this and it worked fine, but the serial display filled up really fast, so I put it back to 1 second for this blog post.
  • The program continues to run after one player flags.  That players clock will not count down past zero, but if he hits his clock, the opponent's flag will count down, so that it is possible to have both players flag.  This is the correct behavior for USCF rules.
  • I will need to add code for common options:
    • Delay time before the clocks start to count
    • Increment time added each move
    • More than one time period
  • Once I get some LCD displays, I will need to write code for:
    • Choosing options and setting initial time
    • Displaying the time on the LCD displays.



Here is the sketch listing:

//   
//  Chess Clock Practice Sketches
//
//  Bob Nolan
//  3/15/2015
//

// Declare Global Variables
unsigned int timeR1;
unsigned int timeR2;
unsigned long lastMilliS;
int turn;
int ledPin1 = 8;
int ledPin2 = 9;
int switchPin1 = 2;
int switchPin2 = 3;
int flagPin1 = 10;
int flagPin2 = 11;
boolean checkButton;
boolean flag1=0;
boolean flag2=0;

void setup() {
  Serial.begin(9600);
  timeR1 = 15;                // set initial time
  timeR2 = 15;                // need to add user input routine
  turn=0;
  pinMode(ledPin1,OUTPUT);
  pinMode(ledPin2,OUTPUT);
  pinMode(switchPin1,INPUT);
  pinMode(switchPin2,INPUT);
  pinMode(flagPin1,OUTPUT);
  pinMode(flagPin2,OUTPUT);
}

void loop() {  
 if (turn==0){              // dont start counting until 1st button press
    lastMilliS=millis();
 }
  if (millis()-lastMilliS >= 1000) {   // every 1000 msec, update time
    lastMilliS=millis();
    if((turn==1)&&(!flag1)){
      timeR1--;
    }
    if((turn==2)&&(!flag2)){
      timeR2--;
    }
    printTime();
  }
  checkButton=digitalRead(switchPin1);   // player 1 button press
  if(!checkButton && (turn!=2)){
    digitalWrite(ledPin2,HIGH);
    digitalWrite(ledPin1,LOW);
    turn = 2;
    Serial.println("Player 1 button");
    printTime();
    
  }
  checkButton=digitalRead(switchPin2);   // player 2 button press
  if(!checkButton && (turn!=1)){
    digitalWrite(ledPin1,HIGH);
    digitalWrite(ledPin2,LOW);
    turn = 1;
    Serial.println("Player 2 button");
    printTime();
   
  }
  if((timeR1<=0)&&(!flag1)){            // player 1 flag
    digitalWrite(flagPin1,HIGH);
    Serial.println("Player 1 Flag");
    flag1=1;
  }
  if((timeR2==0)&&(!flag2)){            // player 2 flag
    digitalWrite(flagPin2,HIGH);
    Serial.println("Player 2 Flag");
    flag2=1;    
  }
}

void printTime() {                      // print time function
   Serial.print(turn);                  
   Serial.print("  Player 1 = ");
   Serial.print(timeR1);
   Serial.print("  Player 2 = ");
   Serial.println(timeR2);
}

Tuesday, March 10, 2015

The Arduino has arrived



The Arduino experimenter's kit arrived today. 




I loaded the software without much trouble.  The only issue I had was the software recognized the Arduino was plugged into COM 3, but it was trying to write the program to COM 1.  This may have been due to having two instances of the software open.  After I closed one of them, it has worked ever since.

I built the first project from the booklet:  Making an LED blink.  I guess this is the "Hello World" program of the Arduino world.


So far this is going much more smoothly than I had hoped.   I will try to do a project each evening.  That should give me a good start at writing the chess clock program.


Monday, March 2, 2015

Building My Own Chess Clock


I now own 3 digital chess clocks:
  • DGT North American
  • DGT Easy Plus
  • Duel Timer
Each of them has drawbacks.  For instance, the DGT North American does not show the delay seconds counting down,  The Easy Plus cannot do more than one time period, and the Duel Timer only indicates whose turn it is to move on the display (no light or mechanical button).


So as an Engineer, I figure I can make something that can address all of these issues.  This is likely to become a massive project, so I will break it down into manageable chunks.


Phase 1 - Choose a Microcontroller

Based on what I have found on the interwebs, I am looking at the Arduine Uno R3.   Everything needed is onboard, just plug in and start programming.  Here are the specs:

MicrocontrollerATmega328
Operating Voltage5V
Input Voltage (recommended)7-12V
Input Voltage (limits)6-20V
Digital I/O Pins14 (of which 6 provide PWM output)
Analog Input Pins6
DC Current per I/O Pin40 mA
DC Current for 3.3V Pin50 mA
Flash Memory32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM2 KB (ATmega328)
EEPROM1 KB (ATmega328)
Clock Speed16 MHz
Length68.6 mm
Width53.4 mm
Weight25 g


Phase 2 - Learn to program the microcontroller

I can get the Arduino as with a starter kit that includes enough components and instructions for some first projects.  Plus there a lot of tutorials and videos on the web with instructions.  Failing that, I might even read some books.   It shouldn't take too long for me to be able to write the code for an elementary count down timer that switches to the other counter when a button is pressed.


Phase 3  -  Integrate the Displays

Right now I am looking at the HD4470 20x4 LCD display, one for each side.
The 8 custom characters would allow me to design a segmented display that would use 3 lines for the time H:MM:SS and the 4th line for information such as delay countdown (or increment), period, and move counter.  I mocked up something with only 5 custom characters that might look like this:



This display can be controlled with just 6 digital lines, one of which is the enable.  If I understand correctly, I could control 2 displays with just 7 lines, with a unique enable going to each display, and the rest of the data going to both.


Phase 4 -  Build the Case

For the first attempt, I will probably just use a clear plastic box, some large buttons and LEDs to indicate which player to move.  That would leave me 3 more digital pins to add Pause, and setting buttons.

The ultimate goal is to make a nice wooden body with mechanical buttons that click into place, just like my wife's nice Jerger analog clock.


Pressing the Start Button

Publishing my thoughts here forced me to spend some time thinking about what I would need and doing some research.  It also gives both my readers a chance to guide me back to the right path if I am starting out in the wrong direction.  So now is your chance; leave me some comments.

I'll publish some future posts with status reports and pictures as I make progress.











Sunday, March 1, 2015

Position Evaluation Criteria




A while back, I started compiling categories of position evaluation criteria as expressed by various authors. Here is the list based on the books in my library. I am curious as to what other authors (and readers of this blog) have to say on the subject.





Aleksander Kostyev, 40 Lessons for the Club Player
    Evaluation Principles:
  1. Material Balance
  2. Threats
  3. King Safety
  4. The Center
  5. Open Lines
  6. Active Pieces
  7. Pawn Structure Defects




Samuel Reshevsky, The Art of Positional Play
    Chapters:
  1. Weak Pawns
  2. Passed Pawns
  3. King Position
  4. Space
  5. Open Lines
  6. Tactics
  7. Good and Bad Pieces



Max Euwe, The Development of Chess Style
    Steinitz Theory, Characteristics:
  1. Lead in Development
  2. Superior Mobility
  3. Occupation of the Center
  4. Unsafe King Position
  5. Weak Squares
  6. Pawn Structure
  7. The Queenside Majority
  8. Open Files
  9. The Advantagbe of the Two Bishops
  10. Material Preponderance



Jeremy Silman, How to Reassess Your Chess
    Imbalances:
  1. Superior Minor Piece
  2. Pawn Structure
  3. Space
  4. Material
  5. Control of Key Squares
  6. Lead in Development
  7. Initiative



Gary Kasparov, Interview with Brian Readhead, Kasparov's Winning Chess Moves
    Dimensions:
  1. Material
  2. Time
  3. Quality



Johathan Rowson, Chess for Zebras
    Dimensions:
  1. Material
  2. Opportunity
  3. Time
  4. Quality



Dan Heisman, Elements of Positional Evaluation
    Elements:
  1. Mobility
  2. Flexibility
  3. Vulnerability
  4. Center Control
  5. Piece Coordination
  6. Time
  7. Speed


    Pseudo-Elements:
  1. Material
  2. Space
  3. King Safety
  4. Development



Aron Nimzowitsch, My System
    Elements:
  1. The Center and Development
  2. Open Files
  3. The Seventh and Eighth Ranks
  4. The Passed Pawn
  5. Exchanging
  6. Elements of Endgames
  7. The Pin
  8. Discovered Check
  9. The Pawn Chain



Ludek Pachman, Modern Chess Strategy
    Factors: (that determine the character of a position)
  1. Material Relationship
  2. Power of the individual pieces
  3. Quality of the individual pawns
  4. Position of the Pawns, Pawn Structure
  5. The Position of the Kings
  6. Co-operation amongst the Pieces and Pawns



CJS Purdy, paraphrased by Ralph J. Tykodi, CJS Purdy's Fine Art of Chess Annotation and Other Thoughts
    Key Features:
  1. Material
  2. King Position
  3. Weaknesses

    • Weak Pawns / squares
    • Pawn moved in front of the castled king
    • Confined pieces
    • cramped game
    • backward development

  4. Strengths

    • Well Posted Pieces
    • More Space
    • Greater elasticity, mobility, freedom
    • Control of Center

  5. Development
  6. Breakthrough Points



Larry Evans, New Ideas in Chess

  1. Space
  2. Time
  3. Force
  4. Pawn Structure






Conclusions:



After giving this some thought, I have concluded that these ideas fall into 3 different groups:


  1. Categories of Evaluation

    • Material - includes minor piece imbalances
    • King Safety
    • Pawn Structure - includes the center, and any weak pawns or weak squares
    • Piece Activity - includes mobility and development
    • Threats

  2. Units of Measurement

    • Relative Piece Value
    • Force
    • Space
    • Time

  3. Basis for Evaluation

    • Activity - Which I define as useful mobility that can generate threats
    • Vulnerability - Something (piece, pawn, square) that has value, can be attacked and is underdefended.
    • Flexibility - Multiple options for improving the position or responding to threats.


Extreme Example: Checkmate. The winning player has superior activity aimed at the enemy king. The losing player has a vulnerable king, and lacks flexibily to respond to the threats.

When I evaluate pawn structure, I may notice an isolated pawn. By itself, I cannot say if the isolated pawn is good or bad. It can only be evaluated in terms of:

  • Activity: Do the pieces gain activity due to the open files on either side of the isolated pawn?
  • Vulnerability: Can the pawn be attacked? Can it be defended?
  • Flexibility: Can the pawn be advanced? Blockaded?


What do you think about these ideas?


Sunday, February 15, 2015

Data Visualizations by Randy Olson



I just ran across Randy Olson's blog where he does data visualizations.   Info about Randy Olson from his blog:


Randy is a PhD candidate in Michigan State University's Computer Science program. As a member of Dr. Chris Adami's research lab, he studies biologically-inspired artificial intelligence and evolutionary processes.


He published a series of 4 blog articles with data visualizations of chess topics.


  1. Chess tournament games and Elo ratings 
  2. A data-driven exploration of the evolution of chess: Game lengths and outcomes
  3. A data-driven exploration of the evolution of chess: Popularity of openings over time
  4. A data-driven exploration of the evolution of chess: Moves, captures, and checkmates

Sunday, February 8, 2015

Opening Names - Tree Diagrams


What is the deal with opening names?

There are sequences of opening moves that are played over and over again.  This is because the moves make sense in accomplishing the goals of the opening.  These goals are:
  • Develop the pieces off the back rank and into the game
  • Fight for the center of the board
  • Castle your king into safety

The names of openings have been assigned pretty much by accident over history.  Openings can be named after:
  • The first player who popularized the opening
  • The city or country where the opening was first popular
  • A descriptive name of the what is happening on the board

Do I need to learn all of the opening names?

No, you don't need to learn the names of all of the openings, but you should probably learn the names of the openings you play.  The best way to do this is to write down the moves of your next game (if you are playing online, most servers will record the moves for you).  After the game, look up the moves on the tree diagrams below and try to find the name of the opening you just played.  If the moves you played do not have a name, you may have been playing inferior moves and should consider one of the moves from the diagram instead.

Once you know the name of the opening you play, you can search on the internet for more information about that opening.  There are even videos that explain the finer points of each opening.


And now, the tree diagrams

I couldn't fit all of the openings on one diagram, so I broke them up according to the common classification system, which is explained in the first diagram.  Note:  There are many other openings that I did not include here.  These are either very rarely played anymore, or are not suited for improving players.








Next Steps

Now that you know the name of the openings you like to play, you can make your own tree diagrams showing the variations and sub-variations of those openings.  There are plenty of internet resources to guide you.  Old school players like me still read about the variations in books.

You should also plan to spend some time learning about the openings your opponents might use to prevent you from playing your opening,  For example, suppose you like to play the Scotch opening as White.   From the diagrams, you will notice that Black does not have to follow the path that leads to the Scotch.  After 1.e4 e5,  2.Nf3 Black does not have to play 2...Nc6.   Black can choose to play 2...Nf6 (Petroff Defense) or 2...d6 (Philidor Defense) instead.  Also, Black does not have to reply with 1...e5, but could choose any of the Semi-Open defenses instead.

I enjoy learning about the openings and I hope this information will help you get started improving your opening play.


Monday, January 26, 2015

A Recent Correspondence Game


This is a correspondence game I recently played on Chessworld.net.

The final position is very similar to the Damiano's mate I give in an earlier post.

Saturday, January 24, 2015

Thoughts on Opening Repertiore Choices


Why have a specific opening repertoire?
  • To specialize in a limited set of openings
  • To minimize the amount of study required
Why have I chosen to have to have 2 sets of opening choices?
  • Because my objectives differ when playing higher or lower rated opponents
  • To get exposure to a larger set of opening ideas and positions
  • To avoid boredom and stagnation
  • To have a back-up plan in case my opponent is prepared for my opening
Objectives against higher rated players.
  • To paraphrase Simon Webb -  The tiger must lead the elephant into the swamp.
  • Maximize my tactical chances
  • Unclear / dynamic positions
  • Drawish lines OK – especially forcing tactical lines
  • All pawn structures, including IQP
  • Stay in book.  I want them to leave book worried about my prepared lines.
Objectives against lower rated players.
  • The tiger waits for the rabbit to make a mistake
  • Minimize my opponent's tactical chances
  • Strategically sound positions
  • Avoid drawish lines
  • Avoid symmetrical pawn structures
  • Avoid pawn weaknesses
  • Get them out of their prepared lines.

Thursday, January 22, 2015

Chess Graphs: Risk vs. Reward



How to play against lower rated players

I have been given conflicting advice on how to play lower rated players.  On the one hand, a strong master told me I should play the sharpest tactical opening lines, and try to blow my lower rated opponent out of the water as quickly as possible.

On the other hand, I get this advice from the book Chess for Tigers by Simon Webb.

"Do you know how Tigers catch Rabbits?  Do they rush after them and tear them limb from limb?  Or do the stalk them through the bush before finally creeping up on them when their resistance is low?"

My personal experience has lead me to believe the  2nd approach makes more sense.  When I play complicated forcing moves against my lower rated opponents, I often just put them in a position where they must find the one move that doesn't lose, and they sit there until they find it.  In effect, I am forcing them to play good moves.  When I play less forcing moves (still strong moves, just less forcing) I sometimes give my lower rated opponents more chances to make positional errors that I can exploit later.


Now for the Graphs

Imagine if I were to make a scatter plot of chess games.  On the x axis would be a measure of the risk involved in the chosen moves (I'm not sure how I would measure this, but sacrifices and gambits would be on the high end of the scale).  On the y axis would be a measure of the outcome of the games, from loss to win, perhaps measured by computer evaluations of the final positions.

That graph might look something like this:


For two equally rated players, I would expect all of the data points to fall between the two dashed lines.  Notice that when neither player takes much risk, a draw is a likely result.  As either player increases the risk, however, the chance of a win or loss increases.

Now consider games where one player is much higher rated than the other.  By much higher rated, I mean at least 200 rating points higher (you would expect the higher rated player to score 75% ).  I expect the shape of the points to be about the same, just shifted higher.


Looking at this graph, I would conclude that the higher rated player has almost no chance of losing the game if the risk level stays low.  As the risk level increases, the chances of winning increase slightly, but so do the chances of losing. 

There is a phrase used by strong players when referring to a situation where one player is controlling the risk level of the game in order to avoid a loss.  They say the player is "playing for 2 results."  Those results being a win or a draw.  If there is some risky play (a sacrifice perhaps), the player is "playing for all 3 results."


How to play against higher rated players

So if the higher rated player wants to minimize the risk involved, the opposite must be true for the lower rated player.  Looking at the graph, it appears the only chance the lower rated player has is to maximize the risk level.

Once again, I quote Simon Webb:

"The basic principle is to head for a complicated or unclear position such that neither of you has much idea what to do, and hope that he makes a serious mistake before you do.  Of course you are still more likely to lose than to win, but by increasing the randomness of the result you are giving yourself more chance of a 'lucky' win or draw."

 He then gives some pointers for increasing the risk level against higher rated players.  (I am paraphrasing):
  1. Choice of Opening -  Sharp theoretical lines and gambits.
  2. Play actively-  Aggressive attacking play, even if that means sacrificing a pawn or two.
  3. Randomize - Create unclear and unbalanced positions; complications that can't be figured out over the board.
  4. Don't swap everything off -  Strong players are better in the endgame, so keep the pieces on the board and stay in the middle game.
  5.  Be brave - Your opponent is higher rated so you have nothing to lose.

Conclusion

My tournament experience has convinced me that this is the correct advice.  Against a lower rated player, I accumulate small advantages and trade down to a winning endgame.   My games may last a long time, but I win a very high percentage of them.  Against higher rated players, I throw everything I have at them, often in a caveman like style, but I have some nice upsets as a result.

In a future post, I will show how I changed my opening repertoire to take this advice into account.





Monday, January 19, 2015

Types of chess "rules"


As I am reading about chess, I come across many types of advice and information that are called "rules". Here I have classified them into 5 groups. I would like to hear your opinion about this classification and some examples of "rules" that do or do not fit into this classification.

1. Rules of the game. What FIDE calls the Laws of Chess. These are the rules that govern how the pieces move and capture, how castling is performed, pawn promotion, etc. These rules are the same for OTB, correspondence or blitz chess.

2. Tournament rules. These would be rules that govern how pairings are done, the use of the clock, notation requirements, claiming draws, etc. These rules differ according to the type of competition. Correspondence rules differ from OTB and blitz.

3. Rules of strategy. What I am thinking here would be the fundamental rules that guide decisions of strategy. This would include the relative value of the pieces, the advantage of two bishops in an open position, rooks behind passed pawns in the endgame. Rules in this category would be expected to have few exceptions. If they had zero exceptions, and could be assumed to be true without further proof, we would call them axioms. Can anybody give an example of an axiom of chess strategy?

4. Rules of thumb. These would be rules that have so many exceptions that they must be considered only as rough guidelines. Knights before bishops is a good example. Some in this category might be called parables: for example the story of the man who left his inheritance on the condition that his son never captured a b-pawn with his queen.

5. Rules about how to think. Not specifically about strategy, but more about how to manage your own thought processes. Kotov's tree of analysis for example. Or the advice: If you see a good move, look for a better one.

Have I missed any categories of rules? Do you have examples that do not fit into these categories? What are your favorite rules?

How to Lose at Chess - Checkmate Patterns


Checkmate Patterns


Pattern recognition is an important skill for losing at chess.  The following examples show checkmate patterns that you can try to emulate in your games.  Let us hope your opponent knows these patterns too.

Back Rank Mate

The most common mating pattern occurs when one player leaves the back rank unprotected, and the king has no escape square.

In the diagram below:  White to move wins with 1.Qa8#

If you have the white pieces a good way to lose is to make a useless move with your queen, such as 1...Qa7.   Then Black wins using the back rank mate pattern with 2...Rd1#.



Damiano's Mate

This partial diagram shows the final position of Damiano's mate. 




If Black could reach the next position, White could force checkmate in 5 moves.  (Hint:  Eliminate the rooks with check to get the queen on the h-file.)



If you have the white pieces, you can lose by making a useless move such as 1.Rh2 allowing Black to mate you using Damiano's mate.



Anastasia's Mate

This partial diagram shows the final position of Anastasia's mate.



The following position comes from the novel Anastasia and Chess by W. Heinse in 1803.  From this position, White would be able to force mate in 3 moves.



Boden's Mate

This partial diagram shows the final position of Boden's mate.



If Black could reach the following position, White could force mate in 2 moves.



You should try to create positions like this where your opponent can sacrifice a piece to expose your king.


Smother Mate

This partial diagram shows the final position of a smother mate.



If Black could reach the following position, White could force mate in 5 moves.


I will leave it as an exercise for the reader to find a move for White that would allow a back rank checkmate.


How to Lose at Chess - Introduction

How to Lose at Chess - Losing by Checkmate