Author: Stuart Cracraft
Date: 21:09:52 08/05/04
Assume for the sake of simplicity you aren't worrying about pinned
or x-rayed pieces for now.
Assume your attackers of sq are in attackers[], your defenders of sq
are in defenders[] and the count of each is in at1 and de1 and you
have them sorted from highest value to lowest value,i.e.
Rook, Knight, Pawn at positions 0, 1, 2 in attackers[], etc.
Defenders are the defenders of the piece at sq about which
this whole exchange is taking place.
Do your exchange by lowest piece first. Return a function value
reflecting the value of the exchange from the attacker's perspective
and taking into account that the whole sequence doesn't have to play
out and one can stop mid-way if advantageous to do so.
int see(sq) {
int defenders[], attackers[], de1, at1, value;
// Value of piece starting the exchange
value = absolute value of piece at sq.
while (1) {
if (de1 > 0) {
value -= attacker[at1-1];
at1--;
} else break;
if (at1 > 0) {
value += defender[de1-1];
de1--;
} else break;
}
return(value)
}
What do you think should be the modification to the code
to be able to stand-pat at the right time(s) and return
a value that is accurate for chess, not checkers-like in
terms of everything being forced, allowing for standing
pat and ignoring x-ray and pinned.
For problem 2, how would you integrate x-ray and pinned in?
Happy Hacking,
Stuart
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.