SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 305 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 08 Nov 2017 My Price 10.00

Can anyone guide me as to how I can approach this question through using nested lists?

The Game of Lifeis a well-known mathematical game that gives rise to amazinglycomplex behavior, although it can be specified by a few simple rules. (It is not actually agame in the traditional sense, with players competing for a win.) Here are the rules. Thegame is played on a rectangular grid. Each square on the grid can be either empty(represented by a 0 in our version) or occupied by a "living" cell (represented by a 1). Atthe beginning, you can specify empty and occupied cells in some way; then the gameruns automatically. In eachgeneration, the next generation is computed. A new cell isborn on an empty square if it is surrounded by exactly three occupied neighbor cells. Acell dies of overcrowding if it is surrounded by four or more living neighbors, and it diesof loneliness if it is surrounded by zero or one living neighbor. A neighbor is an occupantof an adjacent square to the left, right, top, or bottom or in a diagonal direction. Figure 16shows a cell and its neighbor cells.Many configurations show interesting behavior when subjected to these rules. Figure 17shows aglider, observed over five generations. Note how it moves. After fourgenerations, it is transformed into the identical shape, but located one square to the rightand below.One of the more amazing configurations is the glider gun: a complex collection of cellsthat, after 30 moves, turns back into itself and a glider (see the large figure at the end).Over the next week, you will use Python to program the game to eliminate the drudgeryof computing successive generations by hand.Your homework assignment will come intwo parts, also known as Programming Assignment 6 and Programming Assignment 7.The Wikipedia page onThe Game of Lifehas a lot of useful information, as well assome real-time examples of program behavior.You should take a look at it.Implementing this game requires a plan for what to do about the cells at the edges of thegrid, since those cells don't have a full complement of eight neighbors.The Wikipediaentry does bring up this issue, and options range from simple to complex.For ourpurposes, it is sufficient to assume that every square outside of the grid is empty (i.e., 0)and will remain empty for the duration of the game.(Much of the description above, and all the figures below, is borrowed from a textbookby Cay Horstmann.)Programming Assignment 6 - Game of Life, Part 1Your solution is to be written using Python 3. Make sure you provide commentsincluding the file name, your name, and the date at the top of the file you submit.Also make sure to include appropriate docstrings for all functions.The names of your functions must exactly match the names given in this assignment.The order of the parameters in your parameter list must exactly match the ordergiven in this assignment.For any given problem below, you may want to write additional functions otherthan those specified for your solution. That's fine with us.
Background image of page 1
The core problem to be solved in the implementation of the Game of Life is how togenerate the next grid from the current grid. Your task is to write a function callednextGenwhich expects only one argument. That argument is a two-dimensionaltable (i.e., a list of lists) with m rows and n columns, representing the current grid.The elements of the table are either 0 (empty square) or 1 (occupied square). Youmay assume that all rows have the same number of elements.Given the current grid,nextGencomputes and returns (but does not print) a newnext grid (without altering the current grid) by applying the simple rules providedabove. For example, given this initial grid:glider =[[0,0,0,0,0,0,0],[0,0,1,0,0,0,0],[0,0,0,1,0,0,0],[0,1,1,1,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]]your function should work like this:>>> x = nextGen(glider)>>> x[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],[0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0],[0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]>>> y = nextGen(x)>>> y[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0],[0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]>>> z = nextGen(y)>>> z[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],[0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0],[0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]>>> q = nextGen(z)>>> q[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0],[0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]
Background image of page 2

Attachments:

Answers

(5)
Status NEW Posted 08 Nov 2017 10:11 AM My Price 10.00

----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------Tha-----------nk -----------you----------- fo-----------r y-----------our----------- in-----------ter-----------est----------- an-----------d b-----------uyi-----------ng -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll -----------be -----------qui-----------ckl-----------y

Not Rated(0)