Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Can u put a move_generator to small defs:

Author: James Robertson

Date: 16:54:31 08/31/99

Go up one level in this thread


On August 31, 1999 at 17:03:13, Nicolas Carrasco wrote:

>I would like if anyone can write me a move_generator to these arrays and put all
>possible moves at "struct move_list.from ,"move_list.to", "move_list.type" and
>put the last index number to "move_list.num".
>
>I would be extreamly pleased if anyone can create a:
>void gen_moves (char side, m_list list)
>
>side = side to move
>list = struct m_list to change
>
>QUESTION:*****Is this a good move_generator idea, or simply good to start?
>
>///////////////////////////////Begin of source/////////////////////////////////
>struct m_list{
>
>        unsigned char num;
>        char type; // 0 move, 1 capture, 2 promote, 3 castle king-side, 4 castle
>                   // queen-side (anything to add or wrong?)
>        char from[64];
>        char to[27]; // A queen at the center of the board has the maximun
>                    // move_number of moves per piece?
>
>}move_list;

I don't understand your movelist. Does this structure represent one move or a
whole list of moves?

I think the easiest way to represent moves is with a structure similar to:

struct move {
  char from;
  char to;
  char promote;   // promotion piece.
  char flags;     // castling, ep, etc.
};

To make things even simpler, make your move just an int, and have macros to
extract the different parts. (I think EXchess or TSCP (one of the two) does
something like this with unions).

Once you have a move, just make a simple array of moves:

move move_list[200];
int number_of_moves;

If you want a structure for your movelist, do something like:

struct move_list {
  int number_of_moves;
  move list[200];
};


I hope this helps.

James

>
>#define TRUE            1
>#define FALSE           0
>
>#define PAWN            0
>#define KNIGHT          1
>#define BISHOP          2
>#define ROOK            3
>#define QUEEN           4
>#define KING            5
>
>#define WHITE           0
>#define BLACK           1
>
>#define EMPTY           6
>
>#define BOOL            char
>
>#define FILE(x)         (x&7)
>#define RANK(x)         (x>>3)
>
>char mailbox[120]= {
>         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>         -1,  0,  1,  2,  3,  4,  5,  6,  7, -1,
>         -1,  8,  9, 10, 11, 12, 13, 14, 15, -1,
>         -1, 16, 17, 18, 19, 20, 21, 22, 23, -1,
>         -1, 24, 25, 26, 27, 28, 29, 30, 31, -1,
>         -1, 32, 33, 34, 35, 36, 37, 38, 39, -1,
>         -1, 40, 41, 42, 43, 44, 45, 46, 47, -1,
>         -1, 48, 49, 50, 51, 52, 53, 54, 55, -1,
>         -1, 56, 57, 58, 59, 60, 61, 62, 63, -1,
>         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
>         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
>};
>
>char mailbox64[64]= {
>        21, 22, 23, 24, 25, 26, 27, 28,
>        31, 32, 33, 34, 35, 36, 37, 38,
>        41, 42, 43, 44, 45, 46, 47, 48,
>        51, 52, 53, 54, 55, 56, 57, 58,
>        61, 62, 63, 64, 65, 66, 67, 68,
>        71, 72, 73, 74, 75, 76, 77, 78,
>        81, 82, 83, 84, 85, 86, 87, 88,
>        91, 92, 93, 94, 95, 96, 97, 98
>};
>
>/* Posciciones iniciales
>*************************************************************/
>char init_color[64]= {
>        1, 1, 1, 1, 1, 1, 1, 1,
>        1, 1, 1, 1, 1, 1, 1, 1,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        0, 0, 0, 0, 0, 0, 0, 0,
>        0, 0, 0, 0, 0, 0, 0, 0
>};
>
>char init_piece[64]= {
>        3, 1, 2, 4, 5, 2, 1, 3,
>        0, 0, 0, 0, 0, 0, 0, 0,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        6, 0, 6, 6, 6, 6, 6, 6,
>        6, 6, 6, 6, 6, 6, 6, 6,
>        0, 0, 0, 0, 0, 0, 0, 0,
>        3, 1, 2, 4, 5, 2, 1, 3
>};
>/*
>*************************************************************/
>char notation [64][3]= {
>        "a8","b8","c8","d8","e8","f8","g8","h8",
>        "a7","b7","c7","d7","e7","f7","g7","h7",
>        "a6","b6","c6","d6","e6","f6","g6","h6",
>        "a5","b5","c5","d5","e5","f5","g5","h5",
>        "a4","b4","c4","d4","e4","f4","g4","h4",
>        "a3","b3","c3","d3","e3","f3","g3","h3",
>        "a2","b2","c2","d2","e2","f2","g2","h2",
>        "a1","b1","c1","d1","e1","f1","g1","h1"
>};



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.