Add files via upload
This commit is contained in:
parent
54c107e3d2
commit
d18d328f2d
426
Life.ipynb
426
Life.ipynb
@ -14,114 +14,16 @@
|
||||
"+ Any empty cell with exactly three live neighbors becomes a live cell in the next generation.\n",
|
||||
"+ All other cells are empty in the next generation.\n",
|
||||
"\n",
|
||||
"For example, in the diagram below, grey cells are live. In the transition from Generation 0 to 1, the cell marked \"E\" becomes empty (dies off) because it has zero live neighbors. In the next transition, the cell marked \"L\" becomes live, because it has 3 live neighbors. All other cells stay the same. \n",
|
||||
"For example, in the diagram below, \"`@`\" cells are live. In the transition from Generation 0 to 1, the cell marked \"`,`\" becomes empty (dies off) because it has zero live neighbors. In the next transition, a fourth `@` becomes live, because it has 3 live neighbors. All other cells stay the same. \n",
|
||||
"\n",
|
||||
"<table><tr><td><table>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td style=\"background-color:lightgrey\"> E \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td ></td> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
"</table>\n",
|
||||
"<br><center>Generation 0\n",
|
||||
" . . . . . . . . . . . . . . .\n",
|
||||
" . . . @ . . . . , . . . . . .\n",
|
||||
" . @ . . . . @ . . . . @ @ . .\n",
|
||||
" . @ @ . . . @ @ . . . @ @ . .\n",
|
||||
" . . . . . . . . . . . . . . .\n",
|
||||
" Gen 0 Gen 1 Gen 2\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"<td><table>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > L\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td ></td> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
"</table>\n",
|
||||
"<br><center>Generation 1\n",
|
||||
"\n",
|
||||
"<td><table>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td ></td> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
"</table>\n",
|
||||
"<br><center>Generation 2\n",
|
||||
"</table>\n",
|
||||
"\n",
|
||||
"The world continues to evolve by these rules for as long as you care to observe. \n",
|
||||
"\n",
|
||||
@ -142,7 +44,8 @@
|
||||
"\n",
|
||||
"+ **World**: The state of the world must represent which cells are empty and which are live. The tricky part is that the number of cells is infinite, and we can't store an infinite array in a finite computer. I can think of three ways to deal with this problem:\n",
|
||||
" 1. **Change the rules**; make the world finite instead of infinite. (Cells at the edge of the world have fewer neighbors, or perhaps they wrap around to the other side of the world.)\n",
|
||||
" 2. Use a **finite rectangular window** that covers all the live cells in the infinite grid. \n",
|
||||
" 2. Use a **finite rectangular window** that covers all the live cells in the infinite grid. As the world\n",
|
||||
" evolves, this window may have to grow or shift.\n",
|
||||
"<br>Example: `world = [[0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]` \n",
|
||||
"\n",
|
||||
" 3. Represent a world as a **set of live cells.** This set will grow and shrink in size from one generation to the next, but we don't have to worry about overflowing the edges of an array.\n",
|
||||
@ -153,25 +56,10 @@
|
||||
"+ **Cell**: Each cell will be represented as an (x, y) pair of integer coordinates. <br>Example: `cell = (1, 2)`.\n",
|
||||
"+ **Live/Empty**: \n",
|
||||
"A cell is live if it is a member of the set of live cells. \n",
|
||||
"<br>Example: \"`cell in world`\" is True, given the definition of `cell` and `world` above.\n",
|
||||
"<br>Example: \"`cell in world`\" is True, given the definition of `cell` and `world` above, so `cell` is live.\n",
|
||||
"+ **Neighbors**: The cell `(x, y)` has eight neighbors, formed by adding or subtracting 1 from `x` or `y` or both. We can define\n",
|
||||
"a function `neighbors(cell)` to return this set.\n",
|
||||
"<br>Example: `neighbors((8, 8)) == [(7, 7), (8, 7), (9, 7), (7, 8), (9, 8), (7, 9), (8, 9), (9, 9)]`\n",
|
||||
"<table>\n",
|
||||
" <tr style=\"height:3em\">\n",
|
||||
" <td class=\"tg-031e\">(x-1, y-1)\n",
|
||||
" <td class=\"tg-031e\">(x, y-1)\n",
|
||||
" <td class=\"tg-031e\">(x+1, y-1)\n",
|
||||
" <tr style=\"height:3em\">\n",
|
||||
" <td class=\"tg-031e\">(x-1, y)</td>\n",
|
||||
" <td style=\"background-color:lightgrey\">(x, y)</td>\n",
|
||||
" <td class=\"tg-031e\">(x+1, y)</td>\n",
|
||||
" <tr style=\"height:3em\">\n",
|
||||
" <td class=\"tg-031e\">(x-1, y+1)</td>\n",
|
||||
" <td class=\"tg-031e\">(x, y+1)</td>\n",
|
||||
" <td class=\"tg-s6z2\">(x+1, y+1)</td>\n",
|
||||
" </tr>\n",
|
||||
"</table>\n",
|
||||
"\n",
|
||||
"+ **Display**: We will need some way to display the state of the world. Let's defer that for now.\n",
|
||||
"\n",
|
||||
@ -179,131 +67,37 @@
|
||||
"a new world with the new set of live cells according to the rules.\n",
|
||||
"Example: `next_generation({(3, 1), (1, 2), (1, 3), (2, 3)}) == {(1, 2), (1, 3), (2, 3)}`\n",
|
||||
"\n",
|
||||
"+ **Live Neighbor Counts**: I need to know how many live neighbors each cell has. A good way to represent this is a dict of `{(x, y): count}`. But which cells need to be the keys of this dict? We can start with the live cells, and also add any cells neighboring the live cells. An efficient way to generate this dict is to create a `Counter` and pass it every neighbor of every live cell. This may feel like we're doing the counting \"backwards.\" Instead of asking \"for each cell, how many live neighbors does it have?\" we are saying \"for each live cell, increment the count of each of its neighbors.\" The two amount to the same thing because *neighbor* is symmetric—if P is a neighbor of Q, then Q is a neighbor of P. Below we see the neighbor counts for each of the three generations:\n",
|
||||
"+ **Live Neighbor Counts**: I need to know how many live neighbors each cell has. A good way to represent this is a dict of `{(x, y): count}`. But which cells need to be the keys of this dict? We can start with the live cells, and also add any cells neighboring the live cells. An easy way to generate this dict is to create a `Counter` and pass it every neighbor of every live cell. This may feel like we're doing the counting \"backwards.\" Instead of asking \"for each cell, how many live neighbors does it have?\" we are saying \"for each live cell, increment the count of each of its neighbors.\" The two amount to the same thing because *neighbor* is symmetric—if P is a neighbor of Q, then Q is a neighbor of P. Below we see the neighbor counts for each of the three generations; in each generation the top diagram gives the neighbor counts for the empty cells, and the bottom diagram gives the counts for the live cells. This is just to make the diagram easier to read; in the code these are combined into one `Counter`:\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"<table><tr>\n",
|
||||
"\n",
|
||||
"<td><table>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > 1 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > 1 \n",
|
||||
" <tr>\n",
|
||||
" <td > 1 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> \n",
|
||||
" <td > 1 \n",
|
||||
" <tr>\n",
|
||||
" <td> 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 2 \n",
|
||||
" <td > 4 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <tr>\n",
|
||||
" <td > 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <td > 1 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
"</table>\n",
|
||||
"<br><center>Generation 0\n",
|
||||
"\n",
|
||||
"<td><table>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > 1 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td> 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 2 \n",
|
||||
" <td > 3 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <td > 1 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
"</table>\n",
|
||||
"<br><center>Generation 1\n",
|
||||
"\n",
|
||||
"<td><table>\n",
|
||||
" <tr>\n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > 1 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td> 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 3 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 3 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > \n",
|
||||
" <tr>\n",
|
||||
" <td > 2 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 3 \n",
|
||||
" <td style=\"background-color:lightgrey\"> 3 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <td > 1 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 2 \n",
|
||||
" <td > 1 \n",
|
||||
" <td > \n",
|
||||
" </tr>\n",
|
||||
"</table>\n",
|
||||
"<br><center>Generation 2\n",
|
||||
"\n",
|
||||
" . . 1 1 1 . . . . . . . . . .\n",
|
||||
" 1 1 2 @ 1 1 1 1 , . 1 2 2 1 .\n",
|
||||
" 2 @ 4 2 1 2 @ 3 1 . 2 @ @ 2 .\n",
|
||||
" 2 @ @ 1 . 2 @ @ 1 . 2 @ @ 2 .\n",
|
||||
" 1 2 2 1 . 1 2 2 1 . 1 2 2 1 .\n",
|
||||
" Gen 0 Gen 1 Gen 2\n",
|
||||
" . . . . . . . . . . . . . . .\n",
|
||||
" . . . 0 . . . . , . . . . . .\n",
|
||||
" . 2 . . . . 2 . . . . 3 3 . .\n",
|
||||
" . 2 2 . . . 2 2 . . . 3 3 . .\n",
|
||||
" . . . . . . . . . . . . . . .\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"</table>\n",
|
||||
"\n",
|
||||
"Here is the implementation.Note that in `next_generation` the `neighbor_counts` is used two ways: `possible_cells` is used to iterate over all cells that might be live, and `counts` is used to check if a cell has the right number of neighbors."
|
||||
"Here is the implementation. Note that in `next_generation` the `neighbor_counts` is used two ways: `possible_cells` is used to iterate over all cells that might be live, and `counts` is used to check if a cell has the right number of neighbors. I decided to use two names for clarity."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from collections import Counter\n",
|
||||
@ -338,9 +132,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -361,9 +153,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -383,9 +173,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -405,9 +193,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -453,9 +239,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def run(world, n):\n",
|
||||
@ -468,9 +252,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -493,15 +275,13 @@
|
||||
"source": [
|
||||
"# Display\n",
|
||||
"\n",
|
||||
"Now let's see how to display each generation. We'll consider a window on the infinite plane, specified as a range of `Xs` and `Ys` coordinates. The function `picture` turns a world into a string showing what the world looks like, and `display_run` runs the world, displaying the picture at each step."
|
||||
"Now let's see how to display worlds. We'll consider a rectangular window on the infinite plane, specified as ranges of `Xs` and `Ys` coordinates. The function `picture` turns a world into a string showing what the world looks like:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import time\n",
|
||||
@ -510,18 +290,6 @@
|
||||
"LIVE = '@'\n",
|
||||
"EMPTY = '.'\n",
|
||||
"PAD = ' '\n",
|
||||
"\n",
|
||||
"def display_run(world, n=10, Xs=range(10), Ys=range(10), pause=0.1):\n",
|
||||
" \"Step and display the world for the given number of generations.\"\n",
|
||||
" for g in range(n + 1):\n",
|
||||
" clear_output()\n",
|
||||
" display_html('Generation {}, Population {}\\n{}'\n",
|
||||
" .format(g, len(world), pre(picture(world, Xs, Ys))), \n",
|
||||
" raw=True)\n",
|
||||
" time.sleep(pause)\n",
|
||||
" world = next_generation(world)\n",
|
||||
" \n",
|
||||
"def pre(text): return '<pre>' + text + '</pre>'\n",
|
||||
" \n",
|
||||
"def picture(world, Xs, Ys):\n",
|
||||
" \"Return a picture: a grid of characters representing the cells in this window.\"\n",
|
||||
@ -532,9 +300,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@ -552,17 +318,41 @@
|
||||
"print(picture(world, range(5), range(5)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The function `display_run` runs the world for `n` steps, displaying the picture at each step:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def display_run(world, n=10, Xs=range(10), Ys=range(10), pause=0.2):\n",
|
||||
" \"Step and display the world for the given number of generations.\"\n",
|
||||
" for g in range(n + 1):\n",
|
||||
" html = ('Generation {}, Population {}\\n{}'\n",
|
||||
" .format(g, len(world), pre(picture(world, Xs, Ys))))\n",
|
||||
" clear_output()\n",
|
||||
" display_html(html, raw=True)\n",
|
||||
" time.sleep(pause)\n",
|
||||
" world = next_generation(world)\n",
|
||||
" \n",
|
||||
"def pre(text): return '<pre>' + text + '</pre>'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"Generation 10, Population 4\n",
|
||||
"Generation 5, Population 4\n",
|
||||
"<pre>. . . . .\n",
|
||||
". . . . .\n",
|
||||
". @ @ . .\n",
|
||||
@ -575,23 +365,21 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display_run(world, 10, range(5), range(5))"
|
||||
"display_run(world, 5, range(5), range(5))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Interesting Worlds\n",
|
||||
"\n",
|
||||
"Now let's take a look at some initial worlds that *Life* enthusiasts have discovered. It would be tedious to define these with an explicit set of `(x, y)` coordinates, so we will define the function `shape` that takes a picture as input and returns a world; `shape` and `picture` are more-or-less inverses. "
|
||||
"Now let's take a look at some initial worlds that *Life* enthusiasts have discovered. It would be tedious to enumerate these with an explicit set of `(x, y)` coordinates, so we will define the function `shape` that takes a picture as input and returns a world; `shape` and `picture` are more-or-less inverses. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
@ -629,10 +417,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -640,7 +426,7 @@
|
||||
"{(3, 3), (4, 3), (4, 4), (5, 4)}"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -652,10 +438,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -663,7 +447,7 @@
|
||||
"{(3, 3), (3, 4), (4, 3), (4, 4)}"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -674,10 +458,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -685,7 +467,7 @@
|
||||
"{(103, 203), (103, 204), (104, 203), (104, 204)}"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -703,10 +485,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -734,10 +514,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -765,10 +543,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -796,10 +572,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -827,10 +601,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -888,10 +660,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -952,10 +722,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@ -1036,10 +804,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def next_generation(world):\n",
|
||||
@ -1066,9 +832,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.1"
|
||||
"version": "3.5.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user