Reply
 
LinkBack Thread Tools Display Modes
  #1   Report Post  
Old February 8th 04, 07:38 PM
Mikko Nummelin
 
Posts: n/a
Default K+R vs. k -problem

I am developing a chess engine and it is now on early alpha-testing stage.
For example Xboard interaction is yet to be done and I am just testing
things from a text console. While testing the engine in "trivial" "K+R vs. k"
endgame, I have come across a weird problem. The engine is coded in such a
way that there are two tables considering the value of placing each others
king in such a situation,

const int endgame_kingpos_def[64] = {
-25,-20,-15,-15,-15,-15,-20,-25,
-20, -5, 0, 0, 0, 0, -5,-20,
-15, 0, 5, 5, 5, 5, 0,-15,
-15, 0, 5, 10, 10, 5, 0,-15,
-15, 0, 5, 10, 10, 5, 0,-15,
-15, 0, 5, 5, 5, 5, 0,-15,
-20, -5, 0, 0, 0, 0, -5,-20,
-25,-10,-15,-15,-15,-15,-20,-25
};

const int endgame_kingpos_att[64] = {
-25,-25,-25,-25,-25,-25,-25,-25,
-25,-20,-15,-15,-15,-15,-20,-25,
-25,-15, 0, 20, 20, 0,-15,-25,
-25,-15, 20, 0, 0, 20,-15,-25,
-25,-15, 20, 0, 0, 20,-15,-25,
-25,-15, 0, 20, 20, 0,-15,-25,
-25,-20,-15,-15,-15,-15,-20,-25,
-25,-25,-25,-25,-25,-25,-25,-25
};

The above one is score for defending lone king placement (taken from the
side of the defender) and the lower one is score for attacking king
placement (taken from the side of the attacker). They are probed like
this (the evaluation function returns positive for whites advantage):

if(all_white_pieces_except_K(brd)==BITBOARD_ZERO){
/* White king */
tmp_bitboard.whole=brd-K.whole;
bitno=my_bsf(tmp_bitboard.whole);
value+=endgame_kingpos_def[63-bitno];

/* Black king */
tmp_bitboard.whole=brd-k.whole;
bitno=my_bsf(tmp_bitboard.whole);
value-=endgame_kingpos_att[63-bitno];

value+=current_depth;
} else if(all_black_pieces_except_K(brd)==BITBOARD_ZERO){
/* White king */
tmp_bitboard.whole=brd-K.whole;
bitno=my_bsf(tmp_bitboard.whole);
value+=endgame_kingpos_att[63-bitno];

/* Black king */
tmp_bitboard.whole=brd-k.whole;
bitno=my_bsf(tmp_bitboard.whole);
value-=endgame_kingpos_def[63-bitno];

value-=current_depth;
} else ...

Well, this is part of the evaluation function used in an iterative
deepening alpha-beta search. It produces sensible moves up to 4 plies but
then starts behaving in erratic way, making unnecessary sidesteps and
calculating better success later in the principal variation. For example
in this situation:

. . . .
.. . . .
. . . .
.. . k .
. . . R
.. . . .
. . K .
.. . . .

it suggests Kf2-e2 while Kf2-e3 would of course be clearly better (Ke2
is suggested with the weird idea of making Ke2-e3 in the following move).
But when the next move comes, it again tries to sidestep back to f2 or d2,
not taking the more valuable squares e3 or d3! Has anyone else came across
this problem before and how is it best avoided?


Mikko Nummelin
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CM9K problem? - Player Profile: Stats vs Opponent Gregory Topov rec.games.chess.computer (Computer Chess) 2 February 16th 04 04:34 PM
Problem with Fritz 8 Marco rec.games.chess.computer (Computer Chess) 6 November 17th 03 04:03 PM
Bookup problem Ajan rec.games.chess.computer (Computer Chess) 3 October 12th 03 11:59 PM
Rebel 12 problem Oliver Lewis rec.games.chess.computer (Computer Chess) 0 October 6th 03 07:20 PM
Diary problem 29 Antonio Torrecillas rec.games.chess.analysis (Chess Analysis) 1 August 30th 03 09:17 AM


All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 ChessBanter.
The comments are property of their posters.
 

About Us

"It's about Chess"

 

Copyright © 2017