Your first chess program.

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Your first chess program.

Post by Gerd Isenberg »

Already a quite experienced C and x86 assembly programmer, I started chess programming in the early 90s after I bought David Levy's Computer Chess Compendium by chance in a chess book store of a Dortmund chess tournament, studied it, specially the article on chess 4.x, and got fascinated and infected. About the same time I studied the "new" x86 bsf, bsr, btx instructions, and DOS IsiChess was bitboards and piecesets from the very beginning, with incremental attack tables, pieces en prise, and move lists...

Gerd
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Your first chess program.

Post by hgm »

In 1977, when I was working on my bachelor's degree in chemistry, a friend of mine, (who had a real job, and the money that came with it, but no knowledge of electronics), had bought a kit for home-building a computer, which he wanted to use to automate his model railway. When the system did not work after he soldered the components together, he brought it to me for troubleshooting, because I had an oscilloscope. In the two weeks that the computer was at my place, I wrote a Chess program for it in assembly code. (Well, more in machine code, actually: I had to poke the hexadecimal instructions into memory, as there was no symbolic assembler.)

The home-built system was based on a 1MHz 6800 CPU, had a 2KB memory card, a video card with 40 x 25 character resolution, 2KB of ROM for what we would now call the BIOS, and storage of programs on audio tape at 300 bits per second. The Chess program ('Usurpator I') did pretty much fill the entire 2KB RAM, and could not castle or e.p. capture. It could win KQK, though.
Jan Brouwer
Posts: 201
Joined: Thu Mar 22, 2007 7:12 pm
Location: Netherlands

Re: Your first chess program.

Post by Jan Brouwer »

I wrote my first chess program in hex code on a Ohio Scientific Superboard computer. It must have been around 1980, but I don't remember the exact year. The computer had a build-in Basic interpreter in an EPROM of a few Kbyte, and you could also modify bytes in memory by specifying an hex memory address and an hex value.
First I wrote the 6502 assembly code on paper, translated it by hand to machine code, calculated al the relative jump offsets, double checked everything, poked the program into memory, and ran it. Either something was displayed on the screen (which was an old black and white TV set which has such low light output that I had to close all the window curtains to be able to see anything), or nothing had happened, and I had to recheck my code on paper, trying to figure out what was wrong.
Things went a bit smoother when I was able to save programs to an audio cassette recorder, but that was later.
The program had a material only evaluation and no quiescence search, but it did have alpha-beta search, and already searched about 5 plies deep.
This was also the time that the (dutch) HCC Nieuwsbrief magazine ran a series of articles about computer chess.
I still have the Ohio Scientific Superboard, and I think I also still have the handwritten assembly / machine code somewhere.
I may also still have a little booklet with the assembly source code of H.G.'s Userpator program.

Jan
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Your first chess program.

Post by bob »

Dan Honeycutt wrote:Programmers,

How did you get into chess programming? What was your first program like?

In my case, the year was 1972. I was a graduate student at Georgia Tech. I had gotten into chess a few years before, inspired, like many of that era, by the ascent of Bobby Fisher. I figured it would be neat to write a chess program.

To run a program back then you typed each line of code on a punch card and carried your deck to ICS (Information and Computer Science). Your program then got a sliver of time on Tech's Burroughs B5500 mainframe. After a few minutes or hours depending on how busy they were, you got back your deck and output.

At least that's how it was for the unwashed masses. I had special privileges. I was on a research assistanceship doing work for the FAA. We were studying characteristics of flat cable. (Flat cable was sheets of conductors used in communications facilities which, today, would be a single fiber-optic cable.) Part of my work involved inverting large complex arrays. Complex as in R + jX, there was nothing complicated about it at all. I simply provided input to a canned program.

Now, the matrix inversion took time. Because of that I had a user number that allowed me long run times during the night hours. I also had access to teletype terminals in the EE department . The terminals had BASIC available and you could save your program on paper tape. None of this card deck misery for me!

With these advanced computing facilities available I set to work on my chess program. I had no idea what I was doing. I started with something like:

Code: Select all

10 DIM B(8,8)
"There, I've got a board to play on." I next defined pieces and went to work to make them move. After some weeks of steady work in the night hours when my user number was good my pieces could make, best I could tell, legal moves. Next I worked on a brute force sort of search - I'd never heard of alpha-beta pruning. I don't know what sort of NPS I was getting, but in a minute or so I could search 3 or 4 ply. My search was not slowed down by my evaluation. That consisted of nothing but material and proximity to the center.

I was quite pleased with myself. While far from competition for anyone other that a rank beginner, my program would capture anything left hanging and even found some simple combinations such as forks. Then one day the EE department secretary called me and told me I needed to schedule an appointment with Dr. Paris, the department head. That could not be good news. I was friendly with the secretary so I asked what it was about. She didn't know. That was even more ominous.

I arrived at Dr. Paris' office at the appointed time. After a few pleasantries he showed me a printout of the department's computing time costs - much of it attributable to me. Exorbitant I think was the term he used. I was completely taken aback. Naive as I was it had never dawned on me that computing time cost money. I considered lying and saying I'd been inverting lots of flat cable arrays but I came clean and told him about my chess program. He was actually quite nice about it. He said while my innovation was commendable the department simply couldn't afford it and my chess programming had to end.

Over the years I lost my last printout of my program. I would be interested in going back now to see what I did.

Best
Dan H.
My first one was "discovered" pretty cleverly. I started the first one in the Fall of 1968. One day the department chairman, who had gotten to know me pretty well came over to the lab and asked: "Hyatt, I have been watching you for 30 minutes. What on earth are you doing? I have seen you go to the keypunch lab, punch one card, stick it in the card reader, I watched the lights on the front of the /360 model 40 blink for a while, then I watched you go over to the printer, space it up a few times, and then back to the keypunch lab you go. Repeated several times. What ARE you doing over there?"

My response: "I'm playing chess."

His reply: "Of course you are, why did I even ask?"

This was in October of 1968. I got interested because of Spock playing the computer on Star Trek, I think the series started in 65 or 66... I had been playing since I was 10 or so, so it seemed like a good idea. :)
User avatar
JuLieN
Posts: 2949
Joined: Mon May 05, 2008 12:16 pm
Location: Bordeaux (France)
Full name: Julien Marcel

Re: Your first chess program.

Post by JuLieN »

My first chess program was programmed in Amiga Basic on my Amiga 500, around 1991-1992, and resulted from a bet with a friend who didn't believe Basic was a language powerful enough to allow the programming of a chess program. I won the bet ^^

For those who are interested in the detail, Eric Belot asked me to tell the story for his website. I think I managed to make it interesting, somehow :)
Bad translation from french to english, by Google: http://translate.google.com/translate?s ... index.html
"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: Your first chess program.

Post by Joost Buijs »

My first chess program was written during the end of 1977 in assembler for the Heatkit H8 (2MHz. 8080) and played it's first moves in januari 1978.
I don't remember much details, only that the move generator was able to generate 15k moves/sec. (rather fast for the hardware used). With full evaluation the program searched about 700 nodes/sec. The search depth was around 3 to 4 ply including quiescense. The playing strenght was approx. 1600 Dutch ELO.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Your first chess program.

Post by Evert »

Over summer holidays in 1992 or 1993 I wrote my first chess program in 8086 assembly language in a notebook. Then when I got home I implemented the thing (using inline assembly in Turbo Pascal).
I think I only had material evaluation and maybe piece square tables and no quiescence search. I discovered much later that there was a bug in the move generator caused by ignoring the piece type when setting the en-passant square, leading to hilarious results like 1. ... Qd7-d5 2. e5xd6ep
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Your first chess program.

Post by jdart »

I wrote a DOS-based program in Modula-2 back in 1991-2. It was never released. It had an integrated user interface written in assembly language, using direct video writes, supporting VGA and Hercules graphics modes (if you remember Hercules, you are an old-timer like me). The graphics was probably the best part of it, though, because the chess engine was junk, and like Dan, I was happy if it could solve mate in 4 or something like that. It tried to do some fancy dynamic eval with analysis of en prise pieces etc. - sort of like an eval function with integrated SEE. I'm ashamed to even show the code to this, although I still have the source.

Arasan was started from scratch some time later (1992?) and was C++, and more or less a conventional alpha-beta searcher with a hash table and null move, although I probably did lots of things wrong in my first implementation of this. Also it used Windows for UI (then a very new technology).

--Jon
Harald
Posts: 318
Joined: Thu Mar 09, 2006 1:07 am

Re: Your first chess program.

Post by Harald »

I wrote my first chess program "HLSchach" 1990 on the Atari ST.
It had a nice GEM GUI but the engine was poor and slow.
It was never released.

- The static evaluation was ok
- Alpha-beta search without any tricks
- No hash table
- Poor move ordering, but I tried to dynamically sort good moves to the top.
- The move generator kind of selected valid moves from the sorted list.
- Coded in C and German with a little English

Is anybody interested in the code? The zipped folder includes some pictures
and binaries and has about 400 kByte. Uncompressed source about 300 kByte.

Harald
F. Bluemers
Posts: 868
Joined: Thu Mar 09, 2006 11:21 pm
Location: Nederland

Re: Your first chess program.

Post by F. Bluemers »

Harald wrote:I wrote my first chess program "HLSchach" 1990 on the Atari ST.
It had a nice GEM GUI but the engine was poor and slow.
It was never released.

- The static evaluation was ok
- Alpha-beta search without any tricks
- No hash table
- Poor move ordering, but I tried to dynamically sort good moves to the top.
- The move generator kind of selected valid moves from the sorted list.
- Coded in C and German with a little English

Is anybody interested in the code? The zipped folder includes some pictures
and binaries and has about 400 kByte. Uncompressed source about 300 kByte.

Harald
ah,Atari ST :D I had one too
You used metacomco C too?
I once ported the basic code from "Das grosse ComputerschachBuch" to C on the Atari.
Data Becker had some real good books those days...