Difference: Lab7Kenyon (6 vs. 7)

Revision 72015-11-01 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 7

Due: Nov 3, 11:55pm

Line: 12 to 12
 
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Changed:
<
<
Turning in complete run of every function at least twice with difference values. 10%
>
>
Turning in runs of the cases below. 10%
 

Problem

The mathematician John Horton Conway invented the “Game of Life.” Though not a “game” in any traditional sense, it provides interesting behav- ior that is specified with only a few rules. This Project asks you to write a program that allows you to specify an initial configuration. The program follows the rules of LIFE to show the continuing behavior of the configuration. LIFE is an organism that lives in a discrete, two-dimensional world. While this world is actually unlimited, we don’t have that luxury, so we restrict the array to 80 characters wide by 22 character positions high. If you have access to a larger screen, by all means use it. This world is an array with each cell capable of holding one LIFE cell. Generations mark the passing of time. Each generation brings births and deaths to the LIFE community. The births and deaths follow the following set of rules.

Line: 66 to 66
 Look for stable configurations. That is, look for communities that repeat patterns continually. The number of configurations in the repetition is called the period. There are configurations that are fixed, which continue without change. A possible project is to find such configurations.

Hints:

Changed:
<
<
Define a void function named nextGenWorld that takes the array we call world, a 80-column by 22-row array of char, which contains the initial configuration. The function scans the array and modifies the cells, marking the cells with births and deaths in accord with the rules listed earlier. This involves examining each cell in turn, either killing the cell, letting it live, or, if the cell is empty, deciding whether a cell should be born. nextGenWorld will need to have a local array ( newWorld) of the same type and size, and it will compute the next generation status of each cell from world into newWorld.nextGenWorld will then copy newWorld back into world and return.
>
>
Define a void function named nextGenWorld that takes the array we call world, a 80-column by 22-row array of char, which contains the initial configuration. The function scans the array and modifies the cells, marking the cells with births and deaths in accord with the rules listed earlier. This involves examining each cell in turn, either killing the cell, letting it live, or, if the cell is empty, deciding whether a cell should be born. nextGenWorld will need to have a local array ( newWorld) of the same type and size, and it will compute the next generation status of each cell from world into newWorld.nextGenWorld will then copy newWorld back into world and return.
  So, the life of a cell [x,y] depends on surrounding cells:
[x-1,y-1] [x,y-1] [x+1,y-1]
Line: 94 to 94
 
  • char nextGenCell(char world[][82], int x, int y) - return a '*' if the cell at this location should be alive in the next generation. Otherwise return a space.
  • void nextGenWorld(char current[ ][82]) - Given the current world, compute the next generation for the world.
  • You find a LOT of interesting patterns here: conwaylife
Changed:
<
<
  • void copyWorld( char from[ ][82], char to[ ][82]) - Copy world from to world to.
>
>
  • void copyWorld( char from[ ][82], char to[ ][82]) - Copy world from to world to.
 There is a cool online version to play with here
Added:
>
>

Turn In:

Runs of the following cases. Run until they are either stable, or 10 steps, whichever come first. Turn in the results.

  • boat.png
  • glider.png
  • f.png

META FILEATTACHMENT attachment="boat.png" attr="" comment="" date="1446390879" name="boat.png" path="boat.png" size="4181" user="JimSkon" version="1"
META FILEATTACHMENT attachment="glider.png" attr="" comment="" date="1446390899" name="glider.png" path="glider.png" size="4182" user="JimSkon" version="1"
META FILEATTACHMENT attachment="f.png" attr="" comment="" date="1446390936" name="f.png" path="f.png" size="4173" user="JimSkon" version="1"
 
META TOPICMOVED by="JimSkon" date="1444937173" from="KenyonCpp.Lab6" to="KenyonCpp.Lab7Kenyon"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback