Prey/predator c++ project
-
Hello everyone, new to programming and algorithms, I have an obligation to respond to a project. That of creating a grid in which there is a prey/predator system. The beginning is to initialize the structures of the 3 elements. We are instructed to create a (dynamic) list to which only the prey and predators entered by the user are added. I totally don't understand how. I had the idea of creating a static list and leaving blanks when nothing is there. But our tutor told us that it's heavier and it's better to use a dynamic list rather than a static one. Thanks for your help.
-
Hello everyone, new to programming and algorithms, I have an obligation to respond to a project. That of creating a grid in which there is a prey/predator system. The beginning is to initialize the structures of the 3 elements. We are instructed to create a (dynamic) list to which only the prey and predators entered by the user are added. I totally don't understand how. I had the idea of creating a static list and leaving blanks when nothing is there. But our tutor told us that it's heavier and it's better to use a dynamic list rather than a static one. Thanks for your help.
The question is not clear. What do you mean by "prey/predator system", what are "the 3 elements"? I know what both of those terms mean, but have no idea what sort of system you are supposed to design. I suggest you go back to your tutor and get a clearer description of what you are supposed to create.
-
Hello everyone, new to programming and algorithms, I have an obligation to respond to a project. That of creating a grid in which there is a prey/predator system. The beginning is to initialize the structures of the 3 elements. We are instructed to create a (dynamic) list to which only the prey and predators entered by the user are added. I totally don't understand how. I had the idea of creating a static list and leaving blanks when nothing is there. But our tutor told us that it's heavier and it's better to use a dynamic list rather than a static one. Thanks for your help.
If the size of the grid is static (
m
xn
), you can just hard-code it:enum GridOccupant {EMPTY, PREY, PREDATOR};
GridOccupant Grid[m][n] = {EMPTY};If the grid is dynamic, the question is whether you're allowed to use things from the Standard Template Library (STL), like
std::vector
[^], or whether you're supposed to allocate the memory yourself. When the user specifies the location ofPrey
orPredator
, you create one and add it toPreyAnimals
orPredatorAnimals
. Again, the question is whether you're allowed to use the STL. EachAnimal
(the base class forPrey
andPredator
, if this helps your design) keeps track of its location in theGrid
to make it easy to find. You might discover that you don't needGrid
at all, only its dimensions (m
xn
).Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.