Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The goal for thsi programming project is to creat a simple 2D predator prey simu

ID: 3621523 • Letter: T

Question

The goal for thsi programming project is to creat a simple 2D predator prey simulation. in this simulation, the prey are ants and the predators are doodlebugs.These critters live in a world composed of a 20 X 20 grid of cells. Only one critter may occupy a cell at atime. the grid is enclosed, so a critter is not allowed to move off the edges of the grid.Time is simulated in time steps.each critter performs some action every time step.

Explanation / Answer

#include #include #include using namespace std; int arrays[20][20],a=0,b=0; void step(int g,int h,int i,int &u,int &l); class organsim { public : int x,y,life; }; class b_bug:public organsim { public: void birth(int e,int f) { x=e; y=f; life=0; arrays[e][f]=2; a++; } void moves(); void breed(); void death() { arrays[x][y]=0; } }bugs[400]; void b_bug::moves() { int k=0,t1,t2,i; life++; for(i=0;i0) { if(k!=1) k=(rand()%k+1); for(i=0;i0;i++) { step(x,y,i,t1,t2); if(arrays[t1][t2]==0) k--; } arrays[x][y]=0; arrays[t1][t2]=2; x=t1; y=t2; if(life>=3) { this->breed(); life=0; } } } void b_bug::breed() { int i,k=0,t1,t2; for(i=0;ix=t1; this->y=t2; } if(steps>=8) this->breed(); if(lifedeath(); } void doodle::breed() { int i,k=0,t1,t2; for(i=0;i0) { if(k!=1) k=(rand()%k+1); for(i=0;i0;i++) { step(x,y,i,t1,t2); if(arrays[t1][t2]==0) k--; } doodles[b].birth(t1,t2); } } void Display() { int i,j; char c; system("cls"); for(i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote