Re: Move function


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by William D McQuain on April 18, 2001 at 07:49:45:

In Reply to: Move function posted by Geoff Zelenka on April 17, 2001 at 18:08:11:

: For figuring out how a critter is supposed to move on a tick is it allowed to do the following:

: Keep an integer value that counts the number of ticks that happen, then do a mod function on the total number of ticks and the total number of possible moves for a critter and then use a switch statement

So you want to store an extra int in each creature, increment that value on each simulated tick, and then evaluate a switch to select a hard-coded move.

Seems to me that's clearly less flexible that storing the list of moves in a queue. The space issue favors your approach. Efficiency is probably a wash if you use the STL queue for this.

Given the language in the spec, creatures are required to organize the movements via some sort of list... I'll leave it at that.

: ie for a browser
: int TotTicks;
: int Move;

: Move = TotTicks % 2;
: switch(Move){
: case 0:
: //move critter east
: case 1:
: // move critter south
: }

: Is this okay?? Or do we have to use a data structure?
: I feel this method is simpler and more effiecient.




Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]