Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tom Kerrigan's Simple Chess Program

279 views
Skip to first unread message

brucemo

unread,
Aug 13, 1997, 3:00:00 AM8/13/97
to

Tom Kerrigan wrote:
>
> This is just a post to announce that I'm done with TSCP, and you can find
> the sources at my homepage, http://www.frii.com/~kerrigan It's a "heavily"
> commented program that's around 1,000 lines long, written for readability.
> I think beginners will find it quite useful.

This is cool, I like it.

One thing that would help is if you used the preprocessor more. You have
lots of instances of things like "if (i & 32) ...", and you'll do things like
have a switch statement where the selector is a board index, and you'll have
things like "case 60:". It would be more readable if you covered these with
#defines, for instance "if (i & PROMOTES) ..." and "case E8:".

bruce

Tom Kerrigan

unread,
Aug 13, 1997, 3:00:00 AM8/13/97
to

I use two bitfields in the program, one to describe castling permissions
and another to describe a move. I think the bits to the latter are
explained at the top of data.c and the former is at defs.h. If I used
the preprocessor to mangle the bits, I think it would actually decrease
readability. On the other hand, it would probably be good if I put all
the castling code in coordinate notation... I'll put this on my todo
list (which is unfortunately fairly full).

Cheers,
Tom

brucemo (bru...@seanet.com) wrote:

Tom Kerrigan

unread,
Aug 13, 1997, 3:00:00 AM8/13/97
to

This is just a post to announce that I'm done with TSCP, and you can find
the sources at my homepage, http://www.frii.com/~kerrigan. It's a "heavily"

commented program that's around 1,000 lines long, written for readability.
I think beginners will find it quite useful.

Cheers,
Tom

Hristo Doichev

unread,
Aug 13, 1997, 3:00:00 AM8/13/97
to

Tom,
great job ... it's so simple that's perfect for everyone who wants to test
things out or build upon it !!!
Thank you Sir !
Hristo

Tom Kerrigan wrote in article <5srnqt$972$1...@europa.frii.com>...

Tim F. Ginnett

unread,
Aug 14, 1997, 3:00:00 AM8/14/97
to

My game against Tom Kerrigan's Simple Chess Program..

First let me say thanks Tom for doing this...I hope to learn alot from
examining the code. I was unable to compile the program with Microsoft's
compiler (several errors and warnings) but used an old Borland Turbo C++
compiler for DOS. It compiled with one warning concerning the in_check
function (sorry didn't write it down).

I then tried playing a game which went .......

1. d4 Rxg8 and I didn't bother playing any further!

the line it was examining was something like (from memory) 1... Rxg8 2.
Rxb1 d5 after which it gave a score of -24......... Is there a problem in
the legal move testing?

Tim


Ed Parry

unread,
Aug 14, 1997, 3:00:00 AM8/14/97
to

On 13 Aug 1997 19:35:14 GMT, kerr...@deimos.frii.com (Tom Kerrigan)
wrote:

Tom Kerrigan wrote:
>
> This is just a post to announce that I'm done with TSCP, and you can find

> the sources at my homepage, http://www.frii.com/~kerrigan It's a "heavily"


> commented program that's around 1,000 lines long, written for readability.
> I think beginners will find it quite useful.

Hi TK!

Just grabebd it - much thanks - I like tinkering and trying to learn
from these critters (I seem to be in the DOLT category of chess
programmers).

Perhaps ONE little suggestion - a README.TXT file with a brief
overview of the program?

Thanksa gain! Ep


Ed Parry - au...@lafn.org
I do the work of three men - Moe, Larry & Curly

Martin Borriss

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

In article <tj20t5...@unox.hak.nl>,
Marcel van Kervinck <mar...@unox.hak.nl> writes:
>For the strange game: My guess is that your compiler somehow
>uses 16 bit ints. The program assumes an int is wider than that.
>See if your compiler has an option to switch to 32 bit ints.
>
>The program is way cool as a beginners aid, I must say.

Borland Turbo C compilers do have 16bit ints only. You will have to
use long ints. Search and replace or use the preprocessor for this...

Martin

P.S.: It does play chess:

gics%
Statistics for TSCP (Last disconnected Thu Aug 14 1997, 18:02 MET
DST):

rating RD win loss draw total best
Blitz 1507 88.7 48 9 2 59 1718 (14-Aug-97)
Standard ---- 350.0 0 0 0 0
Lightning 1824 112.0 3 9 1 13
Wild ---- 350.0 0 0 0 0
Bughouse ---- 350.0 0 0 0 0
Atomic ---- 350.0 0 0 0 0
Suicide ---- 350.0 0 0 0 0


1: Tom Kerrigan's Simple Chess Programm

--
Martin....@inf.tu-dresden.de
.

Marcel van Kervinck

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

Tim F. Ginnett <t-gi...@tamu.edu(REMOVE THIS)> wrote:
> First let me say thanks Tom for doing this...I hope to learn alot from
> examining the code. I was unable to compile the program with Microsoft's
> compiler (several errors and warnings) but used an old Borland Turbo C++
> compiler for DOS. It compiled with one warning concerning the in_check
> function (sorry didn't write it down).

Probably something like warning for in_check() being able to return
nothing at all, which can be discarded. If this is the warning,
speed up the program and remove the warning by diking out the
i<64 test in the for-loop. This way you replace the bounded
linear king search by a plain linear search.

I'm getting tons of warnings when I compile it, but most seem
pretty harmless.

> I then tried playing a game which went .......
> 1. d4 Rxg8 and I didn't bother playing any further!
> the line it was examining was something like (from memory) 1... Rxg8 2.
> Rxb1 d5 after which it gave a score of -24......... Is there a problem in
> the legal move testing?

For the strange game: My guess is that your compiler somehow


uses 16 bit ints. The program assumes an int is wider than that.
See if your compiler has an option to switch to 32 bit ints.

The program is way cool as a beginners aid, I must say.

Marcel
-- _ _
_| |_|_|
|_ |_ mar...@stack.nl
|_| Marcel van Kervinck

Tim F. Ginnett

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

Thanks....the 16/32 bit int problem didn't occur to me. I will see what I
can do to work around it. I spent alot of time going throught the code
last night and you are right....it is "way cool" and I have learned some
neat tricks already.

Tim

Martin Borriss <bor...@inf.tu-dresden.de> wrote in article
<5t1720$aom$1...@os.inf.tu-dresden.de>...


> In article <tj20t5...@unox.hak.nl>,
> Marcel van Kervinck <mar...@unox.hak.nl> writes:

> >For the strange game: My guess is that your compiler somehow
> >uses 16 bit ints. The program assumes an int is wider than that.
> >See if your compiler has an option to switch to 32 bit ints.
> >
> >The program is way cool as a beginners aid, I must say.
>

Hristo Doichev

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

This is interesting.
It compiled without any warnings or errors the first time !!!
I'm using MS C++ 5.0 ... crate a new console project add all ".c" files
and voila works like a champ. Granted there are things that need to be
fixed,
but this is where the fun begins ... :)))

take care.
Hristo

Tim F. Ginnett wrote in article
<01bca8b8$fb560a20$693b...@t-ginnett.tamu.edu>...

>My game against Tom Kerrigan's Simple Chess Program..


>
>First let me say thanks Tom for doing this...I hope to learn alot from
>examining the code. I was unable to compile the program with Microsoft's
>compiler (several errors and warnings) but used an old Borland Turbo C++
>compiler for DOS. It compiled with one warning concerning the in_check
>function (sorry didn't write it down).
>

>I then tried playing a game which went .......
>
>1. d4 Rxg8 and I didn't bother playing any further!
>
>the line it was examining was something like (from memory) 1... Rxg8 2.
>Rxb1 d5 after which it gave a score of -24......... Is there a problem in
>the legal move testing?
>

>Tim
>
>
>

Ed Parry

unread,
Aug 16, 1997, 3:00:00 AM8/16/97
to

On Fri, 15 Aug 1997 00:59:09 +0200, Marcel van Kervinck
<mar...@unox.hak.nl> wrote:

>> First let me say thanks Tom for doing this...I hope to learn alot from
>> examining the code. I was unable to compile the program with Microsoft's
>> compiler (several errors and warnings) but used an old Borland Turbo C++
>> compiler for DOS. It compiled with one warning concerning the in_check
>> function (sorry didn't write it down).

Agreed - Thanks go out to TK for offering this critter openly. VERY
nicely done.

Compilers - So far - Quick C v2.5 and MSC60 seem to do fine for me. No
warning or errors and it runs fine. When I use Turbo C v2.0 or
Borlands C++ v3.1 (standard DOS EXE outout) TSCP starts replacing
pieces on teh board. TK suggested that it might not be a 32 bit
compiler, but I do not recall that Quick C v2.5/MSC60 is either - at
least not without me directing it to be. Anyways, I am stuck - I
tinkered alot with the Borland compilers but could not solve the
problem. Adding #define int long causes a TOO MUCH GLOBAL DATA error;
I even tried using the HUGE memory model and a project file to compile
and link the file individually (I made them all into one 30k soruce
file). Quick C just chugs thru the file (without the #define int long)
and works well. Just has me all perplexed.

Have yet to try it with any other compilers such as Power C v2.0 or
DJGPP v2.x, etc.

>I'm getting tons of warnings when I compile it, but most seem
>pretty harmless.

You can kill certain warnings in Borland compilers - things like:

FUNCTION DOES NOT RETURN A VALUE

and

IDENTIFIER 'ident' IS NOT USED IN FUNCTION xxxxxx

can be turned off. I had to do this to get GenChess.C to compile with
Turbo C v2.0.

I do recall a CONSTANT IS LONG error in TC/BC and I shut it off. I'll
have to recheck - perhaps this is where I would need to change a few
int defines to long's orperhaps the LONG is getting chanegd to an int
in the final program. ie: Still intend to to tinker with it.

>> I then tried playing a game which went .......
>> 1. d4 Rxg8 and I didn't bother playing any further!

Sounds ALOT like my problem(s) with TSCP. I think it IS the 16 vs 32
bit problem, but for Borlands compilers I've not found a solution yet.
IF I do, I'll post it. I suspect DJGPP

>> the line it was examining was something like (from memory) 1... Rxg8 2.
>> Rxb1 d5 after which it gave a score of -24......... Is there a problem in
>> the legal move testing?

No - I think this is the lack of 32 bits for the bitboards based legal
move generator.

>The program is way cool as a beginners aid, I must say.

I second that! Nice job and thanks TK! Ed

Komputer Korner

unread,
Aug 17, 1997, 3:00:00 AM8/17/97
to

> Tom Kerrigan wrote:
> >
> > This is just a post to announce that I'm done with TSCP, and you can
> find
> > the sources at my homepage, http://www.frii.com/~kerrigan It's a
> "heavily"
> > commented program that's around 1,000 lines long, written for
> readability.
> > I think beginners will find it quite useful.
>
>

Tom, your new chess baby is fantastic. Better watch out. The tower of
Babel that is the r.g.c.c. will make sure that it grows and grows. It
may even take over Stobor some day.

--

Best regards
Komputer Korner

The inkompetent komputer

If you see a 1 in my email address, take it out.
Note that my true email is still kor...@netcom.ca
I don't often check the email of the sympatico address.

Tim F. Ginnett

unread,
Aug 19, 1997, 3:00:00 AM8/19/97
to


Ed Parry <au...@lafn.org> wrote in article
<33f60c1c...@news.lafn.org>...


> On Fri, 15 Aug 1997 00:59:09 +0200, Marcel van Kervinck
> <mar...@unox.hak.nl> wrote:
>
> >> First let me say thanks Tom for doing this...I hope to learn alot from
> >> examining the code. I was unable to compile the program with
Microsoft's
> >> compiler (several errors and warnings) but used an old Borland Turbo
C++
> >> compiler for DOS. It compiled with one warning concerning the in_check
> >> function (sorry didn't write it down).
>
> Agreed - Thanks go out to TK for offering this critter openly. VERY
> nicely done.
>
> Compilers - So far - Quick C v2.5 and MSC60 seem to do fine for me. No
> warning or errors and it runs fine. When I use Turbo C v2.0 or
> Borlands C++ v3.1 (standard DOS EXE outout) TSCP starts replacing
> pieces on teh board. TK suggested that it might not be a 32 bit
> compiler, but I do not recall that Quick C v2.5/MSC60 is either - at
> least not without me directing it to be. Anyways, I am stuck - I
> tinkered alot with the Borland compilers but could not solve the

> problem. Adding #define int long causes a TOO MUCH GLOBAL DATA error;....

I had the same problem until last night. Using the preprocessor to
redefine int (#define int long) did not work. However, for some reason
when I explicitly replaced every instance of 'int' with 'long' I got a
compiled version that works. I do have a question though.....the scores
that it gives after each ply seems mysterious..... e.g.

ply score
1 24
2 115
3 1153
4 12563

Do I have another compiler problem? The program seems to be making logical
chess moves now.

Tim

Rotes Sapiens

unread,
Aug 22, 1997, 3:00:00 AM8/22/97
to

On Sat, 16 Aug 1997 20:38:29 GMT, au...@lafn.org (Ed Parry) wrote:

>On Fri, 15 Aug 1997 00:59:09 +0200, Marcel van Kervinck
><mar...@unox.hak.nl> wrote:

>>> First let me say thanks Tom for doing this...I hope to learn alot from
>>> examining the code. I was unable to compile the program with Microsoft's
>>> compiler (several errors and warnings) but used an old Borland Turbo C++
>>> compiler for DOS. It compiled with one warning concerning the in_check
>>> function (sorry didn't write it down).

>Agreed - Thanks go out to TK for offering this critter openly. VERY
>nicely done.

I missed the original post. Where can I get the program?


Does anyone know where this !@#$%! six wheeled robot came from?


Dan Thies

unread,
Aug 22, 1997, 3:00:00 AM8/22/97
to

On 14 Aug 1997 13:57:59 GMT, "Tim F. Ginnett"
<t-gi...@tamu.edu(REMOVE THIS)> wrote:

>My game against Tom Kerrigan's Simple Chess Program..

(snip)


>1. d4 Rxg8 and I didn't bother playing any further!

Why not? The program sacrificed the exchange on the
first move!

8-)

Dan

Dan Thies

unread,
Aug 23, 1997, 3:00:00 AM8/23/97
to

From Tom's original post, here's where to get TSCP.

Dan

>This is just a post to announce that I'm done with TSCP, and you can find

>the sources at my homepage, http://www.frii.com/~kerrigan. It's a "heavily"


>commented program that's around 1,000 lines long, written for readability.
>I think beginners will find it quite useful.

>Cheers,
>Tom


On Wed, 20 Aug 1997 11:18:13 -0400, Marc Thornton <ma...@bon.net>
wrote:

>Marcel van Kervinck wrote:
>>
>> Tim F. Ginnett <t-gi...@tamu.edu(REMOVE THIS)> wrote:

>> > First let me say thanks Tom for doing this...I hope to learn alot from
>> > examining the code. I was unable to compile the program with Microsoft's
>> > compiler (several errors and warnings) but used an old Borland Turbo C++
>> > compiler for DOS. It compiled with one warning concerning the in_check
>> > function (sorry didn't write it down).
>>
>
>

>Hey, Where can I get simple chess at??? I have been trying to find it
>but am having trouble...
>
>
>thanks,
>
>
> marc...


0 new messages