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

Re: [pbmserv-dev] my moultezim program is buggy. help!



Looking in lists.cpp, I see that Init merely copies the pointer, but the =
operator makes a full copy of the values, so this should work.

IntList old;
old.Init().Add(1).Add(2).Add(3);
IntList new;
new = old;

It's OK to change the original board array in order to test things, as
long as you put it back when you are done.  HexEmergo::NextLegalMove and
Chess::IsMate do this, but not recursively.  Recursing should not be a
problem though.

~ John Williams


On Fri, 16 Mar 2001, Douglas Zander wrote:

> Can someone help me with the moultezim program.  I cannot figure
> out how to make copies of an integer array for a recursive routine.
> In the header file there is a class called BB and one of its
> variables is an array of integers board[25]
> now what I want is to call a recursive routine with copies of
> the board[] but I do not want to upset the original board[] array.
> If you happen to have moultezim.h and moultezim.cpp look closely
> at Moultezim::CanMove(...)  and Moultezim::canmove2(...)  and
> Moultezim::canmove3(...)  
> CanMove calls the other two and the other two are recursive routines.
> The problem I believe is that I am not using carbon copies of board[]
> but rather I am upsetting the original board[] array that is in the
> main class structure.  Am I correct?  Am I upsetting the main class
> board[] array when I change board[] values?  How do I correct this?
> I want a new copy with each level of recursion (maximum 4) of the board[]
> array.  Any help would be appreciated.
> 
> --
>  Douglas Zander                |  
>  dzander@solaria.sol.net       | 
>  Shorewood, Wisconsin, USA     |  
> 
> 
> 
> To unsubscribe, send a message to esquire@gamerz.net with
> 	unsubscribe pbmserv-dev
> as the BODY of the message.  The SUBJECT is ignored.
>