changing toga's code(more human moves for the losing side)

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Uri Blass
Posts: 10298
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

changing toga's code(more human moves for the losing side)

Post by Uri Blass »

One of the problems of chess computers is that they play stupid moves in losing positions and they will prefer to lose a rook and not to be mated even if seeing the mate requires a big search depth and the opponent may miss it.

This problem is obvious in the chesstempo site that use toga to generate chess problems and the moves of the defender are always toga's moves.

Toga often refuse to make an obvious capture and prefers to be a piece down and destroy the problem.

a simple example

http://chesstempo.com/chess-problems/53459

Toga refuse to play 2.Qxd2 and humans who did not see 2...Nb3 and simply guessed the first move correctly(based on the comments) solved the problem correctly because the problem is finished after 1...Bxd2



I think that there is a simple solution that can solve many of the computer stupid moves when all you need is to change few lines in toga.

The idea is that is that it is possible not to allow the engine to change it's mind to another losing alternative and you only need to change the function
full_root in search_full.cpp

from

value = -full_search(board,-alpha-1,-alpha,new_depth,height+1,new_pv,NodeCut,cap_extended,ThreadId);

to

value = -full_search(board,-alpha1-1,-alpha1,new_depth,height+1,new_pv,NodeCut,cap_extended,ThreadId);

when alpha1 can be defined as max(alpha,-175)


if (value > alpha) can also be changed to
if (value > alpha1)

Second possible change:
In case that toga see losing score at depth 1 you may want to allow it to change it's mind to another losing move but only at depth 1 and it may require another simple change in toga by defining alpha1 to be alpha when depth=1.

I am not sure if the second change is needed.

Uri
Uri Blass
Posts: 10298
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: changing toga's code(more human moves for the losing sid

Post by Uri Blass »

here is another example when toga plays a stupid move

[D]8/1p5p/p3Q1pk/6q1/5p1P/2P5/P4Pb1/4R1K1 b - -

toga plays the stupid big blunder Qxh4 after a deep search instead of the obvious Qd5 so it spoils the problem and people do not need to find the win for white after Qd5.

http://chesstempo.com/chess-problems/62647

This can be easily fixed by not allowing toga to change it's mind from one losing move to another losing move.

Uri
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: changing toga's code(more human moves for the losing sid

Post by hgm »

Wouldn't a delayed-loss bonus be helpful here? The problem with plain minimax is that, once it sees that it is unavoidably going to lose a Queen fr a Rook (say) after 15 ply in every branch, it might just as well decide to take a branch that sacs the Queen immediately in a trivial way, by capturing a defended Rook with it.

A delayed-loss bonus in combination with a saturating evaluation (e.g. applying an arctan correction to it) would even solve the distant mate vs immediate Rook sac problem.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: changing toga's code(more human moves for the losing sid

Post by Edsel Apostol »

hgm wrote:Wouldn't a delayed-loss bonus be helpful here? The problem with plain minimax is that, once it sees that it is unavoidably going to lose a Queen fr a Rook (say) after 15 ply in every branch, it might just as well decide to take a branch that sacs the Queen immediately in a trivial way, by capturing a defended Rook with it.

A delayed-loss bonus in combination with a saturating evaluation (e.g. applying an arctan correction to it) would even solve the distant mate vs immediate Rook sac problem.
A delayed loss bonus would be great to implement to make the engine play more like human, for example it would try to delay the loss in hoping that the opponent wouldn't see the win. This can also help in engine match if your engine searches deeper than the opponent.

Any hint on how to implement this?
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: changing toga's code(more human moves for the losing sid

Post by jwes »

This is a position from the Nalchik Grand Prix today.
[D]6k1/3Q2p1/p3p3/3nB1r1/8/3q3P/PP6/K1R5 w - - 0 1

After Bxg7, Rxg7 is mated in 3. Do you want the computer to play Rxg7 rather than Qc2, which also loses but is clearly more interesting? If not, how would you distinguish between this position and others where the "stupid" move is not interesting?