Page 2 of 2
Re: Adding a random small number to the evaluation function
Posted: Sun Sep 04, 2016 10:59 am
by PK
For weak engines randomisation is a winner. Take extreme case of material only eval vs material + random component.
I have also noticed that for engines with crippled search (I've done a lot of such tests with Rodent) evaluation functions with more extreme parameters (overemphasising king attack or mobility) score better. This may or may not be similar mechanism.
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 3:02 pm
by Henk
hgm wrote:The alternative method is to add a small random number to the move scores in the root, pre-compensating the alpha used when searching the move for this.
I don't understand how this can work with mate in N scores for if it finds a Mate in 2 and it adds a small random number the score is wrong.
And should the search be something like this
Code: Select all
if (plyCount == 0)
{
randomVal = r.Next(-100, 100);
}
else
{
randomVal = 0;
}
score = -Search(..., -(ub - randomVal), -(lb - randomVal));
if (plyCount == 0 )
{
score += randomVal;
}
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 3:21 pm
by Henk
I am using this now but strangely it looks like it makes more blunders. So I think it has something to do with this random value but I might be wrong.
Code: Select all
Position.PositionHistory.Add(key);
move.Apply();
bool check = Position.CanCaptureTarget((ColorSign)curPlayer, opponentKing, move);
if (plyCount == 0)
{
offset = r.Next(-100, 100);
}
else
{
offset = 0;
}
if (mvCount == 1 || bestMove == null)
{
score = -Search(depth - STEP_SIZE, plyCount + 1, -(ub - offset), -(lb - offset), move, check);
}
else
{
int reduction = (int)(0.7 * STEP_SIZE + 0.1 * depth);
if ( check )
{
reduction = 0;
}
score = -Search(depth - STEP_SIZE - reduction, plyCount + 1, -(lb - offset + 1), -(lb - offset), move, check);
if (score > lb)
{
score = -Search(depth -STEP_SIZE, plyCount + 1, -(ub - offset), -(lb - offset), move, check);
}
}
move.TakeBack(capture, other);
if ( (score > -MIN_MATE_SCORE && score < MIN_MATE_SCORE))
{
score += offset;
}
Position.PositionHistory.Retract(key);
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 3:40 pm
by Henk
Wait a minute research condition should be adapted too. This might explain these blunders.
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 3:55 pm
by Henk
No still does not work for instance in this position it played f7-f6??
[d] 8/k4pP1/8/2p5/1p2p2P/2q5/8/1K6 b - - 0 51
Code: Select all
Depth Value Time(seconds) Nodes
1601 M5 9.36 6297043 b4b3 g8=R c3c2 b1a1 c2a2 a1a2
1501 M5 4.20 2620215 b4b3 g8=R c3c2 b1a1 c2a2 a1a2
1401 M5 3.25 2088421 b4b3 g8=R c3c2 b1a1 c2a2 a1a2
1301 M5 1.03 695511 b4b3 g8=R c3c2 b1a1 c2a2 a1a2
1201 M5 0.63 480052 b4b3 g8=R c3c2 b1a1 c2a2 a1a2
1101 M5 1.54 861366 b4b3 g8=R c3c2 b1a1 c2a2 a1a2
1001 M3 0.61 459522 f7f5
901 M3 0.14 95977 f7f6
801 15.3785 0.07 51300 c3g7 b1c2 g7c3 c2b1 c3e1 b1a2 e1h4 a2b3
701 14.7970 0.03 18130 c3g7 b1c2 g7c3 c2b1 c3e1 b1a2 e1h4
601 14.9050 0.02 13767 c3g7 b1c2 g7c3 c2b1 c3b3 b1a1
501 14.1100 0.01 6103 c3g7 b1c2 g7c3 c2d1 c3d3
401 14.6687 0.00 2803 c3g7 h4h5 c5c4 b1a2
301 13.9932 0.00 1181 c3g7 h4h5 c5c4
201 14.0013 0.01 993 c3g7 h4h5
101 13.1485 0.00 118 c3g7
1 13.9925 0.04 109 c3g7
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 3:56 pm
by Evert
Luis Babboni wrote:I´m a little ashamed making a comment here in the middle of as experimented people as you are.... but take it just as it is, a comment.
I felt disappointing with my first tests with my first and noob engine (Soberango) when playing against other weaks engines, they repeat allways the same game!
So I added random for moves of same score but with a different approach, not adding a random value to the scores but to the order in wich moves are analyzing.
I used to do this too (actually, I don't think I removed that), but I found that it results in too little randomisation in the end.
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 4:40 pm
by Vinvin
Vinvin wrote:Uri Blass wrote:I wonder if this idea can practically help chess engines to play better.
I think that the idea may help the program to prefer lines when it has many ways to get the same score(if we ignore the random numbers) and it may help to improve the playing strength.
I remember that people tried the idea in the past in the stockfish framework with no significant change in playing strength but note that there are many possibilities to choose random numbers(for example maybe it is better to have random numbers that are 0 in half of the cases).
I'm curious about a simple experience : when Stockfish evaluate 1 millions positions, how many positions get the same evaluation score ?
I mean : "when Stockfish evaluate 1 millions positions in the starting position, how many positions get the same evaluation score as the best move ?"
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 7:15 pm
by Henk
I think it works now. No need to subtract offsets from alfa, beta only make sure that alfa is updated right. Otherwise a very bad move with a large upperbound value might be selected as best move.
Code: Select all
if ((score > -MIN_MATE_SCORE && score < MIN_MATE_SCORE))
{
score += smallRandomValue;
}
......
......
if (score > lb)
{
lb = score - maxSmallRandomValue;
}
Depth Value Time(seconds) Nodes
1101 M5 36.95 18364508 b4b3 h4h5 c3c2 b1a1 c2a2 a1a2
1001 M5 13.74 7444077 b4b3 h4h5 c3c2 b1a1 c2a2 a1a2
901 M5 0.68 505628 b4b3 h4h5 c3c2 b1a1 c2a2 a1a2
801 M5 0.23 162481 b4b3 h4h5 c3c2 b1a1 c2a2 a1a2
701 M5 0.07 44531 b4b3 h4h5 c3c2 b1a1 c2a2 a1a2
601 M5 0.07 41588 b4b3 h4h5 c3c2 b1a1 c2a2 a1a2
501 14.0256 0.01 8010 c3g7 b1a2 g7g2 a2b3 g2g3
401 14.6618 0.01 2812 c3g7 h4h5 c5c4 b1a2
301 13.9968 0.00 1232 c3g7 h4h5 c5c4
201 14.0047 0.01 1034 c3g7 h4h5
101 13.1511 0.00 122 c3g7
1 14.0083 0.04 109 c3g7
Re: Adding a random small number to the evaluation function
Posted: Tue Sep 06, 2016 10:45 pm
by Gerd Isenberg
Uri Blass wrote:I wonder if this idea can practically help chess engines to play better.
I think that the idea may help the program to prefer lines when it has many ways to get the same score(if we ignore the random numbers) and it may help to improve the playing strength.
I remember that people tried the idea in the past in the stockfish framework with no significant change in playing strength but note that there are many possibilities to choose random numbers(for example maybe it is better to have random numbers that are 0 in half of the cases).
In their 1994 paper
Random Evaluations in Chess, Don Beal and Martin C. Smith conclude in Possible Applications of the Effect (where five ply minimax with random leaf evaluations wins 100% versus five ply with zero evaluation and random choice of the move unless checkmate is in the tree):
"it is unlikely that random numbers have much practical usefulness in game playing. However, there are some places where either the effect itself might be useful ... A minor way random-evaluation techniques could be of practical application, ..., would be to introduce new evaluation terms against a background of random evaluation instead of zero. ..."
Don Beal, Martin C. Smith (1994). Random Evaluations in Chess. ICCA Journal, Vol. 17, No. 1
Don Beal, Martin C. Smith (1994). Random Evaluations in Chess. Advances in Computer Chess 7
Re: Adding a random small number to the evaluation function
Posted: Wed Sep 07, 2016 6:53 pm
by Ras
The CT800 has this as configurable option: off, +/- 10, 30, 50 centipawns. It is random noise added directly to the eval of a position. Disabled for the endgame eval.
The point, however, isn't raising the playing level, but giving more game variety.