bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] A question - Which die is still available during a move?


From: Jim Segrave
Subject: Re: [Bug-gnubg] A question - Which die is still available during a move? - and a request
Date: Fri, 14 Feb 2003 21:17:30 +0100
User-agent: Mutt/1.2.5.1i

On Thu 13 Feb 2003 (20:01 +0100), Holger wrote:
> > On Thu 13 Feb 2003 (00:41 +0100), Holger wrote:
> > > On Tue, 11 Feb 2003 01:08:40 +0100, Jim Segrave wrote:
> > 
> > Actually - looking briefly at update_move in gtkboard.c, it looks like
> > it's doing what you asked for.
> 
> What GNUbg does right now (at least if I understood it) in order to
> determine whether a move is legal is a little like trial and error. First it 
> makes a
> move and when it sees that it wasn't ok, it reverts and tries a different
> one. It even draws and deletes the chequers in the process, but for today's
> speed this isn't visible. I can't use this. I'm painting the rectangles during
> the dragging phase. Unfortunately, update_move() and place_chequer_or_revert()
> have (for my purpose severe) side effects as they change the board.

I think I can see a way to do what you want:

There is a list of all valid 1, 2, 3 or 4 chequer moves which can be
made (so it deals with incomplete moves as well). This is available in
much of gtkboard.c in the BoardData structure 
   bd->move_list.amMoves

The moves already made are being built in bd->anMove 
The number of moves (2 or 4) are held in bd->cMaxMoves

When a chequer is picked up in board_pointer() in gtkgame.c, you
should be able to figure out all the possible destinations:

Assume you know what point the chequer is piced up from. 
You want tobuild a list of all the valid targets starting with this
move. Initialise a list of possible moves to empty. 
Make a counter of unused moves = bd->cMaxMoves - no_of_entries in bd->anMove

For each move in bd->move_list.amMoves {
   if there are no moves listed with this chequer as a starting point,
      this is an illegal move - you are done
   if the starting point also occurs x times in
      bd->anMove, then it must appear at least x+1 times in
      bd->move_list.amMoves otherwise skip it
   if you get to here, add the move to the list of possible moves.
}
 
Now deal with moving one chequer more than once:

while (--count of unused moves) {
   for each destination in the list of possible moves {
       search for an occurrence of a move with
       starting point = destination, ending point = somewhere
       If found, add somewhere to the list of possible moves.
   }
}

You now have a list of all possible destinations for the chequer just
picked up.   

-- 
Jim Segrave           address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]