diff --git a/agents.ipynb b/agents.ipynb
index 026dd895e..6bfb34d98 100644
--- a/agents.ipynb
+++ b/agents.ipynb
@@ -17,11 +17,16 @@
{
"cell_type": "code",
"execution_count": 1,
- "metadata": {
- "collapsed": true,
- "scrolled": true
- },
- "outputs": [],
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Can't find a valid program for BlindDog, falling back to default.\n"
+ ]
+ }
+ ],
"source": [
"from agents import *\n",
"\n",
@@ -39,7 +44,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "What we have just done is create a dog who can only feel what's in his surrounding environment (since he's blind), and can eat or drink. Let's see if he's alive..."
+ "What we have just done is create a dog who can only feel what's in his location (since he's blind), and can eat or drink. Let's see if he's alive..."
]
},
{
@@ -82,9 +87,7 @@
{
"cell_type": "code",
"execution_count": 3,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"class Food(Thing):\n",
@@ -95,7 +98,7 @@
"\n",
"class Park(Environment):\n",
" def percept(self, agent):\n",
- " '''prints & return a list of things that are in our agent's surrounding environemnt'''\n",
+ " '''prints & return a list of things that are in our agent's location'''\n",
" things = self.list_things_at(agent.location)\n",
" return things\n",
" \n",
@@ -134,7 +137,7 @@
},
"source": [
"# PROGRAM - BlindDog #\n",
- "Now that we have a Park Class, we need to implement a program module for our dog. A program controls how the dog acts in it's environment; it will be very simple, and it's functionality is illustrated in the table below.\n",
+ "Now that we have a Park Class, we need to implement a program module for our dog. A program controls how the dog acts upon it's environment. Our program will be very simple, and is shown in the table below.\n",
"
\n",
" \n",
" Percept: | \n",
@@ -155,9 +158,7 @@
{
"cell_type": "code",
"execution_count": 4,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"class BlindDog(Agent):\n",
@@ -167,13 +168,13 @@
" self.location += 1\n",
" \n",
" def eat(self, thing):\n",
- " '''returns True for success and False otherwise'''\n",
+ " '''returns True upon success or False otherwise'''\n",
" if isinstance(thing, Food):\n",
" return True\n",
" return False\n",
" \n",
" def drink(self, thing):\n",
- " ''' returns True for success and False otherwise'''\n",
+ " ''' returns True upon success or False otherwise'''\n",
" if isinstance(thing, Water):\n",
" return True\n",
" return False\n",
@@ -289,7 +290,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "This is how to implement an agent, its program, and environment. However, this was a very simple case. Lets now try a 2-Dimensional environment with multiple agents.\n",
+ "This is how to implement an agent, its program, and environment. However, this was a very simple case. Let's try a 2-Dimentional environment now with multiple agents.\n",
"\n",
"\n",
"# 2D Environment #\n",
@@ -301,9 +302,7 @@
{
"cell_type": "code",
"execution_count": 8,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"class Park2D(XYEnvironment):\n",
@@ -347,13 +346,13 @@
" self.location[1] += 1\n",
" \n",
" def eat(self, thing):\n",
- " '''returns True for success and False otherwise'''\n",
+ " '''returns True upon success or False otherwise'''\n",
" if isinstance(thing, Food):\n",
" return True\n",
" return False\n",
" \n",
" def drink(self, thing):\n",
- " ''' returns True for success and False otherwise'''\n",
+ " ''' returns True upon success or False otherwise'''\n",
" if isinstance(thing, Water):\n",
" return True\n",
" return False\n",
@@ -421,11 +420,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "This works, but our blind dog doesn't make any use of the 2 dimensional space available to him. Lets make our dog more energetic so that instead of always moving down, he turns and moves forward as well. To be able to handle this extra motion, we'll need to make appropriate changes to our environment.\n",
+ "This works, but our blind dog doesn't make any use of the 2 dimensional space available to him. Let's make our dog more energetic so that he turns and moves forward, instead of always moving down. We'll also need to make appropriate changes to our environment to be able to handle this extra motion.\n",
"\n",
"# PROGRAM - EnergeticBlindDog #\n",
"\n",
- "Let's make our dog turn or move forward at random - except when he's at the edge of our park - in which case we make him change his direction explicitly by turning to avoid trying to leave the park. Our dog is blind, however, so he wouldn't know which way to turn - he'd just have to try arbitrarily.\n",
+ "Let's make our dog turn or move forwards at random - except when he's at the edge of our park - in which case we make him change his direction explicitly by turning to avoid trying to leave the park. Our dog is blind, however, so he wouldn't know which way to turn - he'd just have to try arbitrarily.\n",
"\n",
"\n",
" \n",
@@ -460,9 +459,7 @@
{
"cell_type": "code",
"execution_count": 10,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"from random import choice\n",
@@ -491,13 +488,13 @@
" self.direction = self.direction + d\n",
" \n",
" def eat(self, thing):\n",
- " '''returns True for success and False otherwise'''\n",
+ " '''returns True upon success or False otherwise'''\n",
" if isinstance(thing, Food):\n",
" return True\n",
" return False\n",
" \n",
" def drink(self, thing):\n",
- " ''' returns True f success and False otherwise'''\n",
+ " ''' returns True upon success or False otherwise'''\n",
" if isinstance(thing, Water):\n",
" return True\n",
" return False\n",
@@ -534,9 +531,7 @@
{
"cell_type": "code",
"execution_count": 11,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"class Park2D(XYEnvironment):\n",
@@ -601,26 +596,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "dog started at [0,0], facing down. Lets see if he found any food or water!\n",
- "EnergeticBlindDog decided to move downwards at location: [0, 0]\n",
- "EnergeticBlindDog decided to move downwards at location: [0, 1]\n",
- "EnergeticBlindDog drank Water at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnright at location: [0, 2]\n",
- "EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n",
- "EnergeticBlindDog decided to turnright at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnright at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
- "EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n",
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnright at location: [0, 2]\n",
- "EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n",
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
- "EnergeticBlindDog decided to move downwards at location: [0, 2], but couldn't\n",
- "EnergeticBlindDog decided to turnright at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
- "EnergeticBlindDog decided to move rightwards at location: [0, 2]\n",
+ "dog started at [0,0], facing down. Let's see if he found any food or water!\n",
+ "EnergeticBlindDog decided to turnright at location: [0, 0]\n",
+ "EnergeticBlindDog decided to move leftwards at location: [0, 0], but couldn't\n",
+ "EnergeticBlindDog decided to turnright at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnright at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [0, 0]\n",
+ "EnergeticBlindDog decided to move upwards at location: [0, 0], but couldn't\n",
+ "EnergeticBlindDog decided to turnleft at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnright at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnright at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [0, 0]\n",
+ "EnergeticBlindDog decided to move rightwards at location: [0, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [1, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [1, 0]\n",
+ "EnergeticBlindDog decided to turnleft at location: [1, 0]\n",
+ "EnergeticBlindDog decided to move downwards at location: [1, 0]\n",
+ "EnergeticBlindDog decided to move downwards at location: [1, 1]\n",
"EnergeticBlindDog ate Food at location: [1, 2]\n"
]
}
@@ -649,9 +644,7 @@
{
"cell_type": "code",
"execution_count": 13,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"class GraphicPark(GraphicEnvironment):\n",
@@ -716,7 +709,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 14,
"metadata": {
"scrolled": true
},
@@ -725,13 +718,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "dog started at [0,0], facing down. Lets see if he found any food or water!\n"
+ "dog started at [0,0], facing down. Let's see if he found any food or water!\n"
]
},
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -747,10 +740,20 @@
"EnergeticBlindDog decided to move downwards at location: [0, 0]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -766,10 +769,20 @@
"EnergeticBlindDog drank Water at location: [0, 1]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -782,13 +795,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnleft at location: [0, 1]\n"
+ "EnergeticBlindDog decided to move downwards at location: [0, 1]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -801,13 +824,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnright at location: [0, 1]\n"
+ "EnergeticBlindDog decided to move downwards at location: [0, 2]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -820,13 +853,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move downwards at location: [0, 1]\n"
+ "EnergeticBlindDog decided to move downwards at location: [0, 3]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -839,13 +882,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnleft at location: [0, 2]\n"
+ "EnergeticBlindDog decided to turnleft at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -858,13 +911,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move rightwards at location: [0, 2]\n"
+ "EnergeticBlindDog decided to turnright at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -877,13 +940,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog ate Food at location: [1, 2]\n"
+ "EnergeticBlindDog decided to move downwards at location: [0, 4], but couldn't\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -896,13 +969,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnleft at location: [1, 2]\n"
+ "EnergeticBlindDog decided to turnright at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -915,13 +998,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnleft at location: [1, 2]\n"
+ "EnergeticBlindDog decided to move leftwards at location: [0, 4], but couldn't\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -934,13 +1027,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnleft at location: [1, 2]\n"
+ "EnergeticBlindDog decided to turnright at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -953,13 +1056,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move downwards at location: [1, 2]\n"
+ "EnergeticBlindDog decided to turnleft at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -972,13 +1085,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnright at location: [1, 3]\n"
+ "EnergeticBlindDog decided to turnright at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -991,13 +1114,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move leftwards at location: [1, 3]\n"
+ "EnergeticBlindDog decided to move upwards at location: [0, 4]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1010,13 +1143,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move leftwards at location: [0, 3], but couldn't\n"
+ "EnergeticBlindDog decided to move upwards at location: [0, 3]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1029,13 +1172,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnleft at location: [0, 3]\n"
+ "EnergeticBlindDog decided to turnleft at location: [0, 2]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1048,13 +1201,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnright at location: [0, 3]\n"
+ "EnergeticBlindDog decided to turnleft at location: [0, 2]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1067,13 +1230,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move leftwards at location: [0, 3], but couldn't\n"
+ "EnergeticBlindDog decided to turnright at location: [0, 2]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1086,13 +1259,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to turnright at location: [0, 3]\n"
+ "EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1105,13 +1288,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "EnergeticBlindDog decided to move upwards at location: [0, 3]\n"
+ "EnergeticBlindDog decided to turnright at location: [0, 2]\n"
]
},
+ {
+ "data": {
+ "text/html": [],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1154,10 +1347,8 @@
},
{
"cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 15,
+ "metadata": {},
"outputs": [],
"source": [
"from ipythonblocks import BlockGrid\n",
@@ -1198,13 +1389,13 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1217,7 +1408,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "[[], [], [], [], [, None]]\n",
+ "[[], [None], [], [None], [None]]\n",
"Forward\n"
]
}
@@ -1229,9 +1420,7 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": []
}
@@ -1252,7 +1441,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.1"
+ "version": "3.6.5"
}
},
"nbformat": 4,
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy