Evaluation as a composite

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 3:48 am

Re: Evaluation as a composite

Post by kbhearn » Tue Sep 05, 2017 10:20 am

Nothing wrong with partitioning a long function into distinct subfunctions and then call them in sequence in the main eval. Some would even call it a good practice to do so - but what you linked has nothing to do with that.

Henk
Posts: 5904
Joined: Mon May 27, 2013 8:31 am

Re: Evaluation as a composite

Post by Henk » Tue Sep 05, 2017 10:32 am

kbhearn wrote:Nothing wrong with partitioning a long function into distinct subfunctions and then call them in sequence in the main eval. Some would even call it a good practice to do so - but what you linked has nothing to do with that.
I also would put these sub functions in separate files. File Explorer will provide the index I'm looking for to lookup them easily without much scrolling.

Henk
Posts: 5904
Joined: Mon May 27, 2013 8:31 am

Re: Evaluation as a composite

Post by Henk » Tue Sep 05, 2017 11:18 am

Alternative is a search factory that creates a search for a robot with an evaluation state using an evaluation strategy (composite) that updates its behavior depending on the position.

I want two robots playing chess with different evaluation strategies and see which one plays best.

So you need two evaluations.

Henk
Posts: 5904
Joined: Mon May 27, 2013 8:31 am

Re: Evaluation as a composite

Post by Henk » Tue Sep 05, 2017 2:24 pm

This game being played using the design patterns mentioned. Both using same end game evaluator.

Difference is White using Material + CenterControl and Black Material + CenterControl +- Random(20cp)

You see everything kept minimal. See what happens if it gets more complicated. Otherwise I take the functional approach.

[Something wrong with generated pgn for some data displayed in bright blue]

[pgn]
1. e2-e3 { 0.167 0.00 } { }
1. Ng8-f6 { 0.167 0.00 } { }
2. Nb1-c3 { 0.164 0.00 } { }
2. d7-d5 { 0.164 0.00 } { }
3. f2-f4 { 0.162 0.00 } { }
3. d5-d4 { 0.162 0.00 } { }
4. Nc3-e2 { 0.159 0.00 } { }
4. Nb8-c6 { 0.159 0.00 } { }
5. e3-d4 { 0.156 0.00 } { }
5. Nc6-d4 { 0.156 0.00 } { }
6. c2-c3 { 0.154 0.00 } { }
6. Nd4-c6 { 0.154 0.00 } { }
7. d2-d4 { 0.151 0.00 } { }
7. Ke8-d7 { 0.151 0.00 } { }
8. d4-d5 { 0.149 0.00 } { }
8. Nc6-a5 { 0.149 0.00 } { }
9. Ne2-g3 { 0.146 0.00 } { }
9. Kd7-d6 { 0.146 0.00 } { }
10. b2-b4 { 0.144 0.00 } { }
10. Qd8-e8 { 0.144 -0.02 } { }
11. b4-a5 { 0.141 0.01 } { }
11. e7-e5 { 0.141 -0.03 } { }
12. d5-e6 { 0.139 0.04 } { }
12. Nf6-d5 { 0.139 -0.06 } { }
13. c3-c4 { 0.137 0.06 } { }
13. Qe8-e6 { 0.137 -0.06 } { }
14. Ng1-e2 { 0.134 0.06 } { }
14. Rh8-g8 { 0.134 -0.06 } { }
15. Qd1-d3 { 0.132 0.06 } { }
15. Ra8-b8 { 0.132 -0.06 } { }
16. Ng3-e4 { 0.130 0.06 } { }
16. Kd6-d7 { 0.130 -0.06 } { }
17. c4-d5 { 0.129 0.07 } { }
17. Qe6-e8 { 0.128 -0.08 } { }
18. Qd3-h3 { 0.126 0.08 } { }
18. Kd7-d8 { 0.126 -0.08 } { }
19. Qh3-h7 { 0.124 0.08 } { }
19. g7-g6 { 0.124 -0.08 } { }
20. Ne4-d2 { 0.121 0.08 } { }
20. Bf8-g7 { 0.121 -0.08 } { }
21. Ra1-b1 { 0.119 0.08 } { }
21. Bc8-d7 { 0.119 -0.08 } { }
22. Rb1-b4 { 0.117 0.08 } { }
22. c7-c6 { 0.117 -0.08 } { }
23. Rb4-e4 { 0.115 0.08 } { }
23. Qe8-f8 { 0.116 -0.08 } { }
24. Bc1-a3 { 0.114 0.08 } { }
24. Rg8-h8 { 0.114 -0.08 } { }
25. Ba3-f8 { 0.112 0.08 } { }
25. Rh8-h7 { 0.112 -0.08 } { }
26. Bf8-g7 { 0.110 0.08 } { }
26. Rh7-g7 { 0.110 -0.08 } { }
27. Ne2-c3 { 0.108 0.08 } { }
27. f7-f5 { 0.108 -0.08 } { }
28. Re4-b4 { 0.106 0.08 } { }
28. c6-d5 { 0.106 -0.08 } { }
29. Nc3-d5 { 0.104 0.08 } { }
29. Bd7-e6 { 0.104 -0.08 } { }
30. Rb4-d4 { 0.103 0.08 } { }
30. Rg7-d7 { 0.103 -0.08 } { }
31. Bf1-c4 { 0.101 0.07 } { }
31. Rb8-c8 { 0.101 -0.07 } { }
32. Nd2-b3 { 0.099 0.07 } { }
32. Rc8-c4 { 0.099 -0.06 } { }
33. Rd4-c4 { 0.098 0.06 } { }
33. Rd7-d5 { 0.098 -0.07 } { }
34. h2-h4 { 0.096 0.06 } { }
34. Rd5-d7 { 0.096 -0.06 } { }
35. Rc4-b4 { 0.094 0.06 } { }
35. Be6-d5 { 0.094 -0.07 } { }
36. Rh1-h2 { 0.093 0.06 } { }
36. Rd7-e7 { 0.093 -0.06 } { }
37. Ke1-d1 { 0.091 0.06 } { }
37. Re7-e6 { 0.091 -0.06 } { }
38. Rb4-d4 { 0.090 0.07 } { }
38. Re6-d6 { 0.090 -0.07 } { }
39. Nb3-d2 { 0.088 0.07 } { }
39. Kd8-e7 { 0.088 -0.07 } { }
40. Rd4-b4 { 0.087 0.06 } { }
40. Bd5-a2 { 0.087 -0.06 } { }
41. Rb4-b7 { 0.085 0.06 } { }
41. Rd6-d7 { 0.085 -0.07 } { }
42. Rb7-d7 { 0.084 0.06 } { }
42. Ke7-d7 { 0.084 -0.07 } { }
43. a5-a6 { 0.083 0.06 } { }
43. Kd7-c8 { 0.083 -0.07 } { }
44. Rh2-h1 { 0.081 0.07 } { }
44. Ba2-d5 { 0.081 -0.06 } { }
45. Nd2-f3 { 0.080 0.06 } { }
45. Bd5-a8 { 0.080 -0.06 } { }
46. Rh1-h3 { 0.078 0.06 } { }
46. Ba8-c6 { 0.078 -0.06 } { }
47. Rh3-g3 { 0.077 0.07 } { }
47. Bc6-e8 { 0.077 -0.07 } { }
48. Nf3-e5 { 0.076 0.08 } { }
48. Be8-b5 { 0.076 -0.07 } { }
49. Rg3-g6 { 0.075 0.07 } { }
49. Bb5-a4 { 0.075 -0.07 } { }
50. Kd1-d2 { 0.073 0.08 } { }
50. Ba4-b5 { 0.073 -0.08 } { }
51. Rg6-d6 { 0.072 0.08 } { }
51. Kc8-c7 { 0.072 -0.08 } { }
52. Ne5-f7 { 0.071 0.08 } { }
52. Bb5-c4 { 0.071 -0.07 } { }
53. Rd6-f6 { 0.070 0.08 } { }
53. Kc7-b8 { 0.070 -0.08 } { }
54. Rf6-f5 { 0.069 0.08 } { }
54. Bc4-a6 { 0.069 -0.08 } { }
55. Nf7-d6 { 0.067 0.08 } { }
55. Kb8-c7 { 0.067 -0.08 } { }
56. Rf5-g5 { 0.066 0.08 } { }
56. Kc7-d6 { 0.066 -0.08 } { }
57. Rg5-g6 { 0.065 0.08 } { }
57. Kd6-d5 { 0.065 -0.08 } { }
58. Rg6-a6 { 0.064 0.08 } { }
58. Kd5-e4 { 0.064 -0.08 } { }
59. Ra6-a4 { 0.063 0.08 } { }
59. Ke4-f5 { 0.063 -0.08 } { }
60. h4-h5 { 0.062 0.08 } { }
60. Kf5-g4 { 0.062 -0.09 } { }
61. h5-h6 { 0.061 0.18 } { }
61. Kg4-g3 { 0.061 -0.18 } { }
62. h6-h7 { 0.060 0.18 } { }
62. a7-a6 { 0.060 -0.18 } { }
63. h7-h8Q { 0.059 0.18 } { }
63. Kg3-g2 { 0.059 -0.18 } { }
64. f4-f5 { 0.058 0.18 } { }
64. Kg2-g3 { 0.058 -0.18 } { }
65. f5-f6 { 0.057 0.18 } { }
65. Kg3-g2 { 0.057 -0.19 } { }
66. f6-f7 { 0.056 0.19 } { }
66. a6-a5 { 0.056 -0.19 } { }
67. Qh8-g8 { 0.055 0.29 } { }
67. Kg2-h3 { 0.055 -0.19 } { }
68. f7-f8Q { 0.054 26.21 } { }
68. Kh3-h2 { 0.054 -0.19 } { }
69. Qg8-g6 { 0.053 26.21 } { }
69. Kh2-h3 { 0.053 -0.20 } { }
70. Qf8-g8 { 0.052 26.21 } { }
70. Kh3-h2 { 0.052 -0.20 } { }
71. Qg8-h8 { 0.052 26.21 } { }
[/pgn]

User avatar
cdani
Posts: 2105
Joined: Sat Jan 18, 2014 9:24 am
Location: Andorra
Contact:

Re: Evaluation as a composite

Post by cdani » Tue Sep 05, 2017 6:09 pm

Henk wrote:By the way does anybody know why Stockfish doesn't use a neural network for it's evaluation.
Is a bit like asking why a Ferrari does not use a truck motor with the declared goal of being faster.

Henk
Posts: 5904
Joined: Mon May 27, 2013 8:31 am

Re: Evaluation as a composite

Post by Henk » Tue Sep 05, 2017 7:06 pm

cdani wrote:
Henk wrote:By the way does anybody know why Stockfish doesn't use a neural network for it's evaluation.
Is a bit like asking why a Ferrari does not use a truck motor with the declared goal of being faster.
Maybe you shouldn't go faster if you are a bad driver. In that case better replace the driver.

Might be accuracy is more important than speed. I don't know. I also don't understand anything about chess. They are only talking/writing about specials cases. No general rules while there are only a few types of pieces.

Dann Corbit
Posts: 10308
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Evaluation as a composite

Post by Dann Corbit » Tue Sep 05, 2017 7:32 pm

Henk wrote:
cdani wrote:
Henk wrote:By the way does anybody know why Stockfish doesn't use a neural network for it's evaluation.
Is a bit like asking why a Ferrari does not use a truck motor with the declared goal of being faster.
Maybe you shouldn't go faster if you are a bad driver. In that case better replace the driver.

Might be accuracy is more important than speed. I don't know. I also don't understand anything about chess. They are only talking/writing about specials cases. No general rules while there are only a few types of pieces.
Using a neural net requires a ton of floating point math.

Mathew Lai used a Neural net with Giraffe, and it played very well, but it could not compete with the top level hand tuned evaluations.

When a human brain applies itself to the problem of evaluation, this is (in fact) injection of intelligence into the program.

When 20,000 games are played with some eval tweak to determine the effect of the change, the measurement is a powerful tool to advance the evaluation. The good thing about this use of math is that you do not have to repeat it when the games are being played.

Now, if we could get the top end GPU cards to play chess, the idea of neural net might suddenly become very competitive.

In the meantime, we apply non-artificial intelligence to the construction of evaluation functions and it seems to work pretty well.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

Ras
Posts: 1178
Joined: Tue Aug 30, 2016 6:19 pm
Contact:

Re: Evaluation as a composite

Post by Ras » Tue Sep 05, 2017 10:33 pm

Dann Corbit wrote:Now, if we could get the top end GPU cards to play chess, the idea of neural net might suddenly become very competitive.
The way it was used in Giraffe will, IMO, not be competetive because the neuro net was used in the wrong place. Neuro nets produce similar outputs for similar inputs, i.e. they are useful for pattern matching. But in chess, just one piece one square away can decide the whole game. Unlike Go, chess isn't suited for this approach.

What would work, IMO, is doing it the other way around: using a conventional engine with search and eval, and if no forced line shows up, letting the neuro net choose among the playable moves. That way, the neuro net would be implementing strategy, and that is pattern recognition.

There is even some evidence: centaur games. A team of humans (neuro net based!) and engines is stronger than either of them alone. This is because computers excel in tactics, but humans are better in strategy.

With Stockfish & Co, we have reached a plateau, and if we want another breakthrough, that just will not happen with patches of 0.5 Elo here and 1 Elo there. But a new approach might be interesting. Especially if the neuro net part after the conventional search is dang fast because it's running on the GPU.

brianr
Posts: 362
Joined: Thu Mar 09, 2006 2:01 pm

Re: Evaluation as a composite

Post by brianr » Wed Sep 06, 2017 12:21 am

Ras wrote:The way it was used in Giraffe will, IMO, not be competetive because the neuro net was used in the wrong place. Neuro nets produce similar outputs for similar inputs, i.e. they are useful for pattern matching. But in chess, just one piece one square away can decide the whole game. Unlike Go, chess isn't suited for this approach.
Actually, per the Giraffe paper, the neural net used was specifically designed to address the "one square away" issue. Moreover, Giraffe's eval is quite good. The problem was that it is currently too slow to run the net. See the Texel tests with the Giraffe eval posts.

Tony P.
Posts: 99
Joined: Sun Jan 22, 2017 7:30 pm
Location: Russia

Re: Evaluation as a composite

Post by Tony P. » Sun Sep 17, 2017 2:54 am

Henk wrote:Alternative is a search factory that creates a search for a robot with an evaluation state using an evaluation strategy (composite) that updates its behavior depending on the position.

I want two robots playing chess with different evaluation strategies and see which one plays best.

So you need two evaluations.
I'm not sure what you mean. If you mean that the engine creates two different robots evaluating the same position from the same player's point of view, using the same minimax search routine for both robots, just with different static evaluation functions, and then chooses one of the two moves that the robots report, this strategy has already been implemented by Ed Schroder in ProDeo 2.2. It results in a more entertaining style of play if one of the robots is set to be very aggressive. However, this approach doubles the search time and I doubt that it gives better results in terms of the playing strength than just searching twice more nodes with one robot.

If you mean that one of the robots analyses the game tree from White's point of view while the other analyses the game tree from Black's viewpoint, this might give an improvement, but you have to change the principle that the side to move uses to select the best move. A typical chess engine assumes that the opponent uses the same evaluation function, thus every position that the opponent evaluates as good is necessarily evaluated as bad for the acting engine, e.g. a position that the Black opponent evaluates as equivalent to being a pawn up, the White agent automatically considers equivalent to being a pawn down.

Whereas if different evaluation functions are used, it's sometimes better to make a move which would be worse if the opponent used the same function but which, in fact, creates a complicated position and prompts the weak opponent with inferior evaluation to play bad moves, than to make a perfect move that would allow the opponent to play perfectly too because the position would be easy for the opponent to analyse. Such a provocative style of play takes extra time to calculate too, but this time is probably well spent. The difficulty is that it's hard to estimate the probability of an imperfect opponent making a mistake. So most (if not all) chess engines take a safe approach and make Nash equilibrium moves, assuming that the opponent will always play the best moves.

I suspect that the static evaluation function of Fizbo 1.9 is tuned in a fashion that encourages it to make speculative moves creating a situation where its opponent will start making even worse moves, though we can't tell it for sure as Fizbo's source code is closed.

Fizbo seems to deliberately try to steer the game towards position types where most usual chess engines tend to make mistakes but Fizbo itself excels. (That's what human masters do.) For example, it likes exchanges resulting in material or positional imbalances, sometimes makes the pawn structure closed so that the opponent evaluates the position as drawn, while Fizbo itself is ready to open the position with a sacrifice at a convenient moment.

Another example is that Fizbo likes to play into variations where it can sacrifice a piece by putting it en prise and the reason for that sacrifice is revealed a lot of moves later. Putting a piece en prise (as opposed to capturing a less valuable piece or pawn) is Fizbo's favourite method of sacrifice, for a good reason: if the position that arises after taking that hanging piece is at a leaf of the opponent's search tree, the opponent typically evaluates the position as quiescent and won due to the material advantage and is too 'lazy' to search such a variation deeper and try to find out if putting that piece en prise makes sense for Fizbo or not. Whereas if the sacrifice was a capture (of a less valuable piece or pawn), the opponent would make a recapture extension, search a bit deeper into that variation and detect that the sacrifice is correct and the variation should be avoided.

I'm not a programmer, though. I don't understand the computational costs well enough.

Post Reply