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

Create a console application called the Game of Life Requirements: ? Implement t

ID: 3648662 • Letter: C

Question

Create a console application called the Game of Life
Requirements:
? Implement the grid as a 2-dimensional int array with 25 rows and 40 columns.
? At the beginning all cells are dead except for a continuous horizontal block of 13 living cells in the 14th row ( row index 13, column index 14

Explanation / Answer

fastgraphics graphsize X*H,Y*H dim c(X,Y) : dim cn(X,Y) : dim cl(X,Y) c[X/2-1,Y/3+1] = 1 : c[X/2,Y/3+1] = 1 : c[X/2+1,Y/3+1] = 1 # Thunderbird methuselah c[X/2,Y/3+3] = 1 : c[X/2,Y/3+4] = 1 : c[X/2,Y/3+5] = 1 s = 0 do color black rect 0,0,graphwidth,graphheight alive = 0 : stable = 1 s = s + 1 for y = 0 to Y-1 for x = 0 to X-1 xm1 = (x-1+X)%X : xp1 = (x+1+X)%X ym1 = (y-1+Y)%Y : yp1 = (y+1+Y)%Y cn[x,y] = c[xm1,y] + c[xp1,y] cn[x,y] = c[xm1,ym1] + c[x,ym1] + c[xp1,ym1] + cn[x,y] cn[x,y] = c[xm1,yp1] + c[x,yp1] + c[xp1,yp1] + cn[x,y] if c[x,y] = 1 then if cn[x,y] < 2 or cn[x,y] > 3 then cn[x,y] = 0 else cn[x,y] = 1 alive = alive + 1 end if else if cn[x,y] = 3 then cn[x,y] = 1 alive = alive + 1 else cn[x,y] = 0 end if end if if c[x,y] then if cn[x,y] then if cl[x,y] then color purple # adult if not cl[x,y] then color green # newborn else if cl[x,y] then color red # old if not cl[x,y] then color yellow # shortlived end if rect x*H,y*H,H,H end if next x next y refresh pause 0.06 # Copy arrays for i = 0 to X-1 for j = 0 to Y-1 if cl[i,j]cn[i,j] then stable = 0 cl[i,j] = c[i,j] c[i,j] = cn[i,j] next j next i until not alive or stable if not alive then print "Died in "+s+" iterations" color black rect 0,0,graphwidth,graphheight refresh else print "Stabilized in "+(s-2)+" iterations" end if #include #include #include #define for_x for (int x = 0; x
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