{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Octopusal Networks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This work is based on the ideas that [Dr. Edward De Bono](https://en.wikipedia.org/wiki/Edward_de_Bono) explained in the books \"The mechanism of mind\" and \"I'm Right, You Are Wrong\", which I highly recommend. In these books De Bono carries out a model of the mind the I found very interesting. I don't actually know if someone else implemented this, anyway this notebook is my interpretation of the model in python.\n", "\n", "For each new feature of the model I build some classes and do some examples to show the results, you can also just read the comments and see the output and then return on the code if you are interested." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Octopuses, tentacles and the beach\n", "\n", "> Imagine a neurone as an octopus with a large number of tentacles (not the usual eight). Some of these tentacles may be very long. Each of them rests on the body of another octopus and can transmit to that octopus an electric shock. If an octopus receives a sufficient number of shocks it wakes up and proceeds to shock others. The beach is covered with a large number of octopuses all linked up in this way. Any octopus may be linked up, by means of long tentacles, to an octopus quite far away. But for the sake of convenience we shall assume an octopus is linked to its physical neighbours.\n", "\n", "So to start we create three classes: Octopus, Tentacle and Beach.\n", "\n", "\n", "An octopus can be awake or sleeping, each time that it receives a shock its excitement increase, when the excitement pass a certain threshold it wakes up and starts to shock others.\n", "\n", "A tentacle for now has two attributes, the octopus owner and the octopus on which it rests. It can shock the octopus on which it rests.\n", "\n", "The beach take in the constructor the parameters width and height and construct a list of octopuses of length = width * height. Then each octopus is connected to its neighbours. When we print out an instance of the class Beach the emoji πŸ™represent an octopus sleeping and the emoji πŸ’‘represent an octopus awake." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "class Octopus:\n", "\n", " shocks_threshold = 2\n", "\n", " def __init__(self, id):\n", " self.id = id\n", " self.awake = False\n", " self.excitement = 0\n", " self.tentacles = []\n", "\n", " def shocked(self, power):\n", " self.excitement += power\n", " if (self.excitement >= Octopus.shocks_threshold):\n", " self.awake = True\n", "\n", " def detail(self):\n", " result = f'{self}\\n'\n", " for tentacle in self.tentacles:\n", " result += f'\\t{tentacle}\\n'\n", " return result\n", "\n", " def __str__(self):\n", " return f'Octopus {self.id} [awake: {self.awake}, excitement: {self.excitement}]'" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "class Tentacle:\n", "\n", " def __init__(self, id, owner, connected):\n", " self.id = id\n", " self.owner = owner\n", " self.connected = connected\n", " owner.tentacles.append(self)\n", "\n", " def shock(self):\n", " self.connected.shocked(1)\n", "\n", " def __str__(self):\n", " id = self.id\n", " owner = self.owner\n", " connected = self.connected\n", " return f'Tentacle {id}: Octopus {owner.id} -> Octopus {connected.id}'" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "class Beach:\n", "\n", " def __init__(self, width, height):\n", " self.width = width\n", " self.height = height\n", " self.octopuses = []\n", " self.create_octopuses()\n", " self.connect_neighbours()\n", "\n", " def create_octopus(self, id):\n", " return Octopus(id=id)\n", "\n", " def create_octopuses(self):\n", " for i in range(0, self.width * self.height):\n", " octopus = self.create_octopus(id=i)\n", " self.octopuses.append(octopus) \n", "\n", " def create_tentacle(self, id, owner, connected):\n", " return Tentacle(id=id, owner=owner, \\\n", " connected=connected)\n", "\n", " def connect_neighbours(self):\n", " width = self.width\n", " height = self.height\n", "\n", " def get_neighbours(x, y):\n", " neighbours = []\n", " neighbours.append((x - 1, y - 1))\n", " neighbours.append((x - 1, y))\n", " neighbours.append((x - 1, y + 1))\n", " neighbours.append((x, y - 1))\n", " neighbours.append((x, y + 1))\n", " neighbours.append((x + 1, y - 1))\n", " neighbours.append((x + 1, y))\n", " neighbours.append((x + 1, y + 1))\n", " return neighbours\n", "\n", " for i in range(0, width * height):\n", " octopus = self.octopuses[i]\n", " coors_neighbours = get_neighbours(i // height, i % width)\n", " tentacle_id = 0\n", " for x, y in coors_neighbours:\n", " try:\n", " neighbour = self.get(x, y)\n", " tentacle = self.create_tentacle(id=tentacle_id, owner=octopus, \\\n", " connected=neighbour)\n", " tentacle_id += 1\n", " except:\n", " continue\n", "\n", " def get(self, x, y,):\n", " width = self.width\n", " height = self.height\n", " if (0 <= x < height) and (0 <= y < width):\n", " return self.octopuses[x * width + y]\n", " else:\n", " raise Exception\n", "\n", " def detail(self):\n", " result = ''\n", " for octopus in self.octopuses:\n", " result += octopus.detail()\n", " return result\n", "\n", " def __str__(self):\n", " result = '\\n'\n", " for x in range(0, self.height):\n", " for y in range(0, self.width):\n", " octopus = self.octopuses[x * self.width + y]\n", " result += 'πŸ’‘' if octopus.awake else 'πŸ™'\n", " result += '\\n'\n", " return result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next cell we create a beach of dimensions 4 x 4 and just print it out." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™\n", "\n" ] } ], "source": [ "beach = Beach(width=4, height=4)\n", "print(beach)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Yellow patch\n", "\n", "> Now if we stimulate a group of octopuses, for example by shining a bright light from a helicopter above, they become active and start sending out shocks along their tentacles. In order to see what is happening we shall assume that when an octopus is awake its colour changes to yellow. So now we see a patch of yellow spreading outwards from the group we stimulated with the bright light. Now that yellow patch could go on spreading until it covered until it covered the whole beach of octopuses. This would be somewhat equivalent to an epilectic fit in the brain, with all systems activated.\n", "\n", "Here we introduce the class Helicopter that has a static method with two parameters: the beach and the clause where. The parameter \"where\" is a list of coordinates that tell the helicopter which octopuses to wake up.\n", "\n", "Then we extend the class Beach to create the class BeachWithSpreading. This class adds time and movement to the beach. The main method is \"animate\" that starts by waking up the octopus specified by the parameter \"where\" and then make a loop for certain iterations where each octopus awake shocks every other octopus connected to him. If at a certain point all octopuses are sleeping the loop stop because nothing can happen." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from random import shuffle\n", "\n", "class Helicopter:\n", "\n", " @staticmethod\n", " def light(beach, where):\n", " shuffle(where)\n", " for x, y in where:\n", " octopus = beach.get(x, y)\n", " octopus.shocked(Octopus.shocks_threshold)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next example we create an array \"center\" that has the coordinates of the four octopuses at the center of the beach and then use the helicopter to wake them up." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n" ] } ], "source": [ "size = 10\n", "half = int(size / 2)\n", "center = [(half, half), (half, half - 1), (half - 1 , half), (half - 1, half - 1)]\n", "\n", "beach = Beach(width=size, height=size)\n", "\n", "Helicopter.light(beach, center)\n", "\n", "print(beach)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "class AllSleepingException(Exception):\n", " pass\n", "\n", "class BeachWithSpreading(Beach):\n", "\n", " def __init__(self, width, height, shocks_threshold=3):\n", " super().__init__(width, height)\n", " Octopus.shocks_threshold = shocks_threshold\n", "\n", " def start(self, where):\n", " Helicopter.light(self, where)\n", "\n", " def print_start(self, show):\n", " if show:\n", " print('Start')\n", " print(self)\n", "\n", " def iteration(self):\n", " awake = [o for o in self.octopuses if o.awake]\n", " if len(awake) == 0:\n", " raise AllSleepingException\n", " for octopus in awake:\n", " for tentacle in octopus.tentacles:\n", " tentacle.shock()\n", "\n", " def print_iteration(self, show, i):\n", " if show:\n", " print(f'Iteration {i + 1}')\n", " print(self)\n", "\n", " def animate(self, where=None, iterations=10, show=True):\n", " if where != None:\n", " self.start(where)\n", " self.print_start(show)\n", " for i in range(0, iterations):\n", " try:\n", " self.iteration()\n", " self.print_iteration(show, i)\n", " except AllSleepingException:\n", " if show == True:\n", " print('It looks like everyone is sleeping πŸ˜•')\n", " break" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next example we create a beach and animate it with the parameter \"where\" set at \"center\", that is the array created previously. You can see how the yellow patch spreads to take all the beach" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Start\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 1\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 2\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 3\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 4\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 5\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 6\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 7\n", "\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "\n", "Iteration 8\n", "\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™\n", "\n", "Iteration 9\n", "\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "\n", "Iteration 10\n", "\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘\n", "\n" ] } ], "source": [ "beach = BeachWithSpreading(width=10, height=10)\n", "beach.animate(where=center)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Smell\n", "\n", "> Let us now add another feature. When an octopus is awake (and yellow) it gives off a pungent smell - a sort of cross between decaying fish and ammonia. This smell is so unpleasant to all octopuses that if the strength of the smell reaches a certain level they refuse to be woken up. So when the spreading yellow patch of activated octopuses has reached a certain size the smell will have reached a certain level of strength. At this point no further octopus will wake up, so the patch stays limited that size.\n", "\n", "> In neurological terms we have a spreading activation and a build-up inhibition. This inhibition could be brought about through a build-up of chemicals or direct negative feedback carried by another set of nerves. The function is the same.\n", "\n", "Now we introduce the class OctopusWithSmell that adds to the class Octopus a mechanism by which if the smell in the environment (passed in the constructor) pass a certain threshold the octopus can't wake up. It also increase the smell in the environment when the octopus wakes up." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "class OctopusWithSmell(Octopus):\n", "\n", " smell_threshold = 20\n", "\n", " def __init__(self, id, environment):\n", " super().__init__(id)\n", " self.environment = environment\n", "\n", " def shocked(self, power=0):\n", " if (self.awake):\n", " return\n", " self.excitement += power\n", " if (self.excitement >= Octopus.shocks_threshold and\n", " self.environment.smell < OctopusWithSmell.smell_threshold):\n", " self.awake = True\n", " self.environment.smell += 1" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "class BeachWithSmell(BeachWithSpreading):\n", "\n", " def __init__(self, width, height, shocks_threshold=5, smell_threshold=20):\n", " super().__init__(width, height, shocks_threshold)\n", " self.smell = 0\n", " OctopusWithSmell.smell_threshold = smell_threshold\n", "\n", " def create_octopus(self, id):\n", " return OctopusWithSmell(id=id, environment=self)\n", "\n", " def print_iteration(self, show, i):\n", " if show:\n", " print(f'Iteration {i + 1} - smell: {self.smell}')\n", " print(self)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As you can see in the next cell, this time the yellow patch stop to spread at a certain point, when the smell has reached a certain level." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Start\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 1 - smell: 4\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 2 - smell: 4\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 3 - smell: 12\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 4 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 5 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 6 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 7 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 8 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 9 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 10 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n" ] } ], "source": [ "beach = BeachWithSmell(width=10, height=10)\n", "beach.animate(center)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Soreness\n", "\n", "> If this was all there was to it, the patch of yellowness would always be circular around the octopuses on whom the helicopter light had first shone. So let us add another effect. If an octopus is already awake when it receives an electric shock through a tentacle, that patch of skin under the tentacle gets rather sore. This soreness means that the octopus is much more likely to respond to a shock from this particular tentacle. This means that if two spots of helicopter light awake two groups of nearby octopuses, in the future the connection between those two groups will be stronger than with other octopuses.\n", "\n", "> This effect gives rise to the important phenomenon of association and also to reconstruction. If two helicopter lights have been used in this way and in the future only one light is used, the yellow patch is more likely to spread to the group that is better connected than anywhere else. So the situation is recreated as if there were two spots of light at the same time, and the yellow patch does not spread as a simple circle around the stimulus point but follows the track of increased connectedness which itself depends on past experience. In this way the crowd of octopuses can repeat or reconstruct a pattern. Even if the input is not the exact this time, the same shape of yellow patch can be produced.\n", "\n", "To add this effect we just change the method \"shock\" on the class Tentacle to manage the fact that if both octopus are awake the soreness of the tentacle increase. We also add the method \"night\" to the beach that desactivates all octopuses but keeps the connections between them." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "class TentacleWithSoreness(Tentacle):\n", "\n", " def __init__(self, id, owner, connected):\n", " super().__init__(id, owner, connected)\n", " self.soreness = 1\n", "\n", " def shock(self):\n", " if self.connected.awake:\n", " self.soreness += 1\n", " else:\n", " self.connected.shocked(self.soreness)\n", " \n", " def __str__(self):\n", " return super().__str__() + f': Soreness {self.soreness}'" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "class BeachWithSoreness(BeachWithSmell):\n", "\n", " def __init__(self, width, height, shocks_threshold=50, smell_threshold=50):\n", " super().__init__(width, height, shocks_threshold, smell_threshold)\n", "\n", " def create_tentacle(self, id, owner, connected):\n", " return TentacleWithSoreness(id=id, owner=owner, \\\n", " connected=connected)\n", "\n", " def print_night(self):\n", " print()\n", " print(\"Night\\n\")\n", " for i in range(0, self.height):\n", " print(\"🌚\" * self.width)\n", " print(\"\\n\")\n", " \n", " def night(self, show=False):\n", " for octopus in self.octopuses:\n", " if octopus.awake: self.smell -= 1\n", " octopus.awake = False\n", " octopus.excitement = 0\n", " if show: self.print_night()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next example we first animate the beach for 10 iteration with a shape like an \"L\", so that the octopuses on this shape get connected. Then we make sleep all octopuses and animate again the\n", "beach but only with the vertical part of the \"L\". This time the yellow patch insted of spreding circularly it follows the past experience and recreates the \"L\"." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Start\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 1 - smell: 12\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 2 - smell: 13\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 3 - smell: 14\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 4 - smell: 14\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 5 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 6 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 7 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 8 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 9 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 10 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 11 - smell: 20\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n" ] } ], "source": [ "size = 10\n", "half = int(size / 2)\n", "\n", "L_form_horizontal = []\n", "L_form_vertical = []\n", "for x in range(0 + half // 2, size - half // 2):\n", " L_form_vertical.append((x, half // 2))\n", " L_form_vertical.append((x, half // 2 - 1))\n", "for y in range(0 + half // 2, size - half // 2):\n", " L_form_horizontal.append((half + half // 2, y))\n", " L_form_horizontal.append((half + half // 2 - 1, y))\n", "L_form = L_form_vertical + L_form_horizontal\n", " \n", "beach = BeachWithSoreness(width=10, height=10)\n", "beach.animate(L_form, show=False)\n", "beach.night(show=False)\n", "beach.animate(L_form_vertical, iterations=11, show=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Tiredness\n", "\n", "> What happens next? The yellow patch is no longer spreading but is limited (by the stink). It has followed previous experience. Now the active octopuses have only a short attention span, so they start to get bored and tired. As they start to get bored, the stink they are giving out drops sharply. This means that other octopuses outside the first yellow patch who are receiving enough shocks to be awakened but have been discouraged by the stinck can now wake up and get active. The original group now fall asleep, so their yellow patch disappear. The yellow patch shifts to the new group of recently awakened octopuses. The tired octopuses will take a while to recover from their tiredness.\n", "\n", "> So now we get a shift in the yellow patch from one group to another. The patch, always limited in size by the stink, will continue to shift across the beach. If one group is well connected by long tentacles to a distant group, the patch may disappear in one area and appear in a distant area. The way one one area after another becomes yellow is a sequence or pattern. For a given set of conditions the pattern will be constant.\n", "\n", "To accomplish this, we add at each iteration a call to the method \"tired\" that sleeps the octopuses very tired. An octopus will fall asleep if he has been awake for more than a certain number of iterations. When an octopus fall a sleep has to sleep some time to recover, so we added the fields \"recovering\" and \"recovering_status\" that tracks how much they have to sleep to recover their energies and be activated again." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "class OctopusWithTiredness(OctopusWithSmell):\n", "\n", " tiredness_threshold = 10\n", " recovery_threshold = 10\n", "\n", " def __init__(self, id, environment):\n", " super().__init__(id, environment)\n", " self.tiredness = 0\n", " self.recovering = False\n", " self.recover_status = 0\n", "\n", " def tired(self):\n", " self.tiredness += 1\n", " if (self.tiredness >\n", " OctopusWithTiredness.tiredness_threshold):\n", " self.sleep(night=False)\n", "\n", " def recover(self):\n", " self.recover_status += 1\n", " if (self.recover_status >=\n", " OctopusWithTiredness.recovery_threshold):\n", " self.recovering = False\n", " self.recover_status = 0\n", " \n", " def shocked(self, power=0):\n", " if not self.recovering:\n", " super().shocked(power)\n", "\n", " def sleep(self, night=True):\n", " if self.awake: self.environment.smell -= 1\n", " self.awake = False\n", " self.excitement = 0\n", " self.tiredness = 0\n", " if night:\n", " self.recovering = False\n", " self.recover_status = 0\n", " else:\n", " self.recovering = True" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "from random import shuffle\n", "\n", "class BeachWithTiredness(BeachWithSoreness):\n", "\n", " def __init__(self, width, height, shocks_threshold=80, smell_threshold=50,\n", " tiredness_threshold=5, recovery_threshold=5):\n", " super().__init__(width, height, shocks_threshold, smell_threshold)\n", " OctopusWithTiredness.tiredness_threshold = tiredness_threshold\n", " OctopusWithTiredness.recovery_threshold = recovery_threshold\n", "\n", " def create_octopus(self, id):\n", " return OctopusWithTiredness(id=id, environment=self)\n", "\n", " def iteration(self):\n", " awake = [o for o in self.octopuses if o.awake]\n", " if len(awake) == 0:\n", " raise AllSleepingException\n", " shuffle(awake)\n", " for octopus in awake:\n", " octopus.tired()\n", " for tentacle in octopus.tentacles:\n", " tentacle.shock()\n", " recovering = [o for o in self.octopuses if o.recovering]\n", " for octopus in recovering:\n", " octopus.recover()\n", "\n", " def night(self, show=False):\n", " for octopus in self.octopuses:\n", " octopus.sleep()\n", " if show: self.print_night()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example we reause the \"L\" form utilized in the previous example but this time the yellow patch instead of recreating the entire pattern, will shift from one part of the \"L\" to another." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Start\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 1 - smell: 12\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 2 - smell: 12\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 3 - smell: 13\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 4 - smell: 14\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 5 - smell: 14\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 6 - smell: 14\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 7 - smell: 14\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 8 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 9 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 10 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 11 - smell: 16\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 12 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 13 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 14 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 15 - smell: 18\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 16 - smell: 8\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 17 - smell: 8\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 18 - smell: 8\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 19 - smell: 7\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n", "Iteration 20 - smell: 8\n", "\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™\n", "\n" ] } ], "source": [ "size = 10\n", "half = int(size / 2)\n", "\n", "L_form_horizontal = []\n", "L_form_vertical = []\n", "for x in range(0 + half // 2, size - half // 2):\n", " L_form_vertical.append((x, half // 2))\n", " L_form_vertical.append((x, half // 2 - 1))\n", "for y in range(0 + half // 2, size - half // 2):\n", " L_form_horizontal.append((half + half // 2, y))\n", " L_form_horizontal.append((half + half // 2 - 1, y))\n", "L_form = L_form_vertical + L_form_horizontal\n", "\n", "beach = BeachWithTiredness(width=10, height=10, tiredness_threshold=15)\n", "beach.animate(L_form, show=False)\n", "beach.night(show=False)\n", "beach.animate(L_form_vertical, iterations=20, show=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Listeners\n", "\n", "Let's make the beach more active and attach some listeners to some octopuses, so that when an octopus with a listener wakes up or falls asleep, that listener is fired and based on some conditions can carry out an action." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "class OctopusWithListeners(OctopusWithTiredness):\n", "\n", " def __init__(self, id, environment):\n", " super().__init__(id, environment)\n", " self.listeners = []\n", "\n", " def attach_listener(self, listener):\n", " self.listeners.append(listener)\n", "\n", " def fire_listeners(self):\n", " for listener in self.listeners:\n", " listener.fire(self)\n", "\n", " def shocked(self, power=0):\n", " was_awake = self.awake\n", " super().shocked(power)\n", " is_awake = self.awake\n", " if (not was_awake and is_awake):\n", " self.fire_listeners()\n", " \n", " def tired(self):\n", " was_awake = self.awake\n", " super().tired()\n", " is_awake = self.awake\n", " if (was_awake and not is_awake):\n", " self.fire_listeners()\n" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "class BeachWithListeners(BeachWithTiredness):\n", "\n", " def __init__(self, width, height, shocks_threshold=80,\n", " smell_threshold=50, tiredness_threshold=5, recovery_threshold=5):\n", " super().__init__(width, height, shocks_threshold, smell_threshold, tiredness_threshold, recovery_threshold)\n", " self.listeners = set([])\n", "\n", " def create_octopus(self, id):\n", " return OctopusWithListeners(id=id, environment=self)\n", "\n", " def attach_listener(self, where, listener):\n", " self.listeners.add(listener)\n", " for x, y in where:\n", " octopus = self.get(x, y)\n", " octopus.attach_listener(listener)\n", " \n", " def night(self, show=False):\n", " super().night()\n", " for listener in self.listeners:\n", " listener.reset()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With all this in place we can now teach our beach to count. To do this we first train the beach assigning a pattern to each number and connecting the patterns. Then we attach some listeners to print the numbers and eventually we animate the beach with only the pattern corresponding to the number one. You can see how this lead the beach to print all the numbers. If you change the parameters \"show\", you can see the patterns in the training stage and then how in the test stage the yellow patch traverse all the beach following the patterns." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n" ] } ], "source": [ "class NumberListener():\n", " \n", " def __init__(self, number):\n", " self.threshold = 16\n", " self.number = number\n", "\n", " def reset(self):\n", " self.threshold = 16\n", " \n", " def fire(self, octopus):\n", " if octopus.awake:\n", " self.threshold -= 1\n", " else:\n", " self.threshold += 1\n", " if (self.threshold == 0):\n", " print(self.number)\n", " self.threshold = 16\n", "\n", "from numbers_patterns import *\n", "\n", "beach = BeachWithListeners(\n", " width=28, height=28,\n", " tiredness_threshold=10,\n", " recovery_threshold=30,\n", " smell_threshold=16 + 16 + 12,\n", " shocks_threshold=60\n", ")\n", "\n", "beach.animate(one + after1 + two, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(two + after2 + three, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(three + after3 + four, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(four + after4 + five, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(five + after5 + six, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(six + after6 + seven, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(seven + after7 + eight, iterations=10, show=False)\n", "beach.night(show=False)\n", "beach.animate(eight + after8 + nine, iterations=10, show=False)\n", "beach.night(show=False)\n", "\n", "beach.attach_listener(one, NumberListener(1))\n", "beach.attach_listener(two, NumberListener(2))\n", "beach.attach_listener(three, NumberListener(3))\n", "beach.attach_listener(four, NumberListener(4))\n", "beach.attach_listener(five, NumberListener(5))\n", "beach.attach_listener(six, NumberListener(6))\n", "beach.attach_listener(seven, NumberListener(7))\n", "beach.attach_listener(eight, NumberListener(8))\n", "beach.attach_listener(nine, NumberListener(9))\n", "\n", "OctopusWithSmell.smell_threshold = 16 + 12\n", "beach.animate(one, iterations=210, show=False)\n", "beach.night()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conclusions\n", "\n", "> To summarize we can list the characteristicts of the system:\n", "1. Activity of an octopus can stimulate other octopuses into activity if they are connected by tentacles.\n", "1. The total size of the activated group is limited by negative feedback (the pungent smell).\n", "1. A tiring factor means that activity will shift from the stimulated group to the next ready group.\n", "1. Stimulation is on a 'threshold' basis and is non-linear.\n", "1. Any octopuses which are activated at the same time will have an increased connectedness.\n", "\n", "> As the result of this simple characteristicts the system is capable of the following general behaviour:\n", "1. Attention.\n", "1. Pattern recognition and reconstruction.\n", "1. Integration of different inputs.\n", "1. Creating sequence patterns bringing in past experience.\n", "\n", "The behaviour of this model depends very largerly on the parameters, like other algorithms in machine learning the process of tuning of hyperparameters is central. Are also possible a lot of different architectures. In this notebook every octopus is connected only to its neighbours but this is only one possible choice. We can connect all octopuses to each other and the behaviour would be very different. Or we can do multiple beaches and connect them like layers in neural networks. And so on.\n", "\n", "In the [next notebook](https://nbviewer.jupyter.org/github/marconunnari/octopusal_networks/blob/master/Mnist.ipynb) we we will use octopusal networks to recognize the handwritten digits of the MNIST database" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Marco Nunnari
May 2018

" ] } ], "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.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }