user21579: I want to implement a handicap for my engine and I'm struggling with it. I using alpha-beta pruning.
In my current approach I set a variance variable in centipawns and let the engine choose a move in the variance range. An example with white to move and variance = 5;
25 d2d4 d5d7 ...
23 e2e4 e5e7 ...
20 b1c3 e5e7 ...
18 g1f3 d5d7 ...
...

In this case the engine can choose between the first three moves cause they are all in range of 20-25. A random move of those three is picked, all other moves are ignored.
I implemented this and let it run against my "best move engine". To my surprise in 200 games the "best move engine" wins like 95% of the time. Which is in my opinion way to high.
As I dove deeper I realized that the "variance engine" picks sometimes totally blunder moves. Like sacking a queen without any compensation. I triple checked the code for picking the "random" move in the variance range. Its perfectly fine. So I think my alpha-beta is the problem here. Some questions:

Should alpha-beta in general be capable of implementing something like variance picking. If so, what could I have done wrong or what am I missing?
Is there another way of implementing a handicap for an engine. Couldn't really find anything on the internet.


user9684: Even one minor error could cost the game against a perfect opponent, so 95% losing rate is generous.  However, I don't understand how the "best move" engine could lose any games in the second trail.

The ABSearch could be modified, but it's easier to perform this at the RootSearch function.  Since the arrays for the current moves and their respective scores are present here, it's easy to implement, and the RootSearch should be able to self-correct on future moves better than anything done in the current ABSearch.  (This is really messy.  Sorry.)
I've seen three ways to limit strength.
a.  Make a weak move at a specific interval.  When playing against its sponsors, a computer was told to make a random king move every 10 moves.
b.  The computer wasn't allowed to make a move in which the eval was above a threshold.  So, for a drawing computer, the computer wouldn't make a move where the eval was above a pawn or had to make a mistake to lower the eval to below this range.  This i similar to your variance, but instead of within the top range, it's a final eval of +- a pawn.
c.  The chess engine Galahad (I can't find its source anymore.) allowed you to change some eval constants.  Lowering the penalty for a weakness, such as doubled pawns, does lower its strength, but not in a dramatic manner.

Trappy Beowulf trys to implement a more human engine where it does try for traps instead of the best move.  I haven't read the code, so I can't explain how it accomplishes this, but I assumed that it goes for simple, one move threats, and when this threat is parried, the positions is slightly worse.
I"d like to give a special thanks to the four examples and the OP for thinking out of the box.  Not just trying to be the best, but for being usable.
EDIT:  A better example is "c" would be a piece-square value.  By adjusting this variable, you could make the computer think that g3 is a better square for the knight than e5.  This could be used to make the computer decentralize pieces or make them more defensive.  Changing the pawn protection around the king values, you could make the computer make these weakening moves and test your attacking skills.  The options are only limited by your imagination.

21579: <p>I want to implement a handicap for my engine and I'm struggling with it. I using alpha-beta pruning.</p>

<p>In my current approach I set a variance variable in centipawns and let the engine choose a move in the variance range. An example with white to move and variance = 5;</p>

<pre><code>25 d2d4 d5d7 ...
23 e2e4 e5e7 ...
20 b1c3 e5e7 ...
18 g1f3 d5d7 ...
...
</code></pre>

<p>In this case the engine can choose between the first three moves cause they are all in range of 20-25. A random move of those three is picked, all other moves are ignored.</p>

<p>I implemented this and let it run against my "best move engine". To my surprise in 200 games the "best move engine" wins like 95% of the time. Which is in my opinion way to high.</p>

<p>As I dove deeper I realized that the "variance engine" picks sometimes totally blunder moves. Like sacking a queen without any compensation. I triple checked the code for picking the "random" move in the variance range. Its perfectly fine. So I think my alpha-beta is the problem here. Some questions:</p>

<ol>
<li>Should alpha-beta in general be capable of implementing something like variance picking. If so, what could I have done wrong or what am I missing?</li>
<li>Is there another way of implementing a handicap for an engine. Couldn't really find anything on the internet.</li>
</ol>
 9684: <p>Even one minor error could cost the game against a perfect opponent, so 95% losing rate is generous.  However, I don't understand how the "best move" engine could lose any games in the second trail.</p>

<ol>
<li><p>The ABSearch could be modified, but it's easier to perform this at the RootSearch function.  Since the arrays for the current moves and their respective scores are present here, it's easy to implement, and the RootSearch should be able to self-correct on future moves better than anything done in the current ABSearch.  (This is really messy.  Sorry.)</p></li>
<li><p>I've seen three ways to limit strength.</p>

<p>a.  Make a weak move at a specific interval.  When playing against its sponsors, a computer was told to make a random king move every 10 moves.</p>

<p>b.  The computer wasn't allowed to make a move in which the eval was above a threshold.  So, for a drawing computer, the computer wouldn't make a move where the eval was above a pawn or had to make a mistake to lower the eval to below this range.  This i similar to your variance, but instead of within the top range, it's a final eval of +- a pawn.</p>

<p>c.  The chess engine Galahad (I can't find its source anymore.) allowed you to change some eval constants.  Lowering the penalty for a weakness, such as doubled pawns, does lower its strength, but not in a dramatic manner.</p></li>
</ol>

<p><a href="https://github.com/vollmerm/TrappyBeowulf" rel="nofollow noreferrer">Trappy Beowulf</a> trys to implement a more human engine where it does try for traps instead of the best move.  I haven't read the code, so I can't explain how it accomplishes this, but I assumed that it goes for simple, one move threats, and when this threat is parried, the positions is slightly worse.</p>

<p>I"d like to give a special thanks to the four examples and the OP for thinking out of the box.  Not just trying to be the best, but for being usable.</p>

<p>EDIT:  A better example is "c" would be a piece-square value.  By adjusting this variable, you could make the computer think that g3 is a better square for the knight than e5.  This could be used to make the computer decentralize pieces or make them more defensive.  Changing the pawn protection around the king values, you could make the computer make these weakening moves and test your attacking skills.  The options are only limited by your imagination.</p>
