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

Re: [pbmserv-dev] Dvonn problem (?)



I am not sure if the undo function is really broken (are you talking about
the core source files?)   Anyways, one thing you could do is in the
Dvonn::Init() function, keep an eye out for the variable 'is_regenerating'
and if it is equal to zero (0) then you know the game is just starting
for the very first time.  But if the 'is_regenerating' variable is equal
to one (1) then you know that either a) a mistake was made on the very first
move like lyman did or b) someone is asking for an undo and it was accepted
by the opponent.  I figured out that during the undo process, the
'is_regenerating' variable is set.  This means that you can tell if the 
program is entering the function Dvonn::Init() for the very first time (==0)
or for the second or more time (==1)
What this means is when you enter the Init() function, immediately check the
variable 'is_regenerating' and if it is zero then build a random Dvonn
board and then keep a copy of this initial board in the data file.  This is
important; keep two boards 1) a copy of the very first initial random board
and 2) the running board that the players are playing.  Now if you enter
Init() and 'is-regenerating' is equal to one then *do not* create a random
board, use the one that was already created the very first time!  (I figured
this out after some experimentation and also looking at sharkey's Stratego
program.  In Stratego, sharkey keeps a copy of the player's initial set-up
then when the program regenerates, he places this copy into the comment
section as if the player had re-entered his set-up; very clever sharkey!!!
:-)   This should fix the problem with undo and I hope that it will allow
undos even after the board was started randomly.  

BTW: I wish to say publicly that I am learning a lot of good programming
by studying sharkey's programs.  John Williams is a fine programmer and
I try to steal^H^H^H^H^H borrow from him as often as I can.  I would 
suggest that if any programmers need answers or examples to stea...er...borrow
then they should consult his programs.

--
 Douglas Zander