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: Holger
Subject: Re: [Bug-gnubg] A question - Which die is still available during a move? - and a request
Date: Sun, 16 Feb 2003 01:17:19 +0100

At 21:17 14.02.03 +0100, Jim Segrave wrote:
>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

When I was debugging my way through the programme I had found this already.
I haven't cared so far to look up the format of amMoves nor how exactly the
list is generated. It just looked a bit complex, so I was hesitant to head
right into it and maybe break something. The idea of enumerating all
generated moves came across, but I wasn't really fond of it. So I did it
another way. :-)

>The moves already made are being built in bd->anMove 

This is good news. Very helpful, thanks.

>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.
>   }
>}

Seems to be rather much processing in both loops for a maximum of 4
destination points.

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

Yes, this ought to work. Thanks for the effort. But sorry to disappoint
you. I'm almost done. I really hope that it wasn't much time that you've
spent on this. If you're interested I can send you the code.
Before submitting a patch I still have some work, though. The code is a bit
ugly right now, and there is a minor issue with bear-off. Also I'd like to
add an option in settings. I didn't look into this, yet.

Regards,

        Holger




reply via email to

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