Author: Leen Ammeraal
Date: 22:15:34 07/12/01
Go up one level in this thread
On July 12, 2001 at 17:13:14, Brian Richardson wrote:
>I am wondering if the proper capture order really matters.
>Of course, it does to return the true net gain of an exchange. However,
>in practice there may be _very_ few winning exchanges.
>
>For the purposes of just knowing is it profitable or not,
>can simply swapping off with bishops or rooks before queens suffice?
>
>Can someone provide an example where this does not seem to work?
>
>Thanks
>Brian
Consider this example:
white Ba1, Qb2; black Nd4, Bg1.
Although there are two attackers and one defender,
capturing is unwise here.
If you use my function gain, listed below, for this
example, then
cur = N (= value of knight, such as 300)
att[0] = B, att[1] = Q (since Q is the first attacker)
nAtt = 2,
def[0] = B, nDef = 1,
the returned value is 0.
On the other hand, if the positions of the white
queen and bishop were reversed (that is, white Qa1, Bb2),
we could capture the knight successfully. In that case
we would have
att[0] = Q, att[1] = B (since B is the first attacker)
and the function 'gain' would return 300 (with
piece values Q = 900, B = N = 300).
So remember, the arrays att and def are filled
'in reverse order', that is, the pieces
that act first should be placed at the end.
For the sake of completeness, here is my
function 'gain' once again:
int gain(int cur, int *att, int nAtt, int *def, int nDef)
{ int retval = 0;
if (nAtt)
{ int profit = cur - gain(att[nAtt-1], def, nDef, att, nAtt-1);
if (profit > 0)
retval = profit;
}
return retval; // Always >= 0
}
I hope this answers your question.
If the use of this function is still unclear, of if
you have an alternative, faster version, please let
me know.
Leen Ammeraal
http://home.wxs.nl/~ammeraal/
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.