Chess - Play & Learn


FREE - In Google Play

FREE - in Win Phone Store


Programming Chess #2

Nov 26, 2010, 4:35 PM 1

Time for those improvements I promised!

It's obvious that our program, Cirnovelty, doesn't have to consider every single series of moves to look three moves ahead. So we'll make the first improvement to our program, only slightly non-obvious:

Each position has a value (which we'll call its material worth) that represents Cirnovelty's estimated advantage in the game. We can determine the material worth of a position from the number of pieces each side has left, the number of moves available to each side, the pawn structure, etc...

When Cirnovelty looks ahead 3 moves, it only needs to examine moves that aren't obviously stupid, like ones that let the opponent take our queen. For example, it can only look at the most promising half of the positions each ply.

Right, I'm off the program all this- while you wait, here's a sort-of-puzzle.

I have an oracle that, given just a position in chess (including whether each side can castle and en passant and whatnot), will tell me which side wins with best play. The oracle tells me that the initial position is a win for white. Here's a program, written in pseudocode:

When it's my turn: {

 For each available move: {

  If the resulting position is a win, then make that move.


 If I haven't yet made a move: {

  Print "The oracle is inconsistent!"



What's wrong with this?

Online Now