Author: Keafiwa
Date: 05:16:03 03/20/04
//This code taken from part of TCSP main.c shows it's xboard procedure
//code seems to be entering an infinite loop somewhere, on my machine(p4
//windows xp) can anyone suggest wht might be wrong and how i can correct it
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "defs.h"
#include "data.h"
#include "protos.h"
void xboard()
{
int computer_side;
char line[256], command[256];
int m;
int post = 0;
signal(SIGINT, SIG_IGN);
printf("\n");
init_board();
gen();
computer_side = EMPTY;
for (;;) {
fflush(stdout);
if (side == computer_side) {
think(post);
if (!pv[0][0].u) {
computer_side = EMPTY;
continue;
}
printf("move %s\n", move_str(pv[0][0].b));
makemove(pv[0][0].b);
ply = 0;
gen();
print_result();
continue;
}
if (!fgets(line, 256, stdin))
return;
if (line[0] == '\n')
continue;
sscanf(line, "%s", command);
if (!strcmp(command, "xboard"))
continue;
if (!strcmp(command, "new")) {
init_board();
gen();
computer_side = DARK;
continue;
}
if (!strcmp(command, "quit"))
return;
if (!strcmp(command, "force")) {
computer_side = EMPTY;
continue;
}
if (!strcmp(command, "white")) {
side = LIGHT;
xside = DARK;
gen();
computer_side = DARK;
continue;
}
if (!strcmp(command, "black")) {
side = DARK;
xside = LIGHT;
gen();
computer_side = LIGHT;
continue;
}
if (!strcmp(command, "st")) {
sscanf(line, "st %d", &max_time);
max_time *= 1000;
max_depth = 32;
continue;
}
if (!strcmp(command, "sd")) {
sscanf(line, "sd %d", &max_depth);
max_time = 1 << 25;
continue;
}
if (!strcmp(command, "time")) {
sscanf(line, "time %d", &max_time);
max_time *= 10;
max_time /= 30;
max_depth = 32;
continue;
}
if (!strcmp(command, "otim")) {
continue;
}
if (!strcmp(command, "go")) {
computer_side = side;
continue;
}
if (!strcmp(command, "hint")) {
think(0);
if (!pv[0][0].u)
continue;
printf("Hint: %s\n", move_str(pv[0][0].b));
continue;
}
if (!strcmp(command, "undo")) {
if (!hply)
continue;
takeback();
ply = 0;
gen();
continue;
}
if (!strcmp(command, "remove")) {
if (hply < 2)
continue;
takeback();
takeback();
ply = 0;
gen();
continue;
}
if (!strcmp(command, "post")) {
post = 2;
continue;
}
if (!strcmp(command, "nopost")) {
post = 0;
continue;
}
m = parse_move(line);
if (m == -1 || !makemove(gen_dat[m].m.b))
printf("Error (unknown command): %s\n", command);
else {
ply = 0;
gen();
print_result();
}
}
}
This page took 0.01 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.