Author: Andreas Guettinger
Date: 01:48:46 08/06/04
Go up one level in this thread
You need an array mat_value[12] with the points for queen, rook etc..
mat_value[13] = {0, -900, -500, -300, -300, -100, 0, 100, 300, 300, 500, 900,
0};
Then a counter and an array where you store the score after each step.
counter = 0;
swap_score[];
// reslove SEE
int stm = 1; // side
int gain = stm*mat_value[capturedfig + 6];
swap_score[0] = gain;
stm = -stm;
int next_fig = movingfig;
int counter = 1;
// look for hidden figure
// produce a move vector form source to target square, go along this vector
// from the captured piece to the border to find hidden pieces
// next figure, from the back of the att/def arrays to the front
for (;;)
{
if (defno > 0)
{
gain = gain + stm*mat_value[next_fig+6];
swap_score[counter] = gain;
stm = -stm;
counter++;
defno--;
// look for new defenders
// ....
}
else
break; // no more defenders
if (attno > 0)
{
gain = gain + stm*mat_value[next_fig+6];
swap_score[counter] = gain;
stm = -stm;
counter++;
attno--;
// look for new attackers
// ....
}
else
break; // no more attackers
}
// minimax through swap_scores from back to top
// back up swap_scores if there is a gain, else stand pat
stm = -stm;
counter--;
while(counter)
{
if (stm < 0)
{
if(swap_score[counter] <= swap_score[counter-1])
swap_score[counter-1] = swap_score[counter]; // else stand pat
}
else
{
if(swap_score[counter] >= swap_score[counter-1])
swap_score[counter-1] = swap_score[counter]; // else stand pat
}
counter--;
stm = -stm;
}
return (swap_score[0]);
Hope that helps a bit. It's difficult to explain how the stand pat works, just
take an actual attack position an work trough the swap scores.
regards
Andy
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.