Blunder option

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Blunder option.

Post by Ferdy »

It produces a fun game :!: so far, TC=3m+2, engine is SF12. It started on its own on move a6. See arena log. It is using K=1.0. In the log it made a top 1 move at the right moment :)

I am using something similar to this method.

Code: Select all

if [F(i-1) < r =< F(i)] then
  pick move i
end if

Code: Select all

def search_move_num(d, f):
    """
    Search the move number based on generated random number.
    """
    move_num = 0
    max_tries = 10
    tries = 0

    # Don't return unless we get the move number.
    while True:
        if tries >= max_tries:
            break

        tries += 1

        # Generate random number between the min and max of f.
        # print(f'min: {min(f)}, max: {max(f)}')
        r = random.uniform(min(f), max(f))
        r = round(r, 4)
        # print(f'info string random number {r}')

        found = False
        for i in range(len(d)):
            if i == len(d) - 1:
                break

            low = f[i]
            high = f[i+1]

            if low >= r >= high or low <= r <= high:
                move_num = i
                found = True
                break

        if found:
            break

        print('info string failed to get move num, generate random number again...')

    return move_num + 1, r
[pgn][Event "Computer chess game"]
[Site "?"]
[Date "2020.12.31"]
[Round "?"]
[White "ferdi"]
[Black "Guided v1.0.0"]
[Result "*"]
[BlackElo "2000"]
[ECO "B21"]
[Opening "Sicilian"]
[Time "21:41:04"]
[Variation "Smith-Morra, 1.e4 c5 2.d4 cxd4"]
[WhiteElo "2400"]
[TimeControl "180+2"]
[Termination "unterminated"]
[PlyCount "32"]
[WhiteType "human"]
[BlackType "program"]

1. e4 c5 2. d4 cxd4 3. Qxd4 a6 4. Nf3 b6 5. c4 Bb7 6. Nc3 e6 7. Be3 Nf6 8.
e5 Bc5 9. Qd2 Ne4 10. Nxe4 Bxe4 11. Be2 Bg6 12. O-O Nc6 13. Bxc5 bxc5 14.
Qe3 Qb8 15. Qxc5 Qxb2 16. Rfe1 h6 *[/pgn]

That b6 move is top 8, weak but not weird.

Code: Select all

2020-12-31 21:42:03.891<--1:info string move number 8 random number 0.8342
2020-12-31 21:42:03.898<--1:bestmove b7b6
That last move is top 4 move.

Code: Select all

2020-12-31 21:46:28.728<--1:info string move number 4 random number 0.3514
2020-12-31 21:46:28.734<--1:bestmove h7h6
Arena log
2020-12-31 21:41:20.116-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4
2020-12-31 21:41:20.120-->1:go wtime 181579 btime 184000 winc 2000 binc 2000
2020-12-31 21:41:36.642<--1:info string move number 5 random number 0.6577
2020-12-31 21:41:36.649<--1:bestmove a7a6
2020-12-31 21:41:36.656*1*Found move:a7-a6
2020-12-31 21:41:46.507*1*Start calc, move no: 7
2020-12-31 21:41:46.517-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3
2020-12-31 21:41:46.524-->1:go wtime 174032 btime 169473 winc 2000 binc 2000
2020-12-31 21:42:03.891<--1:info string move number 8 random number 0.8342
2020-12-31 21:42:03.898<--1:bestmove b7b6
2020-12-31 21:42:03.904*1*Found move:b7-b6
2020-12-31 21:42:07.881*1*Start calc, move no: 9
2020-12-31 21:42:07.891-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4
2020-12-31 21:42:07.896-->1:go wtime 172329 btime 154103 winc 2000 binc 2000
2020-12-31 21:42:25.835<--1:info string move number 3 random number 0.4551
2020-12-31 21:42:25.841<--1:bestmove c8b7
2020-12-31 21:42:25.847*1*Found move:Bc8-b7
2020-12-31 21:42:29.618*1*Start calc, move no: 11
2020-12-31 21:42:29.627-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3
2020-12-31 21:42:29.632-->1:go wtime 170829 btime 138171 winc 2000 binc 2000
2020-12-31 21:42:47.886<--1:info string move number 3 random number 0.4503
2020-12-31 21:42:47.894<--1:bestmove e7e6
2020-12-31 21:42:47.902*1*Found move:e7-e6
2020-12-31 21:42:52.364*1*Start calc, move no: 13
2020-12-31 21:42:52.375-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3
2020-12-31 21:42:52.380-->1:go wtime 168641 btime 121910 winc 2000 binc 2000
2020-12-31 21:43:10.713<--1:info string move number 1 random number 0.4379
2020-12-31 21:43:10.720<--1:bestmove g8f6
2020-12-31 21:43:10.728*1*Found move:Ng8-f6
2020-12-31 21:43:27.561*1*Start calc, move no: 15
2020-12-31 21:43:27.571-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5
2020-12-31 21:43:27.576-->1:go wtime 154313 btime 105571 winc 2000 binc 2000
2020-12-31 21:43:45.776<--1:info string move number 1 random number 0.3987
2020-12-31 21:43:45.783<--1:bestmove f8c5
2020-12-31 21:43:45.789*1*Found move:Bf8-c5
2020-12-31 21:43:53.997*1*Start calc, move no: 17
2020-12-31 21:43:54.007-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2
2020-12-31 21:43:54.014-->1:go wtime 148376 btime 89358 winc 2000 binc 2000
2020-12-31 21:44:11.891<--1:info string move number 1 random number 0.4728
2020-12-31 21:44:11.898<--1:bestmove f6e4
2020-12-31 21:44:11.904*1*Found move:Nf6-e4
2020-12-31 21:44:17.038*1*Start calc, move no: 19
2020-12-31 21:44:17.047-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4
2020-12-31 21:44:17.053-->1:go wtime 145533 btime 73472 winc 2000 binc 2000
2020-12-31 21:44:34.436<--1:info string move number 1 random number 0.3805
2020-12-31 21:44:34.442<--1:bestmove b7e4
2020-12-31 21:44:34.449*1*Found move:Bb7xe4
2020-12-31 21:44:41.273*1*Start calc, move no: 21
2020-12-31 21:44:41.281-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4 b7e4 f1e2
2020-12-31 21:44:41.287-->1:go wtime 141018 btime 58086 winc 2000 binc 2000
2020-12-31 21:44:58.039<--1:info string move number 5 random number 0.3527
2020-12-31 21:44:58.046<--1:bestmove e4g6
2020-12-31 21:44:58.054*1*Found move:Be4-g6
2020-12-31 21:45:10.974*1*Start calc, move no: 23
2020-12-31 21:45:10.983-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4 b7e4 f1e2 e4g6 e1g1
2020-12-31 21:45:10.989-->1:go wtime 130393 btime 43325 winc 2000 binc 2000
2020-12-31 21:45:26.992<--1:info string move number 1 random number 0.3447
2020-12-31 21:45:26.998<--1:bestmove b8c6
2020-12-31 21:45:27.004*1*Found move:Nb8-c6
2020-12-31 21:45:36.103*1*Start calc, move no: 25
2020-12-31 21:45:36.111-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4 b7e4 f1e2 e4g6 e1g1 b8c6 e3c5
2020-12-31 21:45:36.116-->1:go wtime 123596 btime 29330 winc 2000 binc 2000
2020-12-31 21:45:51.280<--1:info string move number 1 random number 0.3985
2020-12-31 21:45:51.286<--1:bestmove b6c5
2020-12-31 21:45:51.291*1*Found move:b6xc5
2020-12-31 21:45:55.806*1*Start calc, move no: 27
2020-12-31 21:45:55.815-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4 b7e4 f1e2 e4g6 e1g1 b8c6 e3c5 b6c5 d2e3
2020-12-31 21:45:55.821-->1:go wtime 121377 btime 16163 winc 2000 binc 2000
2020-12-31 21:46:08.649<--1:info string move number 2 random number 0.5475
2020-12-31 21:46:08.656<--1:bestmove d8b8
2020-12-31 21:46:08.663*1*Found move:Qd8-b8
2020-12-31 21:46:17.975*1*Start calc, move no: 29
2020-12-31 21:46:17.985-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4 b7e4 f1e2 e4g6 e1g1 b8c6 e3c5 b6c5 d2e3 d8b8 e3c5
2020-12-31 21:46:17.990-->1:go wtime 114361 btime 5325 winc 2000 binc 2000
2020-12-31 21:46:22.148<--1:info string move number 1 random number 0.8668
2020-12-31 21:46:22.154<--1:bestmove b8b2
2020-12-31 21:46:22.160*1*Found move:Qb8xb2
2020-12-31 21:46:26.277*1*Start calc, move no: 31
2020-12-31 21:46:26.286-->1:position startpos moves e2e4 c7c5 d2d4 c5d4 d1d4 a7a6 g1f3 b7b6 c2c4 c8b7 b1c3 e7e6 c1e3 g8f6 e4e5 f8c5 d4d2 f6e4 c3e4 b7e4 f1e2 e4g6 e1g1 b8c6 e3c5 b6c5 d2e3 d8b8 e3c5 b8b2 f1e1
2020-12-31 21:46:26.291-->1:go wtime 112549 btime 3173 winc 2000 binc 2000
2020-12-31 21:46:28.728<--1:info string move number 4 random number 0.3514
2020-12-31 21:46:28.734<--1:bestmove h7h6
2020-12-31 21:46:28.739*1*Found move:h7-h6
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Blunder option.

Post by Ferdy »

Test game 2, will it mates me?

[pgn][Event "Computer chess game"]
[Site "?"]
[Date "2020.12.31"]
[Round "?"]
[White "ferdi"]
[Black "Guided v1.0.0"]
[Result "0-1"]
[BlackElo "2000"]
[ECO "A00"]
[Opening "Barnes (Gedult) Opening"]
[Time "22:20:17"]
[WhiteElo "2400"]
[TimeControl "180+2"]
[Termination "normal"]
[PlyCount "122"]
[WhiteType "human"]
[BlackType "program"]

1. f3 Nc6 2. Kf2 d5 3. Ke3 Bf5 4. Kf4 Nf6 5. Kg5 Nh5 6. Kxf5 Qd6 7. Kg5 f5
8. Kxf5 Qe5+ 9. Kg4 Qe6+ 10. Kg5 Qh6+ 11. Kf5 Nf4 12. Kg4 g5 13. Kf5 g4 14.
Kxg4 Rg8+ 15. Kf5 Kf7 16. Na3 Rg6 17. Nc4 Nb8 18. Ne5+ Kg8 19. Nxg6 Nxg6
20. Rb1 c5 21. Ra1 a6 22. Rb1 e5 23. Ra1 Ra7 24. Rb1 Be7 25. Ra1 Qh5+ 26.
Ke6 Nf8+ 27. Kxe7 Qf7+ 28. Kd6 b5 29. Kxc5 Ne6+ 30. Kxd5 a5 31. Kxe5 a4 32.
Kd6 Ra5 33. Ke5 Kg7 34. Kd6 Ng5 35. Kc5 Qc4+ 36. Kb6 Ne4 37. Kxa5 Qc7+ 38.
Kxb5 Nd6+ 39. Kxa4 Qc6+ 40. Ka5 Nd7 41. Kb4 Qc4+ 42. Ka5 Qc5+ 43. Ka6 Qb5+
44. Ka7 Qc4 45. Ka8 Ne5 46. Kb8 Kg6 47. Ka7 Kf7 48. Kb8 Qc6 49. Ka7 Qd7+
50. Kb8 Kg6 51. Ka8 Kf7 52. Kb8 Nec4 53. Ka8 Ke6 54. Kb8 Ne3 55. dxe3 Qc6
56. Ka7 Qd7+ 57. Kb8 h5 58. Ka8 Qa4+ 59. Kb8 h4 60. Kc7 Qd7+ 61. Kb8 Qb7#
0-1[/pgn]
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Blunder option

Post by hgm »

To make blunders more human-like you have to be a bit more selective in what you prune. There is for instance a proximity effect: even beginners would virtually never expose their pieces to capture by a Pawn, but they might put something in the path of a distant Rook, or even more likely, a distant Bishop. Not to mention those tricky Knight jumps. So the probability for pruning captures should be 0 ~ Pawns ~ Kings < orthogonal slide < diagonal slide < hippogonal. (Where the slides increase with distance.) There also is a temporal effect: moves have a larger probability to be recognized when they have been possible for a longer time (or have a good score longer). OTOH, there also is an attention effect: moves by a piece that just moved are more likely to be recognized. (So it is especially the discovered attacks that tend to be overlooked: these were not possible before, but are from a piece that did not move.)

A simple algorithm would be to not recalculate all moves in the root, but sometimes (quite often, actually) use the score of the root search from the game position two ply earlier. This obviously only works for moves that were possible before; moves with the moved piece must always be calculated from scratch (but humans would also do that). New moves with stationary pieces can be simply pruned, until their turn comes up to update their score. QS can be weakened by pruning non-recaptures (i.e. to the to-square of the previous ply) with high probability (exceeding the probabilities for pruning recaptures discussed above).
User avatar
emadsen
Posts: 434
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Blunder option.

Post by emadsen »

Ajedrecista wrote: Tue Dec 29, 2020 7:26 pmSome people are writing about Multi-PV and I think it is worth a try. I proposed a method back in 2016 which is based in Multi-PV move-picking involving PRNG. I am not aware that anyone has implemented it so far...
That's what I do in my engine. I described the technique on my website. See The MadChess UCI_LimitStrength Algorithm.

In summary: dumb down positional knowledge, slow down the search, use a MultiPV search to get root moves scores within an error range, randomly select an inferior root move, occasionally randomly select an inferior root move from a much larger blunder range.

See also this post with example code for the root search.

I need to revisit this issue of effectively and realistically weakening my engine prior to releasing the next version. Need to play some games against it, both personally and versus other engines that implement UCI_LimitStrength to get a sense of the realism and to calibrate the ELO scale.

FYI, the GetInferiorMove method mentioned in the post referenced above is simply this:

Code: Select all

private ulong GetInferiorMove(Position Position, int ScoreError)
{
    // Determine how many moves are within score error.
    var bestScore = _bestMoves[0].Score;
    var worstScore = bestScore - ScoreError;
    var inferiorMoves = 0;
    for (var moveIndex = 1; moveIndex < Position.MoveIndex; moveIndex++)
    {
        if (_bestMoves[moveIndex].Score < worstScore) break;
        inferiorMoves++;
    }
    // Randomly select a move within score error.
    return _bestMoves[SafeRandom.NextInt(0, inferiorMoves + 1)].Move;
}
My C# chess engine: https://www.madchess.net
User avatar
Ajedrecista
Posts: 1971
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Blunder option.

Post by Ajedrecista »

Hello Ferdinand:
Ferdy wrote: Thu Dec 31, 2020 3:32 pm Test game 2, will it mates me?

[pgn][Event "Computer chess game"]
[Site "?"]
[Date "2020.12.31"]
[Round "?"]
[White "ferdi"]
[Black "Guided v1.0.0"]
[Result "0-1"]
[BlackElo "2000"]
[ECO "A00"]
[Opening "Barnes (Gedult) Opening"]
[Time "22:20:17"]
[WhiteElo "2400"]
[TimeControl "180+2"]
[Termination "normal"]
[PlyCount "122"]
[WhiteType "human"]
[BlackType "program"]

1. f3 Nc6 2. Kf2 d5 3. Ke3 Bf5 4. Kf4 Nf6 5. Kg5 Nh5 6. Kxf5 Qd6 7. Kg5 f5
8. Kxf5 Qe5+ 9. Kg4 Qe6+ 10. Kg5 Qh6+ 11. Kf5 Nf4 12. Kg4 g5 13. Kf5 g4 14.
Kxg4 Rg8+ 15. Kf5 Kf7 16. Na3 Rg6 17. Nc4 Nb8 18. Ne5+ Kg8 19. Nxg6 Nxg6
20. Rb1 c5 21. Ra1 a6 22. Rb1 e5 23. Ra1 Ra7 24. Rb1 Be7 25. Ra1 Qh5+ 26.
Ke6 Nf8+ 27. Kxe7 Qf7+ 28. Kd6 b5 29. Kxc5 Ne6+ 30. Kxd5 a5 31. Kxe5 a4 32.
Kd6 Ra5 33. Ke5 Kg7 34. Kd6 Ng5 35. Kc5 Qc4+ 36. Kb6 Ne4 37. Kxa5 Qc7+ 38.
Kxb5 Nd6+ 39. Kxa4 Qc6+ 40. Ka5 Nd7 41. Kb4 Qc4+ 42. Ka5 Qc5+ 43. Ka6 Qb5+
44. Ka7 Qc4 45. Ka8 Ne5 46. Kb8 Kg6 47. Ka7 Kf7 48. Kb8 Qc6 49. Ka7 Qd7+
50. Kb8 Kg6 51. Ka8 Kf7 52. Kb8 Nec4 53. Ka8 Ke6 54. Kb8 Ne3 55. dxe3 Qc6
56. Ka7 Qd7+ 57. Kb8 h5 58. Ka8 Qa4+ 59. Kb8 h4 60. Kc7 Qd7+ 61. Kb8 Qb7#
0-1[/pgn]
This behaviour is expected when there are many good moves with similar evals (for example if mate in 1 is +327.66, mate in 2 is +327.64 and so on). Mate evals should be treated in a different way, artificially enlarging their relative differences or whatever in order to avoid this shuffling which is annoying. Anyway, thank you for your time. Much appreciated.

Regards from Spain.

Ajedrecista.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Blunder option.

Post by Ferdy »

Ajedrecista wrote: Sat Jan 02, 2021 1:24 pm Hello Ferdinand:
Ferdy wrote: Thu Dec 31, 2020 3:32 pm Test game 2, will it mates me?

[pgn][Event "Computer chess game"]
[Site "?"]
[Date "2020.12.31"]
[Round "?"]
[White "ferdi"]
[Black "Guided v1.0.0"]
[Result "0-1"]
[BlackElo "2000"]
[ECO "A00"]
[Opening "Barnes (Gedult) Opening"]
[Time "22:20:17"]
[WhiteElo "2400"]
[TimeControl "180+2"]
[Termination "normal"]
[PlyCount "122"]
[WhiteType "human"]
[BlackType "program"]

1. f3 Nc6 2. Kf2 d5 3. Ke3 Bf5 4. Kf4 Nf6 5. Kg5 Nh5 6. Kxf5 Qd6 7. Kg5 f5
8. Kxf5 Qe5+ 9. Kg4 Qe6+ 10. Kg5 Qh6+ 11. Kf5 Nf4 12. Kg4 g5 13. Kf5 g4 14.
Kxg4 Rg8+ 15. Kf5 Kf7 16. Na3 Rg6 17. Nc4 Nb8 18. Ne5+ Kg8 19. Nxg6 Nxg6
20. Rb1 c5 21. Ra1 a6 22. Rb1 e5 23. Ra1 Ra7 24. Rb1 Be7 25. Ra1 Qh5+ 26.
Ke6 Nf8+ 27. Kxe7 Qf7+ 28. Kd6 b5 29. Kxc5 Ne6+ 30. Kxd5 a5 31. Kxe5 a4 32.
Kd6 Ra5 33. Ke5 Kg7 34. Kd6 Ng5 35. Kc5 Qc4+ 36. Kb6 Ne4 37. Kxa5 Qc7+ 38.
Kxb5 Nd6+ 39. Kxa4 Qc6+ 40. Ka5 Nd7 41. Kb4 Qc4+ 42. Ka5 Qc5+ 43. Ka6 Qb5+
44. Ka7 Qc4 45. Ka8 Ne5 46. Kb8 Kg6 47. Ka7 Kf7 48. Kb8 Qc6 49. Ka7 Qd7+
50. Kb8 Kg6 51. Ka8 Kf7 52. Kb8 Nec4 53. Ka8 Ke6 54. Kb8 Ne3 55. dxe3 Qc6
56. Ka7 Qd7+ 57. Kb8 h5 58. Ka8 Qa4+ 59. Kb8 h4 60. Kc7 Qd7+ 61. Kb8 Qb7#
0-1[/pgn]
This behaviour is expected when there are many good moves with similar evals (for example if mate in 1 is +327.66, mate in 2 is +327.64 and so on). Mate evals should be treated in a different way, artificially enlarging their relative differences or whatever in order to avoid this shuffling which is annoying. Anyway, thank you for your time. Much appreciated.

Regards from Spain.

Ajedrecista.
Uploaded GuidedClever, modify the bat and cfg file for the uci engine file you want to run, Stockfish is preferable.

GuidedClever will act as an adaptor, options can be set in cfg file. This adaptor has an option to vary the K value so far. You may post issues in github for algo improvement, etc.

Be sure to install the dependent modules:

Code: Select all

pip install -r requirements.txt
In Arena it is better to open the engine window to see the move, scores perf etc.

Image
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Blunder option

Post by JVMerlino »

Johan did the MultiPV method in The King (Chessmaster). There was a "randomness" setting for each personality, from 0-100. A randomness of 20, for example, gave +/- 10cp for each move. So strong (i.e. GM-level) personalities that had that level of randomness would often play moves that could be called "inaccuracies", but never any blunders.

But, to be honest, there was also a "Strength of Play" setting, and I have no idea how that fit in to the calculation. :oops:

jm
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Blunder option

Post by maksimKorzh »

op12no2 wrote: Tue Dec 29, 2020 2:49 pm I've had a few queries recently (due to Netflix?) about making the online Lozza weaker. It seems that for a beginner even a consistently 'accurate' 1 ply search is too strong - which is fair enough - people need to win to stay interested. I came up with this in the top level search just before the test for > alpha etc.

Code: Select all

if (this.mistakes) {
  if (Math.random() <= 1.0/(this.uci.spec.depth * this.uci.spec.depth)) {
    var mm = Math.random() + Math.random();
    this.uci.debug('blunder, changed score of ',board.formatMove(move,SAN_FMT),' from ',score,' to ',score*mm|0);
    score = score * mm | 0;
  }
}
this.uci.spec.depth is maximum depth to search and I enable it in Levels 1 to 4 (1 to 4 ply search) in the online user interface, although it's generic in my extended UCI command set.

It means that every move is tweaked when playing at Level 1 (I wanted to make sure that Level 1 can be beaten by literally everybody) and every 16th move at Level 4.

While this seems to work fine, I was wondering if there is a better/standard way to force blunders?

Try the new user interface here: https://op12no2.github.io/lozza-ui/play.htm

To see the effect on top levels moves you can use the console UI: https://op12no2.github.io/lozza-ui/console.htm

Type for example:-

Code: Select all

start
uci
ucinewgame
position startpos
debug on
mistakes 1
board
go depth 5
Each blunder is listed within the PV etc output.
Hi Colin, I got similar request just right a moment ago)))
Never thought 1700 Elo engine may be too strong...