Computer Chess Club Archives




Subject: Re: What is Botvinnik's legacy to computer chess?

Author: blass uri

Date: 07:05:33 02/22/00

Go up one level in this thread

On February 22, 2000 at 08:22:00, Tom Kerrigan wrote:

>On February 21, 2000 at 13:47:06, blass uri wrote:
>>I need functions for things that I do several times.
>>I thought to use functions for things like checking if a move is legal and
>>generating moves(it is not important if I use a function for generating the
>>initial position) but probably it is a better idea to start with defining the
>>main only by undefined functions and only after it to design the functions.
>That's one way to look at things, but most people will disagree with you.
>You don't want to be working with all of your program all of the time. Let's say
>you have your move generator lodged in your search function. And you want to
>change your search function. But first you have to find the right part, so you
>have to scroll through several hundred lines of move-generator code. Not cool.
>And you can't just glance at your search function and get the gist of it,
>because there's so much extra crud in there. Now let's say you give your program
>to somebody else. He will have a hell of a time figuring it out, because it's
>not clear where anything is. Instead of putting the move generator in a nice
>function called generate(), you have it built in to the function that's supposed
>to be searching, not generating moves...

You are right.

I think the reason for my mistake is that I tried  to do a program as fast as
possible after I read that it is easy to do a simple chess program and that you
needed only 4 hours for it.

The reason that I thought about doing a chess program is mainly that I believe
that there are many design mistakes in most chess programs
(one example is that programs may calculate for a long time a move when the
opponent has a forced mate against it because they do not reject the move for
the right reason)

I started to do a chess program and did a pseudo move generator some monthes ago
but I did not continue because I found that it is not simple.

I decided to try to do something simple before I try to do more comlicated ideas
and I think that I can learn more by trying to do things than by changing other
programs because it is important to get experience in design decision.

I decided to start again(in second thought I think that working with array of 64
is more comfortable than working with array of 8x8)

This time I have after 90 minutes a project with 4 files(data.h,data.c,search.c
and main.c)

I did not start my move generator in this program and I have no chance to finish
it in 4 hours of work.

Here are my files
I am interesting to know if I do somrething wrong here.


void init(void);
int legal(void);
void chooserandommove(void);
extern int board[64];
extern int color[64];
extern int initcolor[64];
extern int initboard[64];


int initboard[64]= {4,2,3,5,6,3,2,4,
int initcolor[64]={1,1,1,1,1,1,1,1,
int board[64];
int color[64];

#include "data.h"
void init()
	int i;
	for (i=0;i<63;i++)

//legal returns 1 if the move is legal
int legal(void)

//chooserandommove does a random legal move

void chooserandommove(void)

//main program

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "data.h"
void main(void)
  int side;
  char s[256];
  int from;
  int to;
  printf("print 1 if you want to start otherwise print 2\n");
  for (;;)
  if (side==1)
	  printf("print the move to play\n");
	  if (!strcmp(s,"bye"))
	  //the side entered a move
	  while (side==1)
	    if ((from<0)||(from>63)||(to<0)||(to>63))
		  printf("illegal move\n");
		if (legal()==1)



This page took 0.02 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.