(Solved) : Universe Conway S Game Life Infinite Two Dimensional Orthogonal Grid Cells One Two Possibl Q42781010 . . .

The universe of Conway’s Game of Life is an infinite,two-dimensional orthogonal grid of cells, each of which is in oneof two possible states: alive or dead. Every cell interacts withits eight neighbors, which are the cells that are horizontally,vertically, or diagonally adjacent (upper left, top, upper right,right, lower right, bottom, bottom left, left). At each step intime, the following transitions occur:

  • Any live cell with fewer than two live neighbors dies due tounder-population.
  • Any live cell with two or three live neighbors lives on to thenext generation (no change).
  • Any live cell with more than three live neighbors dies due tooverpopulation.
  • Any dead cell with exactly three live neighbors becomes a livecell by reproduction.

The initial pattern constitutes the seed if the system (startsit off). The first generation is created by applying the aboverules simultaneously to every cell in the seed; births and deathsoccur simultaneously, and the discrete moment at which this happensis called a “tick”. Each generation is a pure function of thepreceding one, and the rules continue to be applied repeatedly tocreate further generations.

Objective

This project will involve substantial coding

  • To gain a deep understanding of how to get and set values in2-D arrays.
  • To gain a deep understanding of iterating over arrays using forand nested for loops.
  • To gain a deep understanding of creating and calling functionsfrom main that pass a variety of parameters, includingstatically-allocated 2D arrays.
  • To practice recognizing repeated code and breaking down codeinto functions
  • Practice using string building/concatenation
  • To gain skills in ad-hoc code development, testing, anddebugging techniques

Instructions

Create your own version of Conway’s Game of Life that runs inthe terminal, according to the rules in the description. An exampleexecutable demo_conway has been provided for you. To run, maximizeyour terminal window and run ./demo_conway. Press ctrl+c to make itstop.

Criteria

  • Your program can run in some default mode just by typing ./ andthe name of your program, or even just ./a.out or ./conway orwhatever program name of your choosing.
  • You may use any fixed-size universe that can fit on a computerscreen. For example, the terminal commonly defaults to 24 rows and80 columns. The example executable provided runs with 48 rows and160 columns.
  • Your code supports a round world where cells that go off theedge come back on the other side. For example, the left edge wrapsaround back to the right edge and vice versa, and the top edgewraps around to the bottom edge and vice versa.
  • Your code creates an initial state of the universe thatexhibits some kind of growth/death over many ticks/generations foran initial shape of your choosing. The wikipedia article providesseveral examples of starting configurations that make cool shapes.I recommend using one that is described to grow infinitely or liveson for many generations, such as one of the spaceships.
    • Extra Credit Add support for at least 1additional starting shape and/or a random configuration,specifiable in the terminal:
      • ./conway random
      • ./conway spaceship
      • ./conway glider
      • etc.
      • Demo your code to your instructor with the default andadditional starting shape for the extra credit point.
  • Your code differentiates clearly between a “dead” cell, such asa space ‘ ‘, and a “live” cell, such as ‘*’.
  • Your code should run infinitely (e.g. while (true) {…}), butcan be terminated by using ctrl+c. You don’t need to code anythingspecial to make ctrl+c work, as you’ve observed when debugging yourprevious labs that ran into infinite loops.

CODE PROVIDED:

#include <chrono>
#include <ctime>
#include <curses.h>
#include <iostream>
#include <stdlib.h>
#include <thread>
using namespace std;
const int ROWS = 48;
const int COLUMNS = 160;
void InitializeCurses() {
// Initialize curses to control where to output to theterminal. No need to
// modify this function, but make sure it is called in main atthe beginning.
initscr();
cbreak();
noecho();
clear();
}
void PrintExitInstructions() {
// Prints instructions near the bottom of the screen for how toexit. No need
// to modify this function.
mvaddstr(ROWS + 1, 0, “Press ctrl+c to quit “);
refresh();
}
void PrintRow(string row_to_print, int row) {
mvaddstr(row, 0, row_to_print.c_str());
refresh();
// Optional: Use the following line to create a short delaybetween each
// tick if you want to watch your population grow/shrink moreslowly:
// this_thread::sleep_for(chrono::milliseconds(1));
}
int main(int argc, char* argv[]) {
InitializeCurses();
PrintExitInstructions();
// TODO: Implement Conway’s Game of Life.
while (true) {
}
endwin();
return 0;
}

Expert Answer


Answer to The universe of Conway’s Game of Life is an infinite, two-dimensional orthogonal grid of cells, each of which is in one …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?