Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: chess programming-where to start?

Author: Don Dailey

Date: 22:00:00 01/18/99

Go up one level in this thread


In addition to what Dann Corbit recommends,  I suggest you
write a tic-tac-toe program to get your feet wet.  Make sure
it does a mini-max search with alpha beta pruning.

A chess program is a very ambitious start if you've
never written ANY program before but that doesn't mean
it cannot be done.  When you say you don't have computer
programming background does that mean you've never
written any program?   In either case I recommend you
write the tic-tac-toe program first.

If you have a c compiler, here is a tic-tac-toe program
I wrote.  Throw it away and write your own, it's a horrible
example of clean readable code but just for fun here it is.
It has no interface, but it just plays itself.  Writing an
interface for it might be a good excercise for you too.
You can also throw out the 'sc' variable and just use alpha.

--------------------------- ttt.c ----------------------------
int  bm[20];
static int sol[8] = { 0111, 0222, 0333, 0007, 0070, 0700, 0124, 0421 };

int  srch( int ply, int side, int alpha, int beta, int pos ){
  int  i,sc;
  int  bs=-300;

  for (i=0; i<8; i++)
    if ( ((pos >> (side ^ 9)) & sol[i])==sol[i]) return(-12+ply);
  if( (pos>>18) == 0777) return(0);

  for (i=(1<<18)|(1<<side); i<(1<<27); i=i<<1)  {
    if ( i & pos ) continue;
    sc = -srch( ply+1, side ^ 9, -beta, -alpha, pos|i );
    if (sc > bs) { bs = sc; bm[ply]=i; }
    if (sc >= beta) break;
    if (sc > alpha) alpha = sc;
  }
 return(bs);
}

void showpos( int p ){
  int i;
  char A[20] ="- - -\n- - -\n- - -\n";
  for (i=0; i<18; i++)
    if ((1<<i) & p) A[(i%9)*2]= (i>8)?'O':'X';
  printf("\n\n%s",A);
}

void main(){
  int  c=9;
  int  pos=0;
  for( ; (pos>>18) < 0777; showpos(pos |= bm[1]))
    srch(1, c^=9, -300, 300, pos);
}

-------------------------------------------------------------



On January 19, 1999 at 00:36:02, Dann Corbit wrote:

>On January 18, 1999 at 22:33:58, brian robson wrote:
>
>>I have no background in computer programming but would like to have my own chess
>>program. Can someone suggests where to start? Thanks.
>Start here:
>http://www.xs4all.nl/~verhelst/chess/programming.html
>
>Also look here:
>http://www.maths.nott.ac.uk/personal/anw/G13GT1/compch.html
>http://www.cs.ualberta.ca/~tony/ICCA/anatomy.html
>http://ourworld.compuserve.com/homepages/thstorm/comchepr.htm
>http://www.npac.syr.edu/copywrite/pcw//node341.html
>http://forum.swarthmore.edu/~jay/learn-game/indexes/other-papers.html



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.