Author: Dann Corbit
Date: 13:58:10 06/07/05
Go up one level in this thread
On June 04, 2005 at 03:06:17, Alvaro Jose Povoa Cardoso wrote: >Could someone please explain the piece list data structure? In the most naive chess implementation, you will search each of the 64 squares looking for chessmen. When you find one, you identify its kind and color and if if is on the side to move, generate moves for it. Some better ways to do it are: 1. Single piece list A. Store a count of how many chessmen there are B. Store a list of the chessmen which contains type, color and position By using this structure, you will have to iterate over at most 32 positions in your piece list instead of 64 positions on your chess board. And if you have only 3 chessmen on the board, it is only 3 positions. A slight variant of the above is to maintain a piece list for all positions besides the kings and separately the king positions (minor speedup for check tests). 2. Two piece lists (by color) Same as type 1, but separate into two distinct piece lists by color. Now, you will only have to store type and position because color is implicit. 3. Store a piece list for every type and color of chessmen. If generically constructed, it should be able to hold up to ten chessmen of any given type. Using this type of list, you only have to store the position. Often, bitboards of the chessmen are used for this purpose. There are (of course) many other possibilities.
This page took 0 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.