Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-22T13:31:48.220Z
Answers.Text: I wouldn't say my engine is playing close to perfect ;). I didn't put any effort on position evaluation yet. The engine is beating me so I guess its around 1500 elo (the "best move engine"), not more. Thats why Im surprised cause there is a large margin of error. Anyway, thanks, Im trying to think about it and if the two of you saying its possible that the win rate is that high Im ok with it.
Answers.UserDisplayName: Mewel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-22T05:56:33.337Z
Answers.LastActivityDate: 2020-02-23T04:05:33.030Z
Answers.LastEditDate: 2020-02-23T04:05:33.030Z
Answers.UserDisplayName: Mike Jones
Answers.Body: <p>Does not sound to high to me.  Actually I would expect higher.</p>
  
  <p>1
  Depends on all the other things your code does and how.</p>
  
  <p>2
  Some make mistakes at random.</p>
  
  <p>You could limit how far you look into the future too. </p>
  
  <p>Try making 2nd best (or slightly less good)  moves but only when there are many closely evaluated ones.  Avoid those bad queen sacs by just picking a really bad one when there are not really any other good alternatives. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-21T17:56:40.280Z
Answers.Text: I tried what you suggested. I set the variance to 1. I only picked between the best and second best move. And set the ply depth to 2. After 1000 games the "best move engine" has 600 wins, 200 draws, and 200 loses. If the variance is that low and the second best move is only picked if close to equal the best move, I think there has to be a bug in alpha-beta or something else is wrong.
Answers.UserDisplayName: Mewel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-21T18:43:49.723Z
Answers.Text: i think is your assuming what you think should happen to the strength of the two engines when they play.  your results sound more reasonable now for what you are trying.   see item 1 in my answer again
Answers.UserDisplayName: edwina oliver
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-21T16:50:30.327Z
Answers.LastActivityDate: 2020-02-21T16:50:30.327Z
Answers.UserDisplayName: edwina oliver
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-21T18:35:51.460Z
Comments.Text: Just limit the depth
Comments.UserDisplayName: postoronnim
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-21T20:30:16.987Z
Comments.Text: Since the move choice is in the root position and not in the AB search, there should be nothing in the AB search that would affect the current move choice.  You could also try to limit it's poor choice to every fifth move.
Comments.UserDisplayName: Mike Jones
Tags: <engines><programming>
Title: Alpha-beta add variance/handicap
ThreadText: # Alpha-beta add variance/handicap
  
  (Asked by: username_0 on 2020-02-21)
  
  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:
  
  1. 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?
  2. Is there another way of implementing a handicap for an engine. Couldn't really find anything on the internet.
  
  **Tags:** engines, programming
  
  > **Comments:**
  > **username_1**: Just limit the depth  
  > **username_2**: Since the move choice is in the root position and not in the AB search, there should be nothing in the AB search that would affect the current move choice.  You could also try to limit it's poor choice to every fifth move.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-02-22. Score: 1
  
  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.
  
  1. 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.)
  2. 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](https://github.com/vollmerm/TrappyBeowulf) 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.
  
  > **Comments:**
  > **username_0**: I wouldn't say my engine is playing close to perfect ;). I didn't put any effort on position evaluation yet. The engine is beating me so I guess its around 1500 elo (the "best move engine"), not more. Thats why Im surprised cause there is a large margin of error. Anyway, thanks, Im trying to think about it and if the two of you saying its possible that the win rate is that high Im ok with it.  
  
  ---
  
  ### Answer by username_3 on 2020-02-21. Score: 0
  
  Does not sound to high to me. Actually I would expect higher.
  
  1
  Depends on all the other things your code does and how.
  
  2
  Some make mistakes at random.
  
  You could limit how far you look into the future too.
  
  Try making 2nd best (or slightly less good) moves but only when there are many closely evaluated ones. Avoid those bad queen sacs by just picking a really bad one when there are not really any other good alternatives.
  
  > **Comments:**
  > **username_0**: I tried what you suggested. I set the variance to 1. I only picked between the best and second best move. And set the ply depth to 2. After 1000 games the "best move engine" has 600 wins, 200 draws, and 200 loses. If the variance is that low and the second best move is only picked if close to equal the best move, I think there has to be a bug in alpha-beta or something else is wrong.  
  > **username_3**: i think is your assuming what you think should happen to the strength of the two engines when they play.  your results sound more reasonable now for what you are trying.   see item 1 in my answer again  
  
  ---
  
  