small chess program source

8 views
Skip to first unread message

ALEXANDER R PRUSS

unread,
Nov 6, 2001, 4:05:10 PM11/6/01
to
I'd love to get source for a small chess program, in C (or Z80 assembly
language!) This would be for porting to a cheap Z80-based PDA that
has 32K of linear SRAM available (one can page in an extra 16k but
access to that is through special library routines; this is the
Sharp OZ/ZQ-7xx.) Anybody have such a thing? I tried the Stanbeck
program, but even after pruning down the data structures, it used
too much memory.

Alex

--
Dr. Alexander R. Pruss || e-mail: pr...@member.ams.org
Philosophy Department || home page:
Georgetown University || www.pitt.edu/~pruss
New North Building, Room 215 \================================
37th & O Streets
Washington, DC 20057
U.S.A.
-----------------------------------------------------------------------------
"Philosophiam discimus non ut tantum sciamus, sed ut boni efficiamur."
- Paul of Worczyn (1424)

Adolf Hammer

unread,
Nov 6, 2001, 3:34:04 PM11/6/01
to

"ALEXANDER R PRUSS" <pru...@pitt.edu> wrote in message
news:9s9ja6$ikq$2...@usenet01.srv.cis.pitt.edu...

> I'd love to get source for a small chess program, in C (or Z80 assembly
> language!) This would be for porting to a cheap Z80-based PDA that
> has 32K of linear SRAM available (one can page in an extra 16k but
> access to that is through special library routines; this is the
> Sharp OZ/ZQ-7xx.) Anybody have such a thing? I tried the Stanbeck
> program, but even after pruning down the data structures, it used
> too much memory.

Search on TSCP or Tom's Small Chess Program.

Or any experienced chess programmer should be able to write you a
bean-counter in about two-three weeks or so. What do you want the thing for?
Commercial, or?

ALEXANDER R PRUSS

unread,
Nov 6, 2001, 5:19:16 PM11/6/01
to
Adolf Hammer (nos...@nospam.com) wrote:
: Search on TSCP or Tom's Small Chess Program.

: Or any experienced chess programmer should be able to write you a
: bean-counter in about two-three weeks or so. What do you want the thing for?
: Commercial, or?

Just freeware.

Adolf Hammer

unread,
Nov 6, 2001, 4:34:02 PM11/6/01
to

"ALEXANDER R PRUSS" <pru...@pitt.edu> wrote in message
news:9s9nl4$jq9$1...@usenet01.srv.cis.pitt.edu...

> Adolf Hammer (nos...@nospam.com) wrote:
> : Search on TSCP or Tom's Small Chess Program.
>
> : Or any experienced chess programmer should be able to write you a
> : bean-counter in about two-three weeks or so. What do you want the thing
for?
> : Commercial, or?
>
> Just freeware.

Tom's thing ought to do the trick.

Robert Hyatt

unread,
Nov 6, 2001, 6:14:52 PM11/6/01
to
ALEXANDER R PRUSS <pru...@pitt.edu> wrote:
> Adolf Hammer (nos...@nospam.com) wrote:
> : Search on TSCP or Tom's Small Chess Program.

> : Or any experienced chess programmer should be able to write you a
> : bean-counter in about two-three weeks or so. What do you want the thing for?
> : Commercial, or?

> Just freeware.

> Alex

Bruce Moreland has written a very nice program called "Gerbil". It has
played on ICC, is small source, but has a few more features that TSCP.

I don't have a linke, but if you log on to ICC you can probably find it
by "finger mouse" (mouse is Bruce's handle on ICC). A net-search for
gerbil might get you a link. It will also get you a lot of _unwanted_
links too. :)


> --
> Dr. Alexander R. Pruss || e-mail: pr...@member.ams.org
> Philosophy Department || home page:
> Georgetown University || www.pitt.edu/~pruss
> New North Building, Room 215 \================================
> 37th & O Streets
> Washington, DC 20057
> U.S.A.
> -----------------------------------------------------------------------------
> "Philosophiam discimus non ut tantum sciamus, sed ut boni efficiamur."
> - Paul of Worczyn (1424)


--
Robert Hyatt Computer and Information Sciences
hy...@cis.uab.edu University of Alabama at Birmingham
(205) 934-2213 115A Campbell Hall, UAB Station
(205) 934-5473 FAX Birmingham, AL 35294-1170

goldfish

unread,
Nov 6, 2001, 10:19:01 PM11/6/01
to
The is a book called something like "Sargon - a computer chess program"
which has the source
code in some non standard Z80 assembly language syntax. It is an old
program but it is very small.
You will need to change the gfx routine though.


"ALEXANDER R PRUSS" <pru...@pitt.edu> wrote in message
news:9s9ja6$ikq$2...@usenet01.srv.cis.pitt.edu...

ALEXANDER R PRUSS

unread,
Nov 7, 2001, 9:17:13 AM11/7/01
to
Well, TSCP doesn't work. It generates about 20K of data as directly
compiled, which together with about 20K of code won't fit in 32K of
memory. Moreover, it's unportable: it assumes 32-bit integers, whereas
8- and 16-bit compilers usually have 16-bit ones. One could fix those
to longs, but that would increase memory usage, and I would have
to understand the internals of the code to see where to change ints to longs.

Alex

ALEXANDER R PRUSS

unread,
Nov 7, 2001, 9:23:25 AM11/7/01
to
Robert Hyatt (hy...@crafty.cis.uab.edu) wrote:
: Bruce Moreland has written a very nice program called "Gerbil".

Alas, it uses 64-bit integers in the code in places. These could be
replaced with a struct, but then one would have to implement the
arithmetic on them. Not too hard, but my guess is that code that
uses 64-bit integers likely uses a lot of memory as well. Not a
very strict inference, but a plausible one.

Alex

Russell

unread,
Nov 7, 2001, 3:02:13 PM11/7/01
to

PubPost

unread,
Nov 8, 2001, 12:54:27 AM11/8/01
to
pru...@pitt.edu (ALEXANDER R PRUSS) wrote in message news:<9s9ja6$ikq$2...@usenet01.srv.cis.pitt.edu>...

> I'd love to get source for a small chess program, in C (or Z80 assembly
> language!) This would be for porting to a cheap Z80-based PDA that

This is going to be a stupid question but....

How complete does the chess program have to be?

I know for certain that I have several old chess programs that would
fit, but they don't have an opening book, they play basic chess but
not the full rules, no draw by repetition, etc.

These were written on an old 64k 8 bit system in k&r C, so I'm nearly
certain they'd fit into your system. Simple keyboard / text
interface. (I'd have to find them, though. The floppy disks are in
storage.)

If you get really desperate, there is a 1k chess program for the zx81
in source. I saw it mentioned on the net. (Too bad nobody can find
the source for the classic Kim-1 chess program...)

You could always disassembly something like MyChess for the TRS-80
Model 1 and port it, but I'm sure you would want to do that.

And I think I have one written for the Commodore 64. The user
interface is in BASIC and the very simple search engine in 6502
assembly. (It's small enough to rewrite, though.)

I think I have one for an old FORTRAN system, and it probably doesn't
use much memory.


But the point is, none of these play full, 100% legal chess. I don't
think Sargon-1 did either, actually. But more so than these things.

ALEXANDER R PRUSS

unread,
Nov 8, 2001, 10:19:41 AM11/8/01
to
PubPost (pub...@yahoo.com) wrote:
: How complete does the chess program have to be?

: I know for certain that I have several old chess programs that would
: fit, but they don't have an opening book, they play basic chess but
: not the full rules, no draw by repetition, etc.
:
: These were written on an old 64k 8 bit system in k&r C, so I'm nearly
: certain they'd fit into your system. Simple keyboard / text
: interface. (I'd have to find them, though. The floppy disks are in
: storage.)

That might do given what a poor chess player I am, and that I'd just like
something to play with while on the bus, and for others to do the same
with.

: If you get really desperate, there is a 1k chess program for the zx81


: in source. I saw it mentioned on the net. (Too bad nobody can find
: the source for the classic Kim-1 chess program...)

Yeah, I've seen that. That's an option.

: But the point is, none of these play full, 100% legal chess. I don't


: think Sargon-1 did either, actually. But more so than these things.

Well, I'm going to wait to see if I can get copyright clearance for Sargon
from the people (Pearson Education) who seem to be the present copyright
holders on Hayden Press books. I faxed them a request.

My guess is also that if I take the book out of a library, there would
be no problem with taking the source for my own use. After all, isn't
that what it was published for? Or was it maybe only for the use of those
who actually owned a copy of the book?

PubPost

unread,
Nov 8, 2001, 11:04:27 PM11/8/01
to
pru...@pitt.edu (ALEXANDER R PRUSS) wrote in message news:<9se7qd$lg6$1...@usenet01.srv.cis.pitt.edu>...

> PubPost (pub...@yahoo.com) wrote:
>
> : I know for certain that I have several old chess programs that would
>
> That might do given what a poor chess player I am, and that I'd just like
> something to play with while on the bus, and for others to do the same
> with.

I've found one of them and I'm going ahead and sending it to you.
"Kelly" chess. (It was named after a friends girlfriend...)

This one looks like it has repetition detection, 50 move rule, depth
search,
time search, etc. No opening book. No thinking on oponents time.

It was written for an 8 bit computer. (Actually, the Tandy Color
Computer
3, with a 6809 microprocessor, running at 1.89mhz and running the OS9
Level
2 operating system.) It was written in k&r style C using Microwares C
compiler.

As written, it looks like it takes about 16k of data. The code would
be
about 16k-20k as written. Depending on the compiler. Probably less if
translated into assembly.

8k of the data is taken by the "history heuristic" which is what
dynamically
orders the moves. That could be removed and replaced with a few lines
of
code that statically orders the moves.

The code is copyrighted freeware. Pretty much free to do what you
want as
long as I'm listed as the original author.

I haven't compiled it with TurboC (the only free 16 bit DOS compiler I
have), but it looks like I made an effort to make it portable, so it'd
probably work.

I've got two more that I haven't found yet. Not sure what size they
are or
what features they have. One was a "Let's write a chess program"
tutorial
that I published.

I think I also have one in Pascal, if you prefer that.

ScottK

unread,
Nov 10, 2001, 11:06:31 AM11/10/01
to

"PubPost" <pub...@yahoo.com> wrote in message
news:b46bdf70.01110...@posting.google.com...

> I've found one of them and I'm going ahead and sending it to you.
> "Kelly" chess. (It was named after a friends girlfriend...)
>
I would also very much like to take a look at this if you wouldn't mind.

TIA,
Scott


PubPost

unread,
Nov 10, 2001, 10:46:34 PM11/10/01
to
"ScottK" <rki...@concentric.net> wrote in message news:<9sjja7$n...@dispatch.concentric.net>...


Sure.

But it might be a few days before I can find the right copy to send.

I thought I had found one, which is what I sent to him, but it had
some errors in it, so I doubt it was my final version.

I've been going through all my old chess disks. It's a little hard to
follow because it's been nearly 10 years. A lot of disk labels have
fallen off. I think I'm missing a box or two. I've gone through
several moves and disks have spilled and been tossed back in.

It looks like:

1) I went through a series of poor chess programs. Most in Pascal.

2) I switched to C (and a new OS) and started over.

3) I wrote several small ones. I also wrote a couple "How to write a
chess program" type of tutorials.

4) I wrote a very big one, with opening book, transposition table,
clocks, etc. Pretty complete. It required about 100k to run. The
search was done as a background task in its own 64k address space. It
was based on John Stackbacks pub domain 1987 version with a few ideas
from GNU chess (v3?) It was very system specific.

5) I decided "small is beautiful" and "Portability is cool" and
started on an extremely small version.

6) I decided to make it compile with SMALL-C, which was a popular C
subset back in the 80's.

7) I wrote Kelly, versions 1-4. Part way through I decided just to
stay with k&r C but keep it simple. I kept it as self contained as
possible with little dependance on any compiler libraries. The only
OS requirements were character I/O and a clock source.

8) I renamed to "ARChess" and went up to version 9.

I don't see anything that is beyond that for certain.


I do see several excursions, where I went back to an old version to
test something. And one spot where I tried to add a GUI with graphic
pieces to one of them. And a time where I ported John Stackback's
1987 version. And where I tried to port the Zorland / Zortech chess
program to my little machine.

At one time I even thought about trying to write one for the 8051 but
gave up.

And so on.

I think I've found the last simple version, but I'm going to have to
check a bit further. I can't even depend on file dates because the
old 8 bit computer didn't have a clock. I had to enter the time by
hand and I often didn't do that. (Ahhh, the joys of yesteryear.)

I'd also like to make sure it compiles and runs with Borland's free 16
bit DOS compiler, Turbo C.


And of course, all of this was written in k&r C. The OS vendor
(Microware) only realeased that one C compiler. No bug fixes, no
updates. Terrible optimizations. Terrible warnings levels. Etc. So
I probably should take the oportunity and add some function prototypes
etc. to it.


ARChess 9 is a little bigger than the last Kelly. 21398 instead of
20649 (for the compiler & options I was using back then), plus data &
stack space, of course. Part of that is the command processor, I/O,
etc. It could be cut out without effecting game play.

I'm not sure how much data space it took. It looks like ARChess took
about 6k for basic play data, 3k for game history (so you can unmake
moves), plus 8k for the history heuristic (for move sorting), plus an
unknown amount of stack space. Some of the space can be reduced by
reducing certain limits or manually removing features.

It fit easily into the 64k address space, but I'm not sure exactly
what the total requirements were.

A couple of earlier ones are smaller but have fewer features and I
don't remember what bugs they had.

Reply all
Reply to author
Forward
0 new messages