OOPortal OOPortal

Eco Simulation  «Prev 

Initializing and displaying the simulation

Objective: Write two functions for the main() function of the simulation--one to generate an initial world and one to display the world.


Implement the eden() function to initialize the world when the simulation begins and the pr_state() function to display the world.
Here is main() again for your reference:
int main(){
world  odd, even;
int    i;
init(odd);  init(even);

//initialize inside world to non-empty types
eden(even);         //generate initial world
pr_state(even);      //display garden of eden state

for (i = 0; i < CYCLES; ++i) {  //simulation
   if (i % 2) {
	  update(even, odd);
   else {
	  update(odd, even);
return 0;

This code is also available in a file named worldmain.cpp, which can be found in the compressed course download file available on the Resources page.
Paste your code below and click the Submit button when you are ready to submit this exercise.