* 堆栈的初始化
*/
stack_deep0 = 0;
s0 = malloc(sizeof(struct five_chess));
for (i = 0; i < 600; i++) /*为什么是600*/
close[i] = NULL; /*close是一个point 数组*/
close[num++] = s0;
for (i = 0; i < LENGTH; i++)
for (j = 0; j < LENGTH; j++) {
s0->chess[i][j] = chessman[i][j];
s0->record[i][j] = chessman[i][j];
}
s0->layer = 0;
s0->value = -3000000;
s0->score = -3000000;
push(s0);
while (is_empty() != 0) { /*看是栈否为空*/
s01 = top(); /*如果不是空*/
s1 = expand(s01); /*从栈顶开始展开*/
close[num++] = s1;
if (s1->layer == -1) {
pop();
continue;
}
go_on =
win_or_not((s1->x + 1) * 30, (s1->y + 1) * 30, 2, s1->chess,
1);
if (go_on == 2) {
a = (s1->x + 1) * 30;
b = (s1->y + 1) * 30;
break_then = 1;
break;
}
go_on =
win_or_not((s1->x + 1) * 30, (s1->y + 1) * 30, 1, s1->chess,
1);
if (go_on == 1) {
a = (s1->x + 1) * 30;
b = (s1->y + 1) * 30;
break_then = 1;
break;
}
s1->value = 30000;
push(s1);
while (1) {
s1 = top();
s2 = expand(s1);
if (s2->layer == -1) {
pop();
if (s1->value > top()->value) {
top()->value = s1->value;
max_chess = s1;
}
free(s2);
break;
}/*end of if*/
s2->score = score(s2->chess);
temps = top();
if (s2->score < temps->value)
temps->value = s2->score;
free(s2);
}/*end of whiile(1) */
}
if (break_then == 0) {
for (i = 0; i < LENGTH; i++) {
for (j = 0; j < LENGTH; j++)
if (max_chess->chess[i][j] != chessman[i][j]) {
a = i * 30 + 30;