Strategies for weaker play levels

Discussion of chess software programming and technical issues.

Moderator: Ras

Vinvin
Posts: 5314
Joined: Thu Mar 09, 2006 9:40 am
Full name: Vincent Lejeune

Re: Strategies for weaker play levels

Post by Vinvin »

Vinvin wrote:
Evert wrote:I've been looking a bit at implementing strength levels in SjaakII.
Set a bonus/malus random values for each move at the root.

How ?
At the beginning of the game, set the range (example from -2 to +2).
Before each search (each move) set a random number for each root move : e4-> random[-2, 2], d4->random[-2, 2], ...
The evaluation will add this value for the corresponding move.
The search could last 0.1 sec.
The advantage : to not blunder too much.
The disadvantage : it will never blunder a mate.
Note : to decrease the number of bigger mistakes, you can use : Factor*Square(random[0, 1]).
And the opposite, to rise the number of bigger mistakes : Factor*SquareRoot(random[0, 1]).
User avatar
Werner Taelemans
Posts: 122
Joined: Mon Feb 03, 2014 11:57 am
Location: Belgium
Full name: Werner Taelemans

Re: Strategies for weaker play levels

Post by Werner Taelemans »

At the beginning of the game, set the range (example from -2 to +2).
I suppose you mean -200cp to +200cp ?
Before each search (each move) set a random number for each root move : e4-> random[-2, 2], d4->random[-2, 2], ...
The evaluation will add this value for the corresponding move.
I tried something like that, and then I saw something strange: the engine always played one of the last moves generated by the move generator. Many times a complete blunder.

If you start with a window (-infinity,+infinity), the move e4 will change the window to e.g. (0,+infinity).
There's a fifty percent chance that the next random number is a positive number, let's say +100cp, and then the window becomes (100,+infinity) after the next move (using fail hard).
This increase of alpha goes on until we reach the end of the move list.

With fail soft this problem wouldn't occur I guess.
jdart
Posts: 4423
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Strategies for weaker play levels

Post by jdart »

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Strategies for weaker play levels

Post by Evert »

I now watched my son play a few games against the static analyser, and he seemed to enjoy himself (he wanted to play "one more" rather than go to bed). It seems like the challenge it poses for him is just about right, which was my first goal.

Of course it has some obvious flaws and draw-backs, and plays a little too predictable (which is undesirable if he would want to play it to improve his chess), but I'm quite pleased with what I have so far. I'll definitely add more though.

He played a few games of chess, then wanted to try out some of the "other chess games". He liked "Almost Chess" (which is indeed neat because a Chancellor is sufficiently weaker than a Queen that you can get some interesting imbalances) and "Amazon Chess" (which is actually not so great in practice, but it has the "wow, look at the number of things this piece can do" factor).
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Strategies for weaker play levels

Post by Evert »

Vinvin wrote:
Vinvin wrote:
Evert wrote:I've been looking a bit at implementing strength levels in SjaakII.
Set a bonus/malus random values for each move at the root.

How ?
At the beginning of the game, set the range (example from -2 to +2).
Before each search (each move) set a random number for each root move : e4-> random[-2, 2], d4->random[-2, 2], ...
The evaluation will add this value for the corresponding move.
The search could last 0.1 sec.
The advantage : to not blunder too much.
The disadvantage : it will never blunder a mate.
Note : to decrease the number of bigger mistakes, you can use : Factor*Square(random[0, 1]).
And the opposite, to rise the number of bigger mistakes : Factor*SquareRoot(random[0, 1]).
Does it lead to natural play?
A human who plays at 1000 Elo is mostly clueless. A computer can play at 1000 Elo by playing at 2500+ Elo most of the time and bungling a piece now and then. This isn't so great because it's obvious that the computer is letting you win.

My concern with tweaking the search or the evaluation is that it mainly makes the computer beatable for those who know how to play, not for those who are learning...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Strategies for weaker play levels

Post by bob »

Evert wrote:I've been looking a bit at implementing strength levels in SjaakII. This is particularly pertinent because it can play any number of obscure variants that humans who just want to try them out may not play well simply because they are unfamiliar with them.

Also, I watched my son play an old hand-held chess computer the other day, and the type of mistakes make playing against a conventional alpha-beta searcher an exercise in frustration, even at low depths. I noticed, however, that the hand-held would play much more appropriately, at least at lower levels: it sometimes forgets to evacuate an attacked piece, or it captures a defended pawn, but in ways that make it not blatantly obvious that the computer is making a blunder. In short, it looks human-ish in the mistakes it makes, which is a great feature.

I've implemented a few options in SjaakII now, as follows:
  • Clueless - this plays a completely random legal move, so it's completely clueless. It doesn't look like it plays chess though.
  • Beal/random - Returns a completely random value from the evaluation, but uses a normal search. Looks like somewhat natural play, might be close to what I'm looking for (it drops the occasional piece), but my understanding is that using this to limit the playing strength does not scale well if you increase the search depth.
  • Static analysis - Very simple. Look at all legal moves in the root, score them according to whether they are SEE>0 captures, centralisation or checking moves, and play the one that gets the highest score. Again, this actually looks like chess, but it's still clueless. Recognising some more patterns (threats against own pieces comes to mind) may make this better.
This topic comes up every once in a while, but from the discussions it's not so obvious to me what most people consider to be a satisfactory algorithm. Is there anyone who has tried one or more of these ideas and is able to make some recommendations based on this?
For several years I had a "skill" command that set randomness between 0 (skill=100) and 100% (skill=0). Worked pretty well but as speeds climbed I started to get complaints. Someone ran a match with versions of Crafty using skill=0, 10, 20, ..., 100 and it turned out that skill=0 was STILL playing at a 2000 level. Depth was so deep the "beal effect" was really working. I did not see ANY throwing pieces away back then, because losing a piece loses mobility, which is what the beal effect is actually measuring via randomness.

My current approach takes three actions.

(1) vary the randomness as before, with skill=50 saying that 1/2 of the final evaluation comes from the actual eval, the other 1/2 is a pure random number.

(2) back off on selectivity (null-move R value, LMR reduction values, pruning margins (increase them to reduce pruning), etc.

(3) introduce a delay in the evaluation to slow the NPS down. This is needed to reduce the depth and minimize the beal effect.

With the above, skill 1 will hang material as the typical search depth at 5 seconds per move is 4-5 plies on my macbook, not nearly enough for the beal effect to kick in.

What everyone wants is the holy grail however, where you have "Elo 1850" or something similar. That is a pretty serious task to undertake, because the hardware used influences the tuning. What might be 1850 on slow hardware might be 2500 on a super-fast box with multiple cores. I have tried to calibrate "skill" with cluster testing, but every time we change hardware the tuning parameters for the "skill" command change. Might be something to re-visit now that I have retired, it would be an interesting feature.
konsolas
Posts: 182
Joined: Sun Jun 12, 2016 5:44 pm
Location: London
Full name: Vincent

Re: Strategies for weaker play levels

Post by konsolas »

Perhaps one could calibrate ELO levels by setting a maximum node count for each skill level? This would presumably settle hardware differences.
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Strategies for weaker play levels

Post by Ferdy »

Evert wrote:I now watched my son play a few games against the static analyser, and he seemed to enjoy himself (he wanted to play "one more" rather than go to bed). It seems like the challenge it poses for him is just about right, which was my first goal.

Of course it has some obvious flaws and draw-backs, and plays a little too predictable (which is undesirable if he would want to play it to improve his chess), but I'm quite pleased with what I have so far. I'll definitely add more though.

He played a few games of chess, then wanted to try out some of the "other chess games". He liked "Almost Chess" (which is indeed neat because a Chancellor is sufficiently weaker than a Queen that you can get some interesting imbalances) and "Amazon Chess" (which is actually not so great in practice, but it has the "wow, look at the number of things this piece can do" factor).
Could you post a sample game played by your son?
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Strategies for weaker play levels

Post by Evert »

Ferdy wrote: Could you post a sample game played by your son?
Not easily; I'd need to store the game next time he plays on the computer.

For reference though: he's almost six, and has been learning how to play chess since Februari or so (in school, but I started him on goro-goro shogi about a year ago and taught him the pieces before he started in school). He knows about castling and en-passant, though they haven't covered that in his classes yet.
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Strategies for weaker play levels

Post by Ferdy »

Evert wrote:
Ferdy wrote: Could you post a sample game played by your son?
Not easily; I'd need to store the game next time he plays on the computer.

For reference though: he's almost six, and has been learning how to play chess since Februari or so (in school, but I started him on goro-goro shogi about a year ago and taught him the pieces before he started in school). He knows about castling and en-passant, though they haven't covered that in his classes yet.
My son now 9 also knew the game, but not the other variants or shogi. I introduced this to him when he was 4, but learned the full game rules when he was 7. There was no proper follow up as I worked abroad that time. I teach my wife to play but he beat his mother :) who just knew how to move pieces. When he was 8 he has some classmates that played chess so the interest comes back.

I am trying to find a good android app that can run engine supporting its weakening options. Before some GUI's does not support all engine options, maybe there are GUI's that supports now.

I have this Shredder on iPad mini, good interface and has weaking Elo options. I let my son play with it at Elo 850, the minimum option. Here is the game with my light annotation.

[pgn]
[Event "10:29 AM"]
[Site "Shredder for iPad"]
[Date "2016.07.03"]
[Round "?"]
[White "Player"]
[Black "Shredder"]
[Result "1-0"]
[BlackElo "850"]
[ECO "B10"]
[EventDate "2016.??.??"]
[WhiteElo "1250"]

1.e4 c6 2.Nc3 d5 3.Nf3
{ He saw the pawn in d5 is protected by c6 pawn, so he did not bother
capturing it with 3.exd5 } 3...dxe4 4.Nxe4 f5 5.Nc3 c5 6.d3
{ Always told him not to block the bishop but here he seemed to forget
after about 1 month of not playing. } 6...g6 7.Na4
{ Generally he liked to attack undefended piece or pawn } 7...b6 8.Ne5 b5
{ A nice trick by an 850 Elo Shredder } 9.Nxc5 Qc7 10.f4
{ He saw only one treat unfortunately } 10...Qa5+
{ But Shredder did not capture! } 11.Bd2 Qb6 12.Qf3
{ He saw he can attack the rook at a8 and just go for it } 12...Qxc5 13.Qxa8
Qd6 14.Qxa7 Qxe5+ { Wow Shredder had sacrificed. } 15.fxe5
{ He most often saw a capture } 15...f4 16.Bxf4 Bg7 17.Qxb8 b4 18.Qxc8+ Kf7
19.Qb8 g5 20.Bxg5 b3 21.cxb3 Bxe5 22.Qxe5 e6 23.Qxh8 h5 24.Qxh5+ Kf8 25.Rc1
{ Before I usually gave him mate in one puzzles, I think he used some of
those knowledge here } 25...e5 26.Rc5 { Oops } 26...e4 27.dxe4 Nh6 28.Bxh6+
Ke7 29.Qg6 Kd8 30.Qg7 Ke8 31.Rc7 Kd8 32.Ra7 Ke8 33.Qg8#
{ After the game Shredder Ipad gave him a rating of 1250, and that is one
that appeared in the pgn header } 1-0
[/pgn]

I will let him play with Deuterium set at 1000 elo on desktop perhaps tomorrow.
Then later tChess pro by Tom, Hiarcs by Mark, Chess pro by Christophe all on iPad which have available weak levels and beautiful GUI's too.