Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Prey/predator c++ project

Prey/predator c++ project

Scheduled Pinned Locked Moved C / C++ / MFC
c++csshelp
3 Posts 3 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sahil Ranka
    wrote on last edited by
    #1

    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.

    L Greg UtasG 2 Replies Last reply
    0
    • S sahil Ranka

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • S sahil Ranka

        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.

        Greg UtasG Offline
        Greg UtasG Offline
        Greg Utas
        wrote on last edited by
        #3

        If the size of the grid is static (m x n), 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 of Prey or Predator, you create one and add it to PreyAnimals or PredatorAnimals. Again, the question is whether you're allowed to use the STL. Each Animal (the base class for Prey and Predator, if this helps your design) keeps track of its location in the Grid to make it easy to find. You might discover that you don't need Grid at all, only its dimensions (m x n).

        Robust Services Core | Software Techniques for Lemmings | Articles
        The fox knows many things, but the hedgehog knows one big thing.

        <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
        <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups