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

Simple chess program code

30 views
Skip to first unread message

Dorian

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

I am interested in chess programming, does anybody know where
I can find the source code (ANSI C) to a very simple chess program
(1200-1500 Elo) ?

Many Thanks

Dorian
pa...@globalnet.co.uk

Dave

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

Dorian, you hit the jackpot! See Komputer Korner's post for a list of
sites with Chess programs and those with source code.

Thanks to Ed Perry, I have about the simplest C source code for chess
you would ever want to see! It is written in Turbo C, not ANSI C.

It plays a limited number of openings, and the end game is woefully
poor, but it is quite OK in the mid game, taking a quick game from
another chess (dedicated) computer (admittedly a weak one). It has no
transposition table, and doesn't "think" on the opponent's time. Truly
primitive, but not stupid until the end game.

The user interface is the pits, with the board not even showing which
squares are black, and which are white! Other features are similarly
primitive, but the result is exactly what you're looking for: simple
chess program code.

I'll be making some small refinements in the code, and I'll post it
here so check back after bit. It will still be primitive, but at least
the board will be two-colored!

Enjoy!

Dave

Robert Hyatt

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

Dave (co...@sprintmail.com) wrote:

: On 3 Aug 1997 17:26:08 GMT, "Dorian" <pa...@globalnet.co.uk> wrote:

: >
: >I am interested in chess programming, does anybody know where
: >I can find the source code (ANSI C) to a very simple chess program
: >(1200-1500 Elo) ?
: >
: >Many Thanks
: >
: >Dorian
: >pa...@globalnet.co.uk

: Dorian, you hit the jackpot! See Komputer Korner's post for a list of
: sites with Chess programs and those with source code.

He didn't exactly "hit the jackpot." The problem is, as a program becomes
more competitive, it also gets bigger, more complicated, and harder to
understand. What we really need is a chess program, based on an offset
board representation (not bitmaps, for clarity's sake) with a simple
search/quiescehce, and a simple eval. *period*. Something that can be
read, studied, and serve as a starting point. Once upon a time, I'd hoped
that Crafty could fill this niche. It is now apparent that it can't, although
it can serve as "the next step" once the basics are out of the way...

: Thanks to Ed Perry, I have about the simplest C source code for chess


: you would ever want to see! It is written in Turbo C, not ANSI C.

: It plays a limited number of openings, and the end game is woefully
: poor, but it is quite OK in the mid game, taking a quick game from
: another chess (dedicated) computer (admittedly a weak one). It has no
: transposition table, and doesn't "think" on the opponent's time. Truly
: primitive, but not stupid until the end game.

this is the right idea, although we really need "simple *and* fairly
contemporary"... ie it should support hashing, since that is a common
idea in chess programs. Ditto for thinking on the opponent's time. But
it is a good step. Just so the author can figure out when to stop and
release a clean version, before going to more complicated (and harder to
understand) things like a horribly complicated eval.

: The user interface is the pits, with the board not even showing which

Dave

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

On 4 Aug 1997 13:09:57 GMT, hy...@crafty.cis.uab.edu (Robert Hyatt)
wrote:

>
>He didn't exactly "hit the jackpot." The problem is, as a program becomes
>more competitive, it also gets bigger, more complicated, and harder to
>understand.
Thanks for bringing me back to earth, Robert. I think you'll agree
that this is about as simple as a decent chess program can be. IMHO

> What we really need is a chess program, based on an offset
>board representation (not bitmaps, for clarity's sake) with a simple
>search/quiescehce, and a simple eval. *period*. Something that can be
>read, studied, and serve as a starting point.

That's *exactly* what this is. This is not *my* program, I'm just
making this pathetic interface go away (far and fast) in favor of
...something resembling sanity. The engine was written by the first
GNUChess author (also wrote "Zarkov", whatever that is). He appears to
me to have done a journeyman's job of it.

. . .

> ie it should support hashing, since that is a common
>idea in chess programs. Ditto for thinking on the opponent's time. But
>it is a good step. Just so the author can figure out when to stop and
>release a clean version, before going to more complicated (and harder to
>understand) things like a horribly complicated eval.

As the computer science books are fond of saying "Those are readily
implemented and so are left as exercises for the reader." Of course,
that's a *blatant* lie, but it shows those authors (and myself) have
a great sense of humor, and a good imagination.<g>

Seriously, I'm interested in everyone's opinion on this. As a learning
tool, and a lab to experiment with, this program could be used to show
the effect of several enhancements on the program's speed and
knowledge: hash table, thinking on the opponents time, improved end
game heuristics, better opening library, etc. Not interested in trying
to make it worthy of a trip to WMCC, just keeping it simple and
hopefully, very educational.

Sound off, NG! I may need some assistance/labor from some of the more
experienced programmers on the NG to create some of the above
features.

I'll post up the program code as soon as the interface is something
sane. Thanks for your input on this, Robert. I look forward to hearing
from *ALL* who are interested in creating/discussing/debating this
project.

It's current features include:

Text based mono board, with no light/dark squares. Just lines at the
edges of each square. Absolute pits - it's going!

Alpha-beta mm search with iterative deepening, killer heuristics.

Primitive Timer, which you can adjust in seconds. No overall time
controls handling such as for a tournament.

Principle Continuation/Variation may be shown on-screen.

Small opening library.

Nodes/Sec. and Total Nodes may be shown on-screen.

Will give hints for your move, upon request.

Move entry is by algebraic notation only.

Chess Board is reversible.

Games can be saved and re-loaded.

Draws with 3 X repetition, 50 move rule, and stalemate supported.

En Passant works, (but display isn't quite right, captured piece still
on board unless you type "redraw"!)

Castling both ways is fine. Won't allow castling thru sqr's attacked
by your opponent.

Board positions may be set-up.

Program will play against itself or a human, and can switch sides on
request.

Very poor end game heuristics & no hash table. OK opening and middle
game.

Code is not commented much, but is logically and clearly laid out,
IMHO. Variable names are well-chosen.

Dang thing spanks me most of the time - I just call it "beta testing"!
<beg>

I'll take a page out of KK's book and whip up some interest in this
program, fate willing! Thanks, KK!

Regards,
Dave

P.S. Also, I'm looking for *BASIC* source code for an alpha-beta
search for chess. Anybody got a little of *that* stuff around?
Please email me or post. Thanks in advance, I know this is *rare*!

(No, it's not for me, and *yes*, my friend is very serious about
making a full chess program in ***BASIC***. He's already got a very
nice GUI. BASIC? Go figure!)


John DeMastri

unread,
Aug 5, 1997, 3:00:00 AM8/5/97
to Dave

I'd be happy to donate time & effort to help with this project. I'm an
expeienced C++ programmer looking for just such an opportunity to come up to
speed in chess programming. Perhaps this isn't the type of people you're
looking for, but if it is, where do I start??

John DeMastri

Tom Kerrigan

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

In my program I basically have two board representations. One is for the
user interface. It's written such that the user can make moves and
take them back without bothering the rest of the program. This code is
very clear and not particularly fast because of what it's being used
for. It took maybe two hours to write, too. I imagine I could write a
fairly complete actual chess program that's just as easy to read in a day.
If anybody's interested, mail me. I might get around to it next week,
although God knows I have enough to do already. :(

Cheers,
Tom

Dave

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

On 6 Aug 1997 14:12:33 GMT, hy...@crafty.cis.uab.edu (Robert Hyatt)
wrote:

************* The K.I.S.S. Chess Program Project ****************

What we have:

A moderate strength chess engine, w/limited openings, OK middle game,
lousy end game performance, written in "C", fairly easy to follow.
Could use more comments in the code. Less than 1800 lines total, at
present. Thanks to Ed Parry for furnishing the program, and to the
author for designing it as a basic chess program, but not a joke.

Features of the engine include:

Full alpha-beta search, with iterative deepening, killer heuristics.
No hash table. No end game heuristics to my knowledge.

Other features are:

Text screen for resident user interface. Now has two-tone board, and
the chaotic numbers (here a number there a number, but what does it
mean?), is being fixed.

Will save and load a game, reverse the board, adjust playing time for
whatever amount per move you specify, and let you set up a position.

Will switch sides, give you hints, and show the principal
continuation, number of nodes searched, nodes searched / second. and
it's evaluation of the game in progress.

Nice, but you wouldn't mistake it for CM5000, Crafty, Ferret, Fritz,
Shredder, etc.

The Goal:

The purpose of the project is to produce the simplest, most readable
and easy to understand code, in a well-documented and strong chess
playing program. The source code will be *freeware*, and all will be
encouraged to study and alter it for their own use, as they wish.

By strong, I don't mean like Rebel, or MChess. I'm talking about a
moderately strong (like GNU Chess, perhaps?) program, in a code that's
two-third's the size, and three times as easy to understand.

It's meant as an educational tool, for all those interested in
computer chess, and chess programming. It's not a candidate for the
next computer chess championships.


The Method:

I have several (crazy) people who have graciously offered to help me
with this project. I intend to ask them, and others from this NG, for
their kind assistance in adding/changing all kinds of options: chess
"engine", I/O, user interface, etc.

The "C" language only will be used. (You're perfectly free to make
your own translations from it into whatever language you wish.) Those
who re-write it in assembly will be promptly directed to psychiatric
help!

As soon as I get the rest of the resident interface coded, I'll post
it and ask everyone to check it out and tell me what you think should
be done to improve it and still Keep It Simple, Smarty.

Pucker Up, People!. You're about to be KISS'd!!

Regards,
Dave D.

P.S. Attached is the Pseudo Code in "C" for the Alpha Beta Search.


.
>
>the only part of Crafty I'd suggest following is Quiesce(), which is
>simple, clean and fast. But the board representation is more complicated
>than needed for a "bare bones" starting point, which is the most serious
>problem with new programmers looking at Crafty. If something decent could
>be done in 2500 lines of code, that would be absolutely outstanding as it
>would be managable to read and understand.


Dave

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

Ed Parry

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

COPIES TO EMAIL & RGCC -

Hi Dave!

On Thu, 07 Aug 1997 00:34:41 GMT, co...@sprintmail.com (Dave) wrote:

>************* The K.I.S.S. Chess Program Project ****************
>
>What we have:
>
>A moderate strength chess engine, w/limited openings, OK middle game,
>lousy end game performance, written in "C", fairly easy to follow.
>Could use more comments in the code. Less than 1800 lines total, at
>present. Thanks to Ed Parry for furnishing the program, and to the
>author for designing it as a basic chess program, but not a joke.

No need to thank me at all. John Stanback came up with it. Just today
I was told via email that the Unix source can be located at

http://ftp.digital.com:80/pub/usenet/comp.sources.games/volume1

- The file is called CHESS.Z

Stanback is well known in the computer chess community. GNU Chess was
his work initially as I recall. He also wrote/writes the Zarkov Chess
programs, and I think his chess engine is used in at least one bigtime
commerical chess program.

>The Goal:
>
>The purpose of the project is to produce the simplest, most readable
>and easy to understand code, in a well-documented and strong chess
>playing program. The source code will be *freeware*, and all will be
>encouraged to study and alter it for their own use, as they wish.

Good project idea! I'd also LOVE to see a Chess programming FAQ for
beginner and intermediates with minimal coding or psudeo code.

Also, make sure GenChess (KISS) does not get too large. If you dig out
OLD GNU Chess/DOS versions, you'll see that the C source is only
80-90k and I suspect it plays substantially better then GenChess does.

Altho the code is followable, I have seen MUCH neater coding styles
(like BH's Crafty for example) and more comments would be welcome.

Good luck and have fun! Ep
Ed Parry - au...@lafn.org
I do the work of three men - Moe, Larry & Curly

Dave

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

begin 644 ABSEARCH.TXT
<encoded_portion_removed>
end

Harald

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

quoting a mail from hy...@crafty.cis.uab.edu


RH> the only part of Crafty I'd suggest following is Quiesce(), which is
RH> simple, clean and fast. But the board representation is more complicated
RH> than needed for a "bare bones" starting point, which is the most serious
RH> problem with new programmers looking at Crafty. If something decent could
RH> be done in 2500 lines of code, that would be absolutely outstanding as it
RH> would be managable to read and understand.

Hmm, I remember Genius2 which completely had/has only 165kB including
board representation....so it can't be that difficult...ask Richard. :-)


Harald Faber

Robert Hyatt

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

Harald (dirty...@sensecom.de) wrote:

: quoting a mail from hy...@crafty.cis.uab.edu

Er, I think that using assembly language would be just a "tad" in the
wrong direction, for a program that should be readable by beginners? :)


: Harald Faber

Scott Gasch

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

Dave <co...@sprintmail.com> wrote:
> On 6 Aug 1997 14:12:33 GMT, hy...@crafty.cis.uab.edu (Robert Hyatt)
> wrote:

> ************* The K.I.S.S. Chess Program Project ****************

Do you have any idea when the project might begin? How
many interested parties so far? What platform? How will
cooperation/version control work? Can anyone help? Is
there a mailing list? Organizational meetings?

As I mentioned in e-mail to Dave, the goal of the project
is wonderful and this is something I would like to help
with. If you are interested too, mail Dave (co...@sprintmail.com)
or me.

Scott

--
+------------+ <a href="http://perl.guru.org/scott">hp</a> +-----------------+
| Scott Gasch \ / scott@ |
| Computer Sci \ ``All programmers are playwrights and / perl.guru.org |
| Virginia Tech \ all computers are lousy actors'' / finger for PGP key |
+----------------+ +---------------------+
Send all unsolicited commercial email to postm...@fbi.gov and root@localhost

Anders Holtsberg

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

About the The K.I.S.S. Chess Program Project from
http://ftp.digital.com:80/pub/usenet/comp.sources.games/volume1

1) Is there a later release than 3-10-87
2) getchar() should be getch() in order not to
cause trouble on alpha machines.
3) On both my alpha and sparc the program says
silly things like "computer will soon mate"
and refuses to go further even though this is
very wrong.
4) A search on altavista gave nothing for +"K.I.S.S" +"chess"
or +GenChess so it seems like it isn't actively
maintained.
5) The email address to the author, r...@mirror.TMC.COM,
seems out of date. Well 10 years is a long time...

Since I like the idea of an extreamly simple and
readable program I want to get a bit into this.

Help or comments anyone?

Anders Holtsberg

Dave

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

On 12 Aug 1997 11:25:40 GMT, and...@maths.lth.se (Anders Holtsberg)
wrote:

Great! Love to have your help, Anders.

I am not aware of any later versions, and I wouldn't think we needed
one. As long as we have fairly decent coding to read, we'll take care
of the rest. <IMHO>

Now I know to play the program on a sparc or alpha computer! When I
(ahem!) "let" it mate me on a DOS machine (all in the name of testing,
of course!) it doesn't stop, and it's very right.

If you would like to test our code from time to time, on the alpha and
sparc computers, that would be a big help. Of course, I look forward
to all other comments you may have as well concerning the code, the
features needed/desired, etc.

Although this chess program is fairly readable, and can be made even
more so by adding the appropriate comments throughout, no chess
program is extremely simple. If we can divide up the work, though, it
should be fun and if we stay focused on our goal, relatively simple.

On Sunday next, I'll be posting up the revised code. Until then, if
you get a chance, can you see what other code problems we have when
running it on a sparc or an alpha computer?

Thanks a bunch, Anders. 'Till Sunday.

Dave

>Since I like the idea of an extreamly simple and
>readable program I want to get a bit into this.
>

>Anders Holtsberg


Tom Kerrigan

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

Yes, I think GNU 1 and 2 were written mainly by some guy named Stuart
Cracraft (sp?) who also wrote Gazebo chess which was around for a while.
I've never run across the early GNU's, but Gazebo is VERY squishy (I
can beat it as a human) so I imagine the GNU's were too. I think
Stanback basically rewrote the thing and called it 3.0, and it's actually
a good program, dispite a lot of people who slam it these days. Then
he went off and worked on Zarkov, which was a well known (and strong)
commercial program but hasn't been updated for a while so not a lot of
the newbies know about it. I have read a few back issues of CSS, circa
92/93, and it seems everybody had a copy of Zarkov in one form or another.

Cheers,
Tom

Ed Parry (au...@lafn.org) wrote:
: COPIES TO EMAIL & RGCC -

: Hi Dave!

: On Thu, 07 Aug 1997 00:34:41 GMT, co...@sprintmail.com (Dave) wrote:

: >************* The K.I.S.S. Chess Program Project ****************

Tom Kerrigan

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

I've been writing my own insanely simple chess program. All it needs now
is an evaluation function. I should be posting it for download later this
week.

Cheers,
Tom

Anders Holtsberg (and...@maths.lth.se) wrote:

: About the The K.I.S.S. Chess Program Project from
: http://ftp.digital.com:80/pub/usenet/comp.sources.games/volume1

: 1) Is there a later release than 3-10-87
: 2) getchar() should be getch() in order not to
: cause trouble on alpha machines.
: 3) On both my alpha and sparc the program says
: silly things like "computer will soon mate"
: and refuses to go further even though this is
: very wrong.
: 4) A search on altavista gave nothing for +"K.I.S.S" +"chess"
: or +GenChess so it seems like it isn't actively
: maintained.
: 5) The email address to the author, r...@mirror.TMC.COM,
: seems out of date. Well 10 years is a long time...

: Since I like the idea of an extreamly simple and


: readable program I want to get a bit into this.

: Help or comments anyone?
:

: Anders Holtsberg

0 new messages