Your first chess program.

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 4:31 pm
Location: Atlanta, Georgia

Your first chess program.

Post by Dan Honeycutt »

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.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Your first chess program.

Post by mar »

Well I started in 2006. So much later than you :). I had no clue about how a chess program works, no clue about alphabeta until i read some papers. Did know nothing about UCI, CECP; never heard of Rybka back then,...
(But I knew Rebel because of Ed's pages about chessprogramming, so thanks)
It was a SDL-based GUI app. What it did was in fact multipv all (I really had no clue :). It did a fixed depth 3-ply search, no quiescence and it was incredibly slow. But i still remember when i played my first game against my own chess program. An exciting experience. It really moved the pieces around the board ;)
In case someone wants to see cheng1 in action and laugh, here's the link (Windows only).
http://www.mediafire.com/?fwqj59mzk14vv92

PS Piece images were borrowed from wikipedia diagrams, I hope I don't get accused of theft ;)
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Your first chess program.

Post by tpetzke »

I started somewhat 1992 with my first computer a 286 after reading in a computer magazine about game theory and the article included a bit of alpha beta pseudo code. I found that very interesting and started to develop a few games like draughts, reversi (othello), 4 wins and also a chess variant where the player wins that loses all its pieces first. The programs searched 5 to 6 ply and played reasonably well means I was challenged to win.

For many years I did then nothing related to game programming until 2009 where I started with a real chess program. I had no idea about protocols and engines so it was a chess playing GUI written in Pascal. I later decoupled the engine from the GUI and in 2011 I switched the language to C++ and started all over.

It is strong enough to beat the crap out of me by now but there is still room for improvement, lots of...

Thomas...
BubbaTough
Posts: 1154
Joined: Fri Jun 23, 2006 5:18 am

Re: Your first chess program.

Post by BubbaTough »

In 1988, my junior year of high school, I came up with a neat idea for a chess program (mini-max). I wrote down a simple eval function and used to play games simulating (aka trying to calculate in my head) the heuristic against whoever I could find (pretty bad games, since I was simulating a 3 ply search with no Q-search). I think I first learned other people did this stuff in 1989 when I found the book Computer Chess II at Powell's bookstore. At that time, I had written my own program which had an awful version of alpha-beta I had made up myself (I don't remember it exactly but I do remember it pruned much less than it should have) and tried to use capture extensions and such instead of a q-search. It did have a pretty decent eval function though, with pawn structure, outposts, trapped piece detection, mobility and such. Move generation was a whole bunch of if then's :).

-Sam
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Your first chess program.

Post by Don »

My first program was before I had a computer - it was a set of instructions that a human could follow and it would produce just one move in a deterministic way. I don't think I was the first to write a paper program but I din't know at the time that it had every been done before. I was in high school 9th grade and knew nothing about computers. At the time regular 4 function calculators were first coming out but few people could afford them and they were not programmable.

I don't remember much about it, but it was basically composed of questions that you would answer which would direct you to various steps - a big decision tree basically. It was not overly complicated to execute and did not even do a 1 ply search nor did it have an evaluation function which would have been pretty taxing to compute by hand anyway. I do remember the question for the very first step: 1. Are you in check? - all out of check moves were handled separately.

There were some provisions for handling just the most trivial tactics - nothing so sophisticated as a swap-off but for instance if an up-capture was legal it was always the preferred move and otherwise if a piece was up-attacked capturing the attacker or moving the piece was given priority. If one of those rules did not kick in, some kind of move would be prescribed to develop a piece, where moves towards the center were preferred. There was no random move selection, eventually you would get to a rule that would force some move to be played. There was no scoring either, a rule either kicked in or you moved to the next rule.

After getting familiar with the program you could usually execute moves without the program as the steps were easy to follow and remember.

I think it would be really fun to build such a program today - a computer could be used to "test" it and you could probably even get such a thing up to a level that a beginner might be challenged by using a computer to figure out what rules work best.

To be practical you must avoid complex calculations - nobody is going to want to tally points and add things up just to execute such a program - it has to be simple and not confusing.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
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: 27787
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 ]