Live data from Hacker News

A step-by-step guide to building a simple chess AI

medium.com

31–40 of 44 posts

Re: A step-by-step guide to building a simple chess AI

#32
post #30
post #29

I'm very interested in the values assigned to pieces. Does anyone know the source or reasoning behind the table in step 2? How are pieces relative values calculated? What's to say a pawn is 1/3 of a rook or a knight? And why is the king 900, not simply the total value of all other pieces or slightly more? 8 pawns (10 ea), 2 knights (30 ea), 2 rooks (30 ea) and a queen (90) totals 290 points. Why can't a king simply b…

Check out this chess programming wiki article [1] for a (still fairly hand-wavy) rationale for similar piece values, and the Wikipedia article on chess piece relative values [2] for a more in-depth look at various weightings. Some modern approaches use analysis of a huge corpus of master games to come up with piece values, but many of the systems are based on intuition and empirical evidence. [1] https://chessprogram…

Good parent question and interesting links, thanks, will take a look.

To follow on though, shoukdn't it technically be the case that piece values should in theory fluctuate based on current situation.

For instance, my castle is worth zero to me if I'm throwing it so I can get you in check.

Will I know modern chess engines take this stuff into account. Mostly just a random thought.

Re: A step-by-step guide to building a simple chess AI

#33
post #30
post #29

I'm very interested in the values assigned to pieces. Does anyone know the source or reasoning behind the table in step 2? How are pieces relative values calculated? What's to say a pawn is 1/3 of a rook or a knight? And why is the king 900, not simply the total value of all other pieces or slightly more? 8 pawns (10 ea), 2 knights (30 ea), 2 rooks (30 ea) and a queen (90) totals 290 points. Why can't a king simply b…

Check out this chess programming wiki article [1] for a (still fairly hand-wavy) rationale for similar piece values, and the Wikipedia article on chess piece relative values [2] for a more in-depth look at various weightings. Some modern approaches use analysis of a huge corpus of master games to come up with piece values, but many of the systems are based on intuition and empirical evidence. [1] https://chessprogram…

Good parent question and interesting links, thanks, will take a look.

To follow on though, shoukdn't it technically be the case that piece values should in theory fluctuate based on current situation.

For instance, my castle is worth zero to me if I'm throwing it so I can get you in check.

Will I know modern chess engines take this stuff into account. Mostly just a random thought.

Re: A step-by-step guide to building a simple chess AI

#34
I recently wrote a chess AI in javascript, and found that it wasn't able to evaluate nearly as many moves per second as I expected, even though the implementation was pretty light (though not extensively optimized).

My feeling is that for serious AIs that need to perform huge tree evaluations (whether classical alpha-beta or something closer to monte-carlo minimum regret searches) there's several orders of magnitudes of optimization that can be performed, huge gains from subtle tradeoffs (larger static memory allocations, memory caching strategies, etc) and deep heuristics that can lead to pruning search spaces by huge percentages.

Highly tuned implementations such as these - or the graphics visualizations from the demo scene - have always fascinated me as an art form.

In practice, for most practical purposes, the industry seems to value more code for more features over the incredible feats of superimplementation.

Re: A step-by-step guide to building a simple chess AI

#36
post #35

Would anyone besides me like to step forward and admit they cannot even beat an opponent that makes random moves?

I'm not quite that bad at chess, but bad enough that I wrote a chess game that plays random moves so I could always beat it:

http://www.notesfromandy.com/2016/09/27/chessfidget/

That got boring, so I added very weak AI by connecting to the chess engine that comes preinstalled on macOS (inside Chess.app).

Re: A step-by-step guide to building a simple chess AI

#37
post #35

Would anyone besides me like to step forward and admit they cannot even beat an opponent that makes random moves?

I'm not quite that bad at chess, but bad enough that I wrote a chess game that plays random moves so I could always beat it: http://www.notesfromandy.com/2016/09/27/chessfidget/ That got boring, so I added very weak AI by connecting to the chess engine that comes preinstalled on macOS (inside Chess.app).

> connecting to the chess engine that comes preinstalled on macOS

Can you elaborate on this please? The presentation at your link doesn't say.

Re: A step-by-step guide to building a simple chess AI

#38
post #32
post #30

Earlier quoted context omitted.

Check out this chess programming wiki article [1] for a (still fairly hand-wavy) rationale for similar piece values, and the Wikipedia article on chess piece relative values [2] for a more in-depth look at various weightings. Some modern approaches use analysis of a huge corpus of master games to come up with piece values, but many of the systems are based on intuition and empirical evidence. [1] https://chessprogram…

Good parent question and interesting links, thanks, will take a look. To follow on though, shoukdn't it technically be the case that piece values should in theory fluctuate based on current situation. For instance, my castle is worth zero to me if I'm throwing it so I can get you in check. Will I know modern chess engines take this stuff into account. Mostly just a random thought.

> values should in theory fluctuate based on current situation

The author touched this a little bit with adding the position adjustments

> my castle is worth zero to me if I'm throwing it so I can get you in check.

I know what you mean, but castling into or through check isn't a legal move and shouldn't show up in your list of possible moves.

Re: A step-by-step guide to building a simple chess AI

#39
post #32
post #30

Earlier quoted context omitted.

Check out this chess programming wiki article [1] for a (still fairly hand-wavy) rationale for similar piece values, and the Wikipedia article on chess piece relative values [2] for a more in-depth look at various weightings. Some modern approaches use analysis of a huge corpus of master games to come up with piece values, but many of the systems are based on intuition and empirical evidence. [1] https://chessprogram…

Good parent question and interesting links, thanks, will take a look. To follow on though, shoukdn't it technically be the case that piece values should in theory fluctuate based on current situation. For instance, my castle is worth zero to me if I'm throwing it so I can get you in check. Will I know modern chess engines take this stuff into account. Mostly just a random thought.

> To follow on though, shoukdn't it technically be the case that piece values should in theory fluctuate based on current situation.

Yes. One common example is knights and bishops. Both are worth about 3 pawns, but knights are generally more useful in closed positions due to their ability to jump over pieces, while bishops are better in open positions since they can more attack and move long distances.

Re: A step-by-step guide to building a simple chess AI

#40
post #32

Earlier quoted context omitted.

Good parent question and interesting links, thanks, will take a look. To follow on though, shoukdn't it technically be the case that piece values should in theory fluctuate based on current situation. For instance, my castle is worth zero to me if I'm throwing it so I can get you in check. Will I know modern chess engines take this stuff into account. Mostly just a random thought.

> values should in theory fluctuate based on current situation The author touched this a little bit with adding the position adjustments > my castle is worth zero to me if I'm throwing it so I can get you in check. I know what you mean, but castling into or through check isn't a legal move and shouldn't show up in your list of possible moves.

Right, although I didn't mean castling into check. I meant tempting a greedy algorithm by throwing away a high value piece (which was always a weakness of early chess machines), although I realize the tree search would spot that.

Also now that I'm awake, read the article fully now.

Very cool, makes me want to try building one!

Post reply on HN