diff --git a/FrequencyClass.png b/FrequencyClass.png new file mode 100644 index 0000000..133a511 Binary files /dev/null and b/FrequencyClass.png differ diff --git a/Gosper_Glider_Gun.png b/Gosper_Glider_Gun.png new file mode 100644 index 0000000..e4a30d6 Binary files /dev/null and b/Gosper_Glider_Gun.png differ diff --git a/Heavy_Spaceship.png b/Heavy_Spaceship.png new file mode 100644 index 0000000..a7366da Binary files /dev/null and b/Heavy_Spaceship.png differ diff --git a/Medium_Spaceship.png b/Medium_Spaceship.png new file mode 100644 index 0000000..06cb880 Binary files /dev/null and b/Medium_Spaceship.png differ diff --git a/game_of_life.ipynb b/game_of_life.ipynb new file mode 100644 index 0000000..00fab78 --- /dev/null +++ b/game_of_life.ipynb @@ -0,0 +1,2085 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# High Level Programming Project - Group 7 " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# GAME OF LIFE" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This game is a zero player game, which means that there is no need for participants because the game is based on its initial state, or seed (in simple terms the first living cells in the grid before the game starts). Historically, Game of Life was inspired by John Von Neumann's ideas about biologically based self-replicating machines, such as cell replication. It is considered a cellular automaton because it is a structure that can be used to simulate complex systems through a grid of cells to which the concept of neighbourhood is applied and for which each cell is assigned a state (live or dead). The definition of the model is produced after the interaction with the neighbouring cells which is done by applying the rules defined below. Finally, the game has been proven Turing-complete, which means that it can theorotically perform any calculation. There is an example of pattern \"glider gun\" formed by two spaceships colliding with a stream of \"gliders\" (the only spaceship that can navigate diagonally). A group of gliders can be modeled like the logic gates of a computer processor.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1. How the game works\n", + "\n", + "The Game of Life is built on a grid of nine squares, every cell has eight neighboring cells. A given cell (i, j) in the simulation is accessed on a grid [i][j], where i and j are the row and column indices, respectively. The value of a given cell at a given instant of time depends on the state of its neighbors at the previous time step. The Game of Life has four rules:\n", + "\n", + "* Overpopulation : if a living cell is surrounded by more than three living cells, it dies.\n", + "\n", + "* Stasis : if a living cell is surrounded by two or three living cells, it survives.\n", + "\n", + "* Underpopulation : if a living cell is surrounded by fewer than two living cells, it dies.\n", + "\n", + "* Reproduction : if a dead cell is surrounded by exactly three cells, it becomes a live cell." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2. Approach\n", + "\n", + "* Initialize the cells in the grid\n", + "* At each time step in the simulation, for each cell (i, j) in the grid, do the following:\n", + " * a. Update the value of cell (i, j) based on \n", + " its neighbors, taking into account the \n", + " boundary conditions\n", + " * b. Update the display of grid values" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np #For 2D array(matrix) manipulation\n", + "import matplotlib.pyplot as plt #For update the simulation (or in easy words to make stuffs move)\n", + "import matplotlib.animation as animation \n", + "from IPython.display import HTML\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "#States of cells\n", + "live = 1 #condition to the cell be ON (white color in the grid)\n", + "dead = 0 #condition to the cell be OFF (black color in the grid)\n", + "states = [live, dead] " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.1 Initialize the cells of the grid" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "#Creation of the world\n", + "def create_world(N=38):\n", + " if N > 38:\n", + " return np.zeros((N,N))\n", + " else:\n", + " return np.zeros((38,38))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* Defining the type of each pattern:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "#Initialisation of the seed\n", + "def initialize_world(world, pattern=\"default\"):\n", + " if(pattern==\"default\"):\n", + " gap = world.shape[0]//3 #alocate the pattern in the middle of the chart \n", + " size = world.shape[0] - 2*gap #alocate the patterns in the middle of the the chart \n", + " grid = np.random.choice(states, size**2, p=[0.3, 0.7]).reshape(size, size)\n", + " world[gap:gap+size, gap:gap+size] = grid # grid of the patterns \n", + " return\n", + " if(pattern == \"stillLifes\"): \n", + " stillLifes(world)\n", + " return\n", + " if(pattern==\"blinker\"): \n", + " blinker(world)\n", + " return\n", + " if(pattern==\"toad\"): \n", + " toad(world)\n", + " return\n", + " if(pattern==\"pulsar\"): \n", + " pulsar(world)\n", + " return\n", + " if (pattern==\"glider\"): \n", + " glider(world)\n", + " return\n", + " if (pattern==\"light_spaceship\"): \n", + " light_spaceship(world)\n", + " return\n", + " if (pattern==\"medium_spaceship\"):\n", + " medium_spaceship(world)\n", + " return\n", + " if (pattern==\"heavy_spaceship\"):\n", + " heavy_spaceship(world)\n", + " return\n", + " if (pattern==\"gun\"): \n", + " gun(world)\n", + " return\n", + " if (pattern==\"unbouded\"):\n", + " unbouded(world)\n", + " return" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 Update the grid" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "#Itarations through generation\n", + "def update_world(frameNum,img,world):\n", + " world_copy = world.copy()\n", + " N = world.shape[0]\n", + " for i in range(N):\n", + " for j in range(N):\n", + " s = world[(i+1)%N,j]+world[i,(j+1)%N]+world[(i-1)%N,j]+world[i,(j-1)%N]+\\\n", + " world[(i+1)%N,(j+1)%N]+world[(i-1)%N,(j-1)%N]+world[(i+1)%N,(j-1)%N]+world[(i-1)%N,(j+1)%N]\n", + " \n", + " if world[i,j] == live:\n", + " if s>3 or s<2:\n", + " world_copy[i,j] = dead # overpopulation and underpopulation\n", + " elif s ==3:\n", + " world_copy[i,j] = live #reproduction \n", + " \n", + " img.set_data(world_copy) #we need to make a copy of the world in order to update the cells correctly \n", + " world[:] = world_copy[:]\n", + " return img" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "#Display of the animation\n", + "def animations(world):\n", + " fig, ax = plt.subplots() \n", + " img = ax.imshow(world, cmap='gray') \n", + " anim = animation.FuncAnimation(fig, update_world, fargs=(img, world), \n", + " frames = 25, \n", + " interval=500)\n", + " plt.close(anim._fig)\n", + " return anim" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3. Categories of patterns thought generations " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.1 Caracteristics of the patterns\n", + "\n", + "
    \n", + " \n", + "Number of cells : the number of cells stay alive in each generation;\n", + "\n", + "Bounding box : is the smallest rectangular array of cells that contains the entire pattern. It is one of the standard ways to measure the size of an object; the other standard metric is the population, in other words is the size of square box that fits the pattern;\n", + " \n", + "Frequency class : The frequency class of an object is a measure of its commonness. The frequency class of an object O, in a given set of objects, is defined as x if and only if the most common object in the set, M, is 2x times as common as O.\n", + " \n", + "![](FrequencyClass.png)\n", + "\n", + "Period : is the smallest number of generations it takes for it to reappear in its original form, possibly with some slight modification of interest.The pattern return at its initial state after \"x\" generations;\n", + " \n", + "Heat : The heat of an oscillator or spaceship is the average number of cells that change state in each generation, in other words is the number of \"births\" and \"deaths\";\n", + "\n", + "Mod : This caracteristic just the oscillator or spaceship have it. The Mod of a pattern is the smallest number of generations that it takes for it to reappear in its original form, possibily subject to some rotation or reflection. The mod of a pattern may be equal to its period, but it may also be a quarter of the period (for oscillators that rotate 90 degrees every quarter period) or half the period (for other oscillators that rotate 180 degrees every half period, oscillators with 180 degree rotational symmetry that rotate 90 degrees every half period, and also for flippers);\n", + " \n", + "Volatility : The volatility of an oscillator is the size (in cells) of its rotor divided by the sum of the sizes of its rotor and its stator. In other words, it is the proportion of cells involved in the oscillator which actually oscillate.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.2 Still Lifes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Still life (cellular automaton) In Conway's Game of Life and other cellular automata, is a pattern that does not change from one generation to the next. A still life can be thought of as an oscillator with unit period.\n", + "In the following code, we are implementing three types of still lives shapes: Block, Beehive and Loaf\n", + "\n", + "| Caracteristic | Block | Beehive | Loaf |\n", + "|-----------------|-------|---------|------|\n", + "| Period | 1 | 1 | 1 |\n", + "| Bounding Box | 2x2 | 3x4 | 4x4 |\n", + "| Frequency class | 0 | 0.9 | 2.7 |\n", + "\n", + "![](still_life.png)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "def stillLifes(world):\n", + " N = world.shape[0]\n", + " type_still_life = np.random.randint(0,3)\n", + " print(type_still_life)\n", + " initial = np.random.randint(0,N,(1,2)).squeeze()\n", + " i, j = initial[0] , initial[1]\n", + " #Block\n", + " if type_still_life == 0:\n", + " world[i,j] = live\n", + " world[(i+1)%N, j] = live\n", + " world[i,(j+1)%N] = live\n", + " world[(i+1)%N,(j+1)%N] = live\n", + " #Beehive\n", + " elif type_still_life == 1:\n", + " world[(i+1)%N, j] = live\n", + " world[i,(j+2)%N] = live\n", + " world[(i+1)%N,(j+1)%N] = live\n", + " world[i, (j-1)%N] = live\n", + " world[(i-1)%N,j] = live\n", + " world[(i-1)%N,(j+1)%N] = live\n", + " #Loaf\n", + " elif type_still_life == 2:\n", + " world[(i+1)%N, j] = live\n", + " world[i,(j+2)%N] = live\n", + " world[i, (j-1)%N] = live\n", + " world[(i-1)%N,j] = live\n", + " world[(i-1)%N,(j+1)%N] = live\n", + " world[(i+1)%N,(j+2)%N] = live\n", + " world[(i+2)%N,(j+1)%N] = live" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.3 Oscillators \n", + "\n", + "An oscillator is a pattern that returns to its initial configuration after some number of steps. The static patterns shown above could be thought of as oscillators with a period of one. Here are two commonly-seen period-two oscillators:" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **The \"Blinker\"**\n", + "\n", + "Blinker is the smallest partern of the called group of oscilators which are made of patterns that after generations they return to the exact position. The parameter of the minimum number of generation until achieving the inicial state is called: period. For intance, the blinker has a period of 2 what means that after two generations it return to the initial position.We can consider the blinker a kind of \"Periodic Life pattern\".\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 3 |\n", + "| Bounding box | 3x3 |\n", + "| Frequency class | 0,1 |\n", + "| Period | 2 |\n", + "| Mod | 1 |\n", + "| Heat | 4 |\n", + "| Volatility | 0,80 |" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "def blinker(world):\n", + " center = world.shape[0]//2 #getting the center of the world\n", + " #translating the shape to put it in the center of the world\n", + " world[center][center-1] = world[center][center] = world[center][center + 1] = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Main\n", + "world = create_world(40) \n", + "initialize_world(world,\"blinker\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **The \"Toad\"**\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 6 |\n", + "| Bounding box | 4x4 |\n", + "| Frequency class | 7,1 |\n", + "| Period | 2 |\n", + "| Mod | 2 |\n", + "| Heat | 8 |\n", + "| Volatility | 0,80 |" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#oscillators The \"Toad\"\n", + "def toad(world):\n", + " center = world.shape[0]//2 #getting the center of the world\n", + " #translating the shape to put it in the center of the world\n", + " world[center][center] = world[center][center+1] = world[center][center-1] = 1\n", + " world[center - 1][center] = world[center-1][center-1] = world[center-1][center-2] = 1\n", + " \n", + " \n", + "#Main\n", + "world = create_world(15) \n", + "initialize_world(world,\"toad\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **The \"Pulsar\"**\n", + "\n", + "Here's a period-three oscillator known as \"The Pulsar\", which displays some appealing symmetry.\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 48 |\n", + "| Bounding box | 15x15 |\n", + "| Frequency class | 12,1 |\n", + "| Period | 3 |\n", + "| Mod | 3 |\n", + "| Heat | 42,7 |\n", + "| Volatility | 0,73 |" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#oscillators The \"Pulsar\"\n", + "def pulsar(world):\n", + " N = world.shape[0]\n", + " #world's center\n", + " c = N//2\n", + " #symetry coefficents\n", + " X=[1,1,-1,-1]\n", + " Y=[1,-1,1,-1]\n", + " for x, y in zip(X, Y):\n", + " left = c - x * 2\n", + " right = c - x * 4\n", + " world[c + y, min(left, right): max(left, right) + 1] = world[c + y * 6, min(left, right): max(left, right) + 1] = live\n", + " up = c + y * 2\n", + " down = c + y * 4\n", + " world[min(up, down): max(up, down) + 1, c - x] = world[min(up, down): max(up, down) + 1, c - x * 6] = live\n", + "\n", + " \n", + "#Main\n", + "world = create_world(15) \n", + "initialize_world(world,\"pulsar\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.4 Spaceships" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **Glider**\n", + "\n", + "The glider is a pattern that travels across the board in Conway's Game of Life. Gliders are the smallest spaceships, and they travel diagonally at a speed of one cell every four generations. The glider is often produced from randomly generated starting configurations.\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 5 |\n", + "| Bounding box | 3x3 |\n", + "| Frequency class | 1,8 |\n", + "| Period | 4 |\n", + "| Mod | 2 |\n", + "| Heat | 4 |\n", + "\n", + "Mod : 2 (After 2 generations the pattern becomes a 90 degre left rotation and a reflection of its initial state.)\n", + " \n", + "![](glider.png)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#oscillators The \"glider\"\n", + "def glider(world):\n", + " center = world.shape[0] // 2 #getting the center of the world\n", + " #translating the shape to put it in the center of the world\n", + " world[center+1][center] = world[center][center-1] = world[center][center+1] = live\n", + " world[center+1][center+1] = world[center-1][center+1] = 1\n", + "\n", + "\n", + "#Main\n", + "world = create_world(3) \n", + "initialize_world(world,\"glider\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **Light spaceship**\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 9 |\n", + "| Bounding box | 35x4 |\n", + "| Frequency class | 11,2 |\n", + "| Period | 4 |\n", + "| Mod | 2 |\n", + "| Heat | 11 |\n", + "\n", + "Mod : 2 (After 2 generations the pattern becomes a 180 degres rotation)\n", + "\n", + "![](light.png)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# lightweight spaceship\n", + "def light_spaceship(world):\n", + " center = world.shape[0] // 2 #getting the center of the world\n", + " #translating the shape to put it in the center of the world\n", + " world[center][center+1]=live\n", + " world[center][center+4]=live\n", + " world[center+1][center+0]=live\n", + " world[center+2][center+0]=live\n", + " world[center+2][center+4]=live\n", + " world[center+3][center+0:center+4]=live\n", + "#Main\n", + "world = create_world(20) \n", + "initialize_world(world,\"light_spaceship\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **Medium spaceship**\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 11 |\n", + "| Bounding box | 6x4 |\n", + "| Frequency class | 13,2 |\n", + "| Period | 4 |\n", + "| Mod | 2 |\n", + "| Heat | 15 |\n", + "\n", + "Mod : 2 (After 2 generations the pattern becomes a 180 degre rotation)\n", + "\n", + "![](Medium_Spaceship.png)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# mediumweight spaceship\n", + "def medium_spaceship(world):\n", + " center = world.shape[0] // 2 #getting the center of the world\n", + " #translating the shape to put it in the center of the world\n", + " world[center+0,3] = world[center+1,1] = world[center+1,5] = live\n", + " world[center+2,0] = world[center+3,0] = world[center+3,5] = world[center+4,0:5] = live\n", + "\n", + "#Main\n", + "world = create_world(20) \n", + "initialize_world(world,\"medium_spaceship\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **Heavy spaceship**\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 13 |\n", + "| Bounding box | 7x4 |\n", + "| Frequency class | 15,7 |\n", + "| Period | 4 |\n", + "| Mod | 2 |\n", + "| Heat | 19 |\n", + "\n", + "Mod : 2 (After 2 generations the pattern becomes a 180 degre rotation)\n", + "\n", + "![](Heavy_Spaceship.png)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# heavyweight spaceship\n", + "def heavy_spaceship(world):\n", + " center = world.shape[0]//2 #getting the center of the world\n", + " #translating the shape to put it in the center of the world\n", + " world[0,center+3]=live\n", + " world[0,center+4]=live\n", + " world[1,center+1]=live\n", + " world[1,center+6]=live\n", + " world[2:4,center]=live\n", + " world[3,center+6]=live\n", + " world[4,center:center+6]=live\n", + "\n", + "\n", + "#Main\n", + "world = create_world(20) \n", + "initialize_world(world,\"heavy_spaceship\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* **The Gosper Glider Gun**\n", + "\n", + "This pattern create streams of gliders forever.\n", + "\n", + "It is pattern that after can be shuttle running some generations it moves back to initial state, than emits forever glider which is a spaceship pattern that travels diagonally. Consider the first unbounded-growth.\n", + "\n", + "| Caracteristic | Value |\n", + "|-----------------|--------|\n", + "| Number of cells | 36 |\n", + "| Bounding box | 36x9 |\n", + "| Period | 30 |\n", + "\n", + "![](Gosper_Glider_Gun.png)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#spaceship The \"Gosper Glider Gun\"\n", + "def gun(world):\n", + " world[5:7,1:3] = live #setting a rectangle of cells to one\n", + " world[3,13:15] = live #setting a line of cells to one\n", + " world[4,12] = world[4,16] = live\n", + " world[5,11] = world[5,17] = live\n", + " world[6,11] = world[6,15] = live\n", + " world[6,17:19] = live #setting a line of cells to one\n", + " world[7,11] = world[7,18] = live\n", + " world[8,12] = world[8,16] = live\n", + " world[9,13:15] = live #setting a line of cells to one\n", + " world[1,25] = live\n", + " world[2,23] = world[2,25] = live\n", + " world[3:6,21:23] = live #setting a rectangle of cells to one\n", + " world[6,23] = live\n", + " world[6:8,25] = live #setting a line of cells to one\n", + " world[3:5,35:37] = live #setting a rectangle of cells to one\n", + "\n", + "world = create_world(36) # all cells in the begining are dead\n", + "initialize_world(world,\"gun\")\n", + "\n", + "#print anim_to_html(anim)\n", + "anim = animations(world)\n", + "HTML(anim.to_html5_video())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4. Analyse the evolutions of patterns " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Nowadays it has been seen many application to Conway's Game of Life since biology to music due to its simple rules and coverage.Considering that\n", + "at the earlier studies of John Conway in 1970's,the elementary patterns were discovered with the use of blackboards, graph papwes and game boards. \n", + "After 50 years the academic world has changed dramatically with the popularization and evolution computational power able to do the more complex \n", + "calculations in seconds what led to more advanced patterns.\n", + "\n", + "Talking about still life patterns, this pattern is divided into groups such as :strict still life,pseudo still lifes, stable constellations and quasi still\n", + "lifes, considering the first two groups mentioned as the most important ones.For the strict still life,it is formed by one or two components, in case one\n", + "cell is removed it breaks the equilibrium and as the consequence the pattern is not considered a still life anymore due to the main characterist of \n", + "being a period 1 pattern.As example we have the Beehive shown in this work, the Beehive with tail and the \"table on table\".The pseudo still life are made of two or more island which means copies of still life which if one cell is removed, the\n", + "pattern is strict still life for the example the bi-block,the triple pseudo still life and teh quad pseudo still life. The blockade is an example of stable \n", + "constellation which is made by four blocks distant one from another and with no interaction. The last pattern is similar to a constellation with the slightest\n", + "difference that a dead cell between the block maintain the estability as the example the tub and the quasi still life. The most recently discovered in the Still \n", + "Life is \"House on house siamese table-on-table weld hat-siamese-hat\" which comprises 34 cells and it is an example of stric still lived in 2019.\n", + "\n", + "The oscillator pattern repeats itself after finite number of generations without moving in the grid and since the earlier works of Conway with the blinker and \n", + " pulsar with period respectely of 2 and 3, described in this project, much more complex patterns were developped with the substancial growth of the period reaching\n", + "the maximum of 312 so far with Dave Greene a called period-triple p104 gun in 2004. The most recent pattern was the first 23 rd period oscillator by Luka Okanishi\n", + "in November 2019.\n", + "\n", + "The spaceship is the pattern which after input an inicial seed, after a finite number of generation the pattern returns to the initial state but in a different location\n", + "in the grid. Due to this fact, spaceships have the intrinsic characteristic of speed which is defined by the the number of cells that an object travelled until returning \n", + "to its initial position, times aconstant c( which represents the speed of light)divided by the period ( number of generations until reaching its initial state).For instance,\n", + "a glider has a period of 4 and after its initial state it moves only one cell during its period that is why the speed is c/4.\n", + "It is assumption that no spaceship can move diagonally faster than c/4 and not faster than c/2 horizontaly.Spaceships are divided into the following classes :elementary,enginnered,adjustable and many others. The first one generally has a small size such as the glider.\n", + "which the latest discovery was done by Adam Gauche called \"Sir Robin\" which is also well-known as teh first \"knightship\" what means that for every two cells that moves horizontally,\n", + "one moves vertically.Engineered spaceships consists requires small interaction and the latest invention was the 2-engine Cordership discovered by Adam F. Pierce in 2017. Lastly,\n", + "the adjustable spaceship can adjust your own speed as the latest is the \"Demonoid \"which consists of a Gemini and orthogonal in 2015. The evolution of spaceship was observed in terms\n", + "of the dramatically increase of the number of cells, different speeds and ability to move in different directions such as vertically or in an oblique way.\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Sources:\n", + "\n", + "https://www.conwaylife.com/\n", + "\n", + "https://cs.stanford.edu/people/eroberts/courses/soco/projects/2001-02/cellular-automata/walks%20of%20life/patterns.html\n", + "\n", + "http://web.archive.org/web/20090603015231/http://ddi.cs.uni-potsdam.de/HyFISCH/Produzieren/lis_projekt/proj_gamelife/ConwayScientificAmerican.htm\n", + "\n", + "https://books.google.it/books?id=Dvb0DAAAQBAJ&pg=PT158&lpg=PT158&dq=spaceship+speed+pattern+game+of+life&source=bl&ots=Hz9Q4ei6qi&sig=ACfU3U2yETRZztVfg_8ITIem1x0QuLt6HA&hl=pt-BR&sa=X&ved=2ahUKEwijmLbo3aHpAhXtQhUIHfcuBb84FBDoATAGegQIChAB#v=onepage&q=spaceship%20speed%20pattern%20game%20of%20life&f=false\n", + "\n", + "http://web.math.ucsb.edu/~padraic/ucsb_2014_15/ccs_problem_solving_w2015/The%20Game%20of%20Life.pdf\n", + "\n", + "https://niginsblog.wordpress.com/2016/03/07/new-spaceship-speed-in-conways-game-of-life/\n", + " \n", + "https://en.wikipedia.org/wiki/Oscillator_(cellular_automaton)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/glider.png b/glider.png new file mode 100644 index 0000000..babd8c5 Binary files /dev/null and b/glider.png differ diff --git a/light.png b/light.png new file mode 100644 index 0000000..27ed356 Binary files /dev/null and b/light.png differ diff --git a/still_life.png b/still_life.png new file mode 100644 index 0000000..aa2e71b Binary files /dev/null and b/still_life.png differ