Author: Christophe Theron
Date: 22:12:06 09/23/99
Go up one level in this thread
On September 23, 1999 at 23:12:48, Normand M. Blais wrote:
>On September 23, 1999 at 22:44:01, leonid wrote:
>
>>On September 23, 1999 at 14:11:57, Normand M. Blais wrote:
>>
>>>On September 22, 1999 at 15:30:36, Brian Nielsen wrote:
>>>
>>>>
>>>>Hi
>>>>
>>>>My name is Brian, i was thinking about writing a chess engine for fun.
>>>>I am pretty experienced programmer/developper(c++,delpie), but have not been
>>>>programming games, thoug i have made a packman clone a couple years ago.
>>>>
>>>>I have done a little research myself to get the principles in making a chess
>>>>engine/program, and i think i now have basic understanding in how to(i hope :-))
>>>>
>>>>i am curious in how you chessgame programmers represent the chessboard, I have
>>>>seen 4-5 different examples/ways in how to do it, how do you do it and why ??
>>>>
>>>>Second how long time does it take to make a basic engine! from scratch
>>>>provided that i am a experienced programmer.
>>>>
>>>>Best regards
>>>>
>>>>Brian Nielsen
>>>
>>>
>>>Hi,
>>>
>>>I'm not using C/C++ (yet) but I thought I could share the idea that I use for
>>>my chess program. It is probably not new but I've nerver seen it mentionned any-
>>>where. It is easy to understand and to implement. So, just for the record, here
>>>it is.
>>>
>>>
>>>
>>>preliminary notes: The lower bound for array indexing is 1 (not 0) in the
>>> explanation below.
>>>
>>>1- The board is represented by an array of 64 integers.
>>>
>>>
>>>
>>> 1 2 3 4 5 6 7 8 - 8
>>> 9 10 11 12 13 14 15 16 - 7
>>> 17 18 19 20 21 22 23 24 - 6
>>> 25 26 27 28 29 30 31 32 - 5
>>> 33 34 35 36 37 38 39 40 - 4
>>> 41 42 43 44 45 46 47 48 - 3
>>> 49 50 51 52 53 54 55 56 - 2
>>> 57 58 59 60 61 62 63 64 - 1
>>>
>>> A B C D E F G H
>>>
>>>
>>>2- A 64 by 8 integer array is used for the piece movements. For each square,
>>> 8 directions is recorded:
>>>
>>>
>>> NW(8) N(1) NE(2)
>>> \ | /
>>> W(7)--- ----E(3)
>>> / | \
>>> SW(6) S(5) SE(4)
>>>
>>> For a given square and a given direction, the index of the adjacent square
>>> is stored. If there is no square (case of a border square), 0 is stored.
>>>
>>> directions: 1 2 3 4 5 6 7 8
>>> ---------------------------------------
>>> square(1) = 0, 0, 2,10, 9, 0, 0, 0
>>> square(2) = 0, 0, 3,11,10, 9, 1, 0
>>> .
>>> .
>>> .
>>> square(64) = 56, 0, 0, 0, 0, 0,63,55
>>>
>>>
>>>3- The movement of the pieces are defined in term of directions:
>>>
>>> Rook --> 1 to 7 by 2
>>> Bishop --> 2 to 8 by 2
>>> Queen --> 1 to 8 by 1
>>> King --> 1 to 8 by 1
>>>
>>> Knight --> {1,1,2},{1,1,8},{3,3,2},{3,3,4},
>>> {5,5,4},{5,5,6},{7,7,6},{7,7,8}
>>> White:
>>> pawn move one --> 1
>>> pawn move two --> {1,1}
>>> pawn captures --> 2,8
>>>
>>> Black:
>>> pawn move one --> 5
>>> pawn move two --> {5,5}
>>> pawn captures --> 4,6
>>>
>>>4- Enhencements.
>>>
>>> A 64 by 8 array can be generated for the knight where the squares stored
>>> for a given direction is the end square of a knight move. Then the knight
>>> movement can be defined this way:
>>>
>>> Knight --> 1 to 8 by 1
>>>
>>>
>>>
>>>Best Regards,
>>>
>>>Normand M. Blais
>>
>>This is pretty fascinating for me to find your description of the chess
>>board. It had nothing to do with mine. My question to you is: Do your
>>representation of the board is usual?
>>
>>Thanks,
>>Leonid.
>>boad represention is usual one or something
>
>The way I represent the chess board is not new. What's particular is the way I
>generate the moves using an intermediary array to represent directions. I was
>able to build a movegenerator in a short time. I compare it to TSCP move
>generator and it is as fast if not faster. I know that the bitboard is the way
>to go but I'm using an interpreted language that don't have 64bits unsigned
>integer data type. I'm programming for fun only.
>
>NMB
If somebody tells you bitboards are the way to go, don't believe him.
Christophe
This page took 0.02 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.