BYTE.com
RSS feed

Newsletter
Free E-mail Newsletter from BYTE.com
Email Address
First Name
Last Name




 
    
             
BYTE.com > Features > 2003

How to Write a Chess-Playing Program, Part 2

By Ihor Bobak

September 1, 2003

(How to Write a Chess-Playing Program, Part 2 :  Page 1 of 1 )



In last week's article we considered theoretical issues influencing the "brain" of a chess program. Now we will consider a practical implementation. Questions like "How do I program the transposition table?" "How do I choose the estimation function?" and "What data structures are best suited for chess?" are answered in this article.

To write a chess playing program we need to do a few things:

  1. Study the rules of chess
  2. Define the data structures and classes for handling things like the notions state, the game tree, moves, etc.
  3. Develop a mechanism for move generation
  4. Invent the estimation function
  5. Implement the search algorithm
  6. Invent a user interface

This article will cover all these tasks except the last one: 2D graphics issues are not covered here. I'll use Delphi as the development tool.

Game Rules

Most people think they know all the rules of chess, but those feeling self-confident should look at this page in order to review them again. Believe me, you will find there something new unless you're a professional chess player.

Data Representation

The Board

Most chess playing programs (including ours) use the following board representation. The board is represented as a set of 64-bit numbers called bitboards. Each bitboard keeps some board characteristic. For example, bitboard can keep the position of white pawns:

the bitboard
Figure 1: Game position (to the left) and the corresponding bitboard

The board is implemented in the following class:

TBoard = class
private
  FCurrentPlayer: integer;
  FBitBoards: array[0..ALL_BITBOARDS-1] of TBitBoard;
  FHasCastled: array[0..
	


 Page 1 of 1 


BYTE.com > Features > 2003
Dr. Dobb's Media Center
BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE: Volume 2 - Heuristic Algorithms
The Best of BYTE: Volume 2 - Heuristic Algorithms
In this volume of Best of BYTE, we explore the emergence of some heuristic algorithms. Although we have only scratched the surface of this intriguing subject, we hope we've suggested the potential of the synthesis of heuristics and algorithms.

© 2008 Think Services, Privacy Policy, Terms of Service, United Business Media Limited
Site comments: webmaster@byte.com
Web Sites: BYTE.com, dotnetjunkies.com, Dr. Dobb's Journal, SD Expo, Sys Admin, sqljunkies.com, Unixreview



MarketPlace
Try Numara FootPrints 9, The ITSM software that Delivers Real Value, Flexibility and Results.
Sign Up & Get Full Access To The Definitive Online Book Collection With SkillSoft's Books24x7�.
Fast online exception analysis. Capture customer crash data online.
One Stop to Buy All Your Business IT Solutions. Browse Through Dell's Best Deals Online Now!
Understand C/C++ code in less time. A new team member ? Inherited legacy code ? Get up to speed faster with Crystal Flow for C/C++. Code-formatting improves readability. Flowcharts are integrated with code browser. Export flowcharts to Visio.
Wanna see your ad here?
 

web2