Adding a random small number to the evaluation function

Discussion of anything and everything relating to chess playing software and machines.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
PK
Posts: 820
Joined: Mon Jan 15, 2007 10:23 am
Location: Warsza
Contact:

Re: Adding a random small number to the evaluation function

Post by PK » Sun Sep 04, 2016 8:59 am

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.

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

Re: Adding a random small number to the evaluation function

Post by Henk » Tue Sep 06, 2016 1:02 pm

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;
}

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

Re: Adding a random small number to the evaluation function

Post by Henk » Tue Sep 06, 2016 1:21 pm

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 ( &#40;score > -MIN_MATE_SCORE && score < MIN_MATE_SCORE&#41;)
                &#123;
                    score += offset;
                &#125;

                Position.PositionHistory.Retract&#40;key&#41;;

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

Re: Adding a random small number to the evaluation function

Post by Henk » Tue Sep 06, 2016 1:40 pm

Wait a minute research condition should be adapted too. This might explain these blunders.

Code: Select all

  if &#40;score > lb - offset&#41;

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

Re: Adding a random small number to the evaluation function

Post by Henk » Tue Sep 06, 2016 1:55 pm

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&#40;seconds&#41;   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 
Last edited by Henk on Tue Sep 06, 2016 2:02 pm, edited 1 time in total.

User avatar
Evert
Posts: 2923
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: Adding a random small number to the evaluation function

Post by Evert » Tue Sep 06, 2016 1:56 pm

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.

Vinvin
Posts: 4370
Joined: Thu Mar 09, 2006 8:40 am
Full name: Vincent Lejeune

Re: Adding a random small number to the evaluation function

Post by Vinvin » Tue Sep 06, 2016 2:40 pm

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 ?"

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

Re: Adding a random small number to the evaluation function

Post by Henk » Tue Sep 06, 2016 5:15 pm

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 (&#40;score > -MIN_MATE_SCORE && score < MIN_MATE_SCORE&#41;)
&#123;
          score += smallRandomValue;
&#125;

......
......

if &#40;score > lb&#41;
&#123;
          lb = score - maxSmallRandomValue;
&#125;



Depth  Value   Time&#40;seconds&#41;   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 


Gerd Isenberg
Posts: 2127
Joined: Wed Mar 08, 2006 7:47 pm
Location: Hattingen, Germany

Re: Adding a random small number to the evaluation function

Post by Gerd Isenberg » Tue Sep 06, 2016 8:45 pm

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

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

Re: Adding a random small number to the evaluation function

Post by Ras » Wed Sep 07, 2016 4:53 pm

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.

Post Reply