Answered step by step
Verified Expert Solution
Question
1 Approved Answer
create an updateReversed(oldB, newB) for the conway's game of life. herae's an example code for update 1, use it to make update reversd according to
create an updateReversed(oldB, newB) for the conway's game of life. herae's an example code for update 1, use it to make update reversd according to the guidlins
Creating a new "board" from an old one None of the update functions so far depends on a previous "generation" of cells. For our life game we need to update the cells from one generation to modify a NEW board in the subsequent generation. Write a function updateReversed ( oldB , newB ) that takes an old board and a blank new board and modifies the newB such that each cell is the "opposite" of oldB's cells. That is, where oldB [row] [col] is a 1, the new board's value will be a zero - and vice versa. This function should not return anything. However, keep the outermost edge of cells empty, regardless of their state in the original board - this will help when implementing Life, because it will prevent index out-of-bounds errors. Recall that you can obtain the width and height from oldB: width=len(oldB[0])height=len(oldB) Try out your updateReversed by displaying an example: B = createBoard (10,10) updateRandom ( B ) csplot.show ( B ) newB = createBoard ( 10, 10) \# makes newB reference a NEW board... updateReversed(B, newB) csplot.show ( newB ) It's important that you first make a NEW array of data to pass into the updateReversed function. You might point Creating a new "board" from an old one None of the update functions so far depends on a previous "generation" of cells. For our life game we need to update the cells from one generation to modify a NEW board in the subsequent generation. Write a function updateReversed ( oldB , newB ) that takes an old board and a blank new board and modifies the newB such that each cell is the "opposite" of oldB's cells. That is, where oldB [row] [col] is a 1, the new board's value will be a zero - and vice versa. This function should not return anything. However, keep the outermost edge of cells empty, regardless of their state in the original board - this will help when implementing Life, because it will prevent index out-of-bounds errors. Recall that you can obtain the width and height from oldB: width=len(oldB[0])height=len(oldB) Try out your updateReversed by displaying an example: B = createBoard (10,10) updateRandom ( B ) csplot.show ( B ) newB = createBoard ( 10, 10) \# makes newB reference a NEW board... updateReversed(B, newB) csplot.show ( newB ) It's important that you first make a NEW array of data to pass into the updateReversed function. You might point
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started