Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo for issue #664 #665

Merged
merged 1 commit into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 25 additions & 49 deletions agents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
Expand All @@ -44,9 +43,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -83,9 +80,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Food(Thing):\n",
Expand Down Expand Up @@ -156,9 +151,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class BlindDog(Agent):\n",
Expand Down Expand Up @@ -195,15 +188,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets now run our simulation by creating a park with some food, water, and our dog."
"Let's now run our simulation by creating a park with some food, water, and our dog."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -235,15 +226,13 @@
"source": [
"Notice that the dog moved from location 1 to 4, over 4 steps, and ate food at location 5 in the 5th step.\n",
"\n",
"Lets continue this simulation for 5 more steps."
"Let's continue this simulation for 5 more steps."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -263,15 +252,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Perfect! Note how the simulation stopped after the dog drank the water - exhausting all the food and water ends our simulation, as we had defined before. Lets add some more water and see if our dog can reach it."
"Perfect! Note how the simulation stopped after the dog drank the water - exhausting all the food and water ends our simulation, as we had defined before. Let's add some more water and see if our dog can reach it."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -298,7 +285,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 try a 2-Dimentional environment now 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",
Expand Down Expand Up @@ -349,8 +336,8 @@
" return dead_agents or no_edibles\n",
"\n",
"class BlindDog(Agent):\n",
" location = [0,1]# change location to a 2d value\n",
" direction = Direction(\"down\")# variable to store the direction our dog is facing\n",
" location = [0,1] # change location to a 2d value\n",
" direction = Direction(\"down\") # variable to store the direction our dog is facing\n",
" \n",
" def movedown(self):\n",
" self.location[1] += 1\n",
Expand Down Expand Up @@ -381,15 +368,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now lets test this new park with our same dog, food and water"
"Now let's test this new park with our same dog, food and water"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -436,7 +421,7 @@
"\n",
"# PROGRAM - EnergeticBlindDog #\n",
"\n",
"Lets 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",
"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",
"<table>\n",
" <tr>\n",
Expand Down Expand Up @@ -471,14 +456,12 @@
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"from random import choice\n",
"\n",
"turn = False# global variable to remember to turn if our dog hits the boundary\n",
"turn = False # global variable to remember to turn if our dog hits the boundary\n",
"class EnergeticBlindDog(Agent):\n",
" location = [0,1]\n",
" direction = Direction(\"down\")\n",
Expand Down Expand Up @@ -611,9 +594,7 @@
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -653,15 +634,15 @@
"park.add_thing(water, [2,1])\n",
"morewater = Water()\n",
"park.add_thing(morewater, [0,2])\n",
"print('dog started at [0,0], facing down. Lets see if he found any food or water!')\n",
"print(\"dog started at [0,0], facing down. Let's see if he found any food or water!\")\n",
"park.run(20)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is good, but it still lacks graphics. What if we wanted to visualize our park as it changed? To do that, all we have to do is make our park a subclass of <b>GraphicEnvironment</b> instead of <b>XYEnvironment</b>. Lets see how this looks."
"This is good, but it still lacks graphics. What if we wanted to visualize our park as it changed? To do that, all we have to do is make our park a subclass of <b>GraphicEnvironment</b> instead of <b>XYEnvironment</b>. Let's see how this looks."
]
},
{
Expand Down Expand Up @@ -739,7 +720,6 @@
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
Expand Down Expand Up @@ -1155,7 +1135,7 @@
"morefood = Food()\n",
"park.add_thing(morewater, [2,4])\n",
"park.add_thing(morefood, [4,3])\n",
"print('dog started at [0,0], facing down. Lets see if he found any food or water!')\n",
"print(\"dog started at [0,0], facing down. Let's see if he found any food or water!\")\n",
"park.run(20)"
]
},
Expand All @@ -1177,9 +1157,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"from ipythonblocks import BlockGrid\n",
Expand Down Expand Up @@ -1221,9 +1199,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -1276,9 +1252,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.5.4rc1"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
2 changes: 1 addition & 1 deletion agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def some_things_at(self, location, tclass=Thing):
def add_thing(self, thing, location=None):
"""Add a thing to the environment, setting its location. For
convenience, if thing is an agent program we make a new agent
for it. (Shouldn't need to override this."""
for it. (Shouldn't need to override this.)"""
if not isinstance(thing, Thing):
thing = Agent(thing)
if thing in self.things:
Expand Down