Selaa lähdekoodia

Update README.md

KrYounger 6 vuotta sitten
vanhempi
commit
49f9d86508
No account linked to committer's email
1 muutettua tiedostoa jossa 79 lisäystä ja 2 poistoa
  1. 79
    2
      README.md

+ 79
- 2
README.md Näytä tiedosto

@@ -1,2 +1,79 @@
1
-# Game-Of-Life-Java
2
-A very simple console implementation of Conway's "game of life" on a fixed size matrix.
1
+# Conway's Game of Life
2
+
3
+The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.
4
+
5
+The "game" is a zero-player game, 
6
+meaning that its evolution is determined by 
7
+its initial state, requiring no further input. 
8
+One interacts with the Game of Life by creating an initial configuration and observing how it evolves, or, for advanced "players", by creating patterns with particular properties.
9
+
10
+### Rules
11
+
12
+The universe of the [Game Of Life ](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) is an infinite two-dimensional matrix grid of square cells, each of which is in one of two possible states, alive or dead, or "populated" or "unpopulated". Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
13
+
14
+* Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
15
+* Any live cell with two or three live neighbours lives on to the next generation.
16
+* Any live cell with more than three live neighbours dies, as if by overpopulation.
17
+* Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
18
+
19
+The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.
20
+
21
+You run each generation, decide what cells will be alive in the next generation, make the next generation the current generation and then repeat for some number of times.
22
+
23
+### a Cool Website to explore
24
+
25
+[http://web.stanford.edu/~cdebs/GameOfLife/](Stanford - Conway's Game of Life) is a terrific site, which has a simulator
26
+on it where you can draw and see what happens.
27
+
28
+## The Lab
29
+
30
+This lab has three parts. 
31
+
32
+The first is to create a single window of a set size where a random game can start and run for some number of generations. 
33
+
34
+The second is to prove your game engine works correctly by correctly running the two very simple tests.
35
+
36
+The third is to do a screen grab of a Size 50 matrix, randomly started, and showing the graphic results after 50 generations.
37
+
38
+You'll use a 2D matrix of ints. So "int[][]" is the basic type. When you set the dimension, as referenced in the UML,
39
+you will then set the arrays to `int[50][50]` if dimension is set to 50.
40
+
41
+You'll create two constructors and a few methods to help you break the problem up.
42
+
43
+`isAlive(int, int, int[][])` is the heart of the ConwayGameOfLife class.
44
+
45
+you call it to determine if the cell at i,j will be alive in the next generation, If the cell and its immediate neighbors
46
+fulfill the rules above, the cell lives (1), if not it does (0). when you are at the end of the matrix, reach back around to the "other side" to get the adjacent cell. This essentially makes the top edge meet with the bottom edge, and left edge meet with the right edge.
47
+
48
+`simulate(numberOfGenerations)` returns the final state of the matrix after simulating numberOfGenerations. 
49
+
50
+To determine each generation, you should do a nested FOR loop through the currentGeneration matrix, taking the values from the currentGeneration, and deciding on the live/die for that cell in the nextGeneration matrix. 
51
+
52
+at the end of each generation, you should `copyAndZeroOut(nextGeneration, currentGeneration)`, this routine should
53
+copy each i,j value from nextGeneration to the same i,j in currentGeneration. Then it should put a 0 into i,j or nextGeneration. Then you loop and do it again until generations > maxGenerations.
54
+
55
+In each of your Constructors, the first thing you should do is create an instance variable displayWindow from the provided
56
+SimpleWindow class. 
57
+
58
+```aidl
59
+ this.displayWindow = new SimpleWindow(dimension);
60
+```
61
+
62
+at the top of your main generations loop, you shoud display the currentGeneration matrix:
63
+```aidl
64
+ this.displayWindow.display(currentGeneration, generations);
65
+```
66
+
67
+at the botom of the loop, you should call the window's `sleep` method to delay for 125 milliseconds
68
+```aidl
69
+ this.displayWindow.sleep(125);
70
+```
71
+
72
+Finally, you should create a `private int[][] createRandomStart(Integer dimension)` method
73
+that creates a int[][] array and loops through it puting in randoom 1 or 0 values for each cell in the 
74
+array. This can be used to "seed" the simulation in the `ConwayGameOfLife(Integer dimension)` constructor.
75
+
76
+The testing constructor `ConwayGameOfLife(Integer dimension, int[][] startmatrix)` takes the dimension and the
77
+test starting array.
78
+
79
+