# predator and prey

• 06-07-2011
mahmoz
predator and prey
heeey guys
i want to make predator and prey simulation and i made the 2d array i just don't know what to do next
i need help !!!!

Code:

``` #include <iostream> using namespace std; void printGrid(char grid[][20], int w, int h); int main() {     // Create a 20 by 20 grid array of chars     char grid[20][20];     // Now loop through each row...     for (int i = 0; i < 20; i++) {         // ... then each column and set each space to '.'         for (int j = 0; j < 20; j++) {             grid[i][j] = '.';         }     }       // Print the grid of 20 by 20 dots     printGrid(grid,20,20);       return 0;         std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');   std::cin.get(); }     // Call this function to print your grid. w = width, h = height void printGrid(char grid[][20], int w, int h) {     for (int i = 0; i < w; i++) {         for (int j = 0; j < h; j++) {             cout << grid[i][j] << " ";         }         cout << endl;     } }```
• 06-07-2011
nimitzhunter
predator and prey as in Lotka-Volterra differential equation? then you need to read on how to solve numerical ODE like the Runge-Kutta method.
• 06-07-2011
King Mir
So before you run in and write another function, write main. Write in main what the program is going to do. Is there a loop? What happens each iteration?
Don't worry about how to do each step, just stub out the functions so that you can fill them in later.

On a similar note initializing the array to all '.' should be done in it's own function.
• 06-08-2011
Salem