Author: Nicolas Carrasco
Date: 15:06:20 09/19/99
Dear Guys,
I have changed TSCP main.c file in order to be Winboard compatible, it can play
: HUMAN-TSCP and TSCP-HUMAN, but can“t play ANY-engine VS TSCP and TSCP VS
ANY-engine.
Do u know why?
Please take a look:
/////////////////////////////MODIFIED VERSION OF ORIGINAL main.c TSCP//////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "defs.h"
#include "data.h"
#include "protos.h"
/* main is basically an infinite loop that either calls
think() when it's the computer's turn to move or prompts
the user for a command (and deciphers it). */
void main(void)
{
int i,computer_side,from,to;
char s[256];
BOOL found;
setbuf(stdout, NULL);
setbuf(stdin, NULL);
printf("\n");
printf("Tom Kerrigan's Simple Chess Program (TSCP)\n");
printf("version 1.3, 11/11/98\n");
printf("\n");
printf("'help' displays a list of commands.\n");
printf("\n");
init();
gen();
computer_side=EMPTY;
for(;;) {
if(side==computer_side) { /* computer's turn */
think();
makemove(pv[0][0].b);
printf("move
%c%c%c%c\n",FILE(pv[0][0].b.from)+'a',8-RANK(pv[0][0].b.from)+'0',FILE(pv[0][0].b.to)+'a',8-RANK(pv[0][0].b.to)+'0');
ply=0;
gen();
continue;
}
/* get user input */
printf("tscp> ");
scanf("%s",s);
if(!strcmp(s,"quit")) {
printf("Share and enjoy!\n");
exit(0);
}
if(!strcmp(s,"black")) {
computer_side=LIGHT;
continue;
}
if(!strcmp(s,"white")) {
computer_side=DARK;
continue;
}
if(!strcmp(s,"new")) {
computer_side=EMPTY;
init();
continue;
}
if(!strcmp(s,"d")) {
print_board();
continue;
}
if(!strcmp(s,"help")) {
printf("white - oponent to move, TSCP is black\n");
printf("black - oponent to move, TSCP is white\n");
printf("new - starts a new game\n");
printf("d - display the board\n");
printf("quit - exit the program\n");
printf("Enter moves in coordinate notation, e.g., e2e4, e7e8Q\n");
continue;
}
/* maybe the user entered a move? */
from=s[0]-'a';
from+=8*(8-(s[1]-'0'));
to=s[2]-'a';
to+=8*(8-(s[3]-'0'));
/* loop through the moves to see if it's legal */
found=FALSE;
for(i=0;i<gen_end[ply];i++)
if(gen_dat[i].m.b.from==from&&gen_dat[i].m.b.to==to) {
found=TRUE;
/* get the promotion piece right */
if(gen_dat[i].m.b.bits&32)
switch(s[4]) {
case 'N': break;
case 'B': i+=1; break;
case 'R': i+=2; break;
default: i+=3; break;
}
break;
}
if(!found||!makemove(gen_dat[i].m.b))
;//printf("Illegal move.\n");
else
computer_side = side;
ply=0;
gen();
}
}
/* print_board prints the board (duh) :) */
void print_board(void)
{
int i;
printf("\n8 ");
for(i=0;i<64;i++) {
switch(color[i]) {
case EMPTY: printf(" ."); break;
case LIGHT: printf(" %c",piece_char[piece[i]]); break;
case DARK: printf(" %c",piece_char[piece[i]]+('a'-'A')); break;
}
if((i+1)%8==0&&i!=63)
printf("\n%d ",7-RANK(i));
}
printf("\n\n a b c d e f g h\n\n");
}
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.