Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Thoughts about board representations...

Author: Tom Kerrigan

Date: 00:07:09 02/13/00

Go up one level in this thread


On February 12, 2000 at 20:03:44, Dan Newman wrote:

>In the 0x88 program I do something like this:
>
>        while( !p->end() ) {
>            int from = p->from();
>            switch( p->type() ) {
>                ....
>                case W_KNIGHT: {
>                    int to = from + 33;
>                    if( on_board( to) && is_black( to) )
>                        (movep++)->add_wn_capture( from, to);
>                    to = from + 31;
>                    if( on_board( to) && is_black( to) )
>                        (movep++)->add_wn_capture( from, to);
>                    //and so on, 6 more times...
>                    break;
>                }
>                ....
>            }
>            p++;
>        }

Here is some code I wrote to generate moves for *all* pieces. I think it might
be faster than what you have above.

p = first_piece[side];
do {
  if (!p->dead) {
    for (i = 0; i < vectors[p->t]; ++i) {
      n = p->sq;
      for (;;) {
        n = unbounds[bounds[n] + vector[p->t][i]];
        if (n == -1)
          break;
        if (board[n]) {
          if (board[n]->c == xside)
            add_move(p->sq, n, 0x40000);
          break;
        }
        add_move(p->sq, n, 0x0);
        if (p->bit & 0x22)
          break;
      }
    }
  }
  p = p->next;
} while (p);

Some obvious speedups are possible, but you get the idea.

-Tom



This page took 0.01 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.