diff --git a/agents.ipynb b/agents.ipynb
index ed6920bd0..65878bbab 100644
--- a/agents.ipynb
+++ b/agents.ipynb
@@ -4,6 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
+ "\n",
"# AGENT #\n",
"\n",
"An agent, as defined in 2.1 is anything that can perceive its environment through sensors, and act upon that environment through actuators based on its agent program. This can be a dog, robot, or even you. As long as you can perceive the environment and act on it, you are an agent. This notebook will explain how to implement a simple agent, create an environment, and create a program that helps the agent act on the environment based on its percepts.\n",
@@ -17,6 +18,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
+ "collapsed": true,
"scrolled": true
},
"outputs": [],
@@ -80,7 +82,9 @@
{
"cell_type": "code",
"execution_count": 3,
- "metadata": {},
+ "metadata": {
+ "collapsed": true
+ },
"outputs": [],
"source": [
"class Food(Thing):\n",
@@ -151,7 +155,9 @@
{
"cell_type": "code",
"execution_count": 4,
- "metadata": {},
+ "metadata": {
+ "collapsed": true
+ },
"outputs": [],
"source": [
"class BlindDog(Agent):\n",
@@ -163,14 +169,12 @@
" def eat(self, thing):\n",
" '''returns True upon success or False otherwise'''\n",
" if isinstance(thing, Food):\n",
- " #print(\"Dog: Ate food at {}.\".format(self.location))\n",
" return True\n",
" return False\n",
" \n",
" def drink(self, thing):\n",
" ''' returns True upon success or False otherwise'''\n",
" if isinstance(thing, Water):\n",
- " #print(\"Dog: Drank water at {}.\".format(self.location))\n",
" return True\n",
" return False\n",
" \n",
@@ -456,7 +460,9 @@
{
"cell_type": "code",
"execution_count": 10,
- "metadata": {},
+ "metadata": {
+ "collapsed": true
+ },
"outputs": [],
"source": [
"from random import choice\n",
@@ -487,14 +493,12 @@
" def eat(self, thing):\n",
" '''returns True upon success or False otherwise'''\n",
" if isinstance(thing, Food):\n",
- " #print(\"Dog: Ate food at {}.\".format(self.location))\n",
" return True\n",
" return False\n",
" \n",
" def drink(self, thing):\n",
" ''' returns True upon success or False otherwise'''\n",
" if isinstance(thing, Water):\n",
- " #print(\"Dog: Drank water at {}.\".format(self.location))\n",
" return True\n",
" return False\n",
" \n",
@@ -546,11 +550,9 @@
" if action == 'turnright':\n",
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
" agent.turn(Direction.R)\n",
- " #print('now facing {}'.format(agent.direction.direction))\n",
" elif action == 'turnleft':\n",
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
" agent.turn(Direction.L)\n",
- " #print('now facing {}'.format(agent.direction.direction))\n",
" elif action == 'moveforward':\n",
" loc = copy.deepcopy(agent.location) # find out the target location\n",
" if agent.direction.direction == Direction.R:\n",
@@ -561,7 +563,6 @@
" loc[1] += 1\n",
" elif agent.direction.direction == Direction.U:\n",
" loc[1] -= 1\n",
- " #print('{} at {} facing {}'.format(agent, loc, agent.direction.direction))\n",
" if self.is_inbounds(loc):# move only if the target is a valid location\n",
" print('{} decided to move {}wards at location: {}'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" agent.moveforward()\n",
@@ -664,11 +665,9 @@
" if action == 'turnright':\n",
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
" agent.turn(Direction.R)\n",
- " #print('now facing {}'.format(agent.direction.direction))\n",
" elif action == 'turnleft':\n",
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
" agent.turn(Direction.L)\n",
- " #print('now facing {}'.format(agent.direction.direction))\n",
" elif action == 'moveforward':\n",
" loc = copy.deepcopy(agent.location) # find out the target location\n",
" if agent.direction.direction == Direction.R:\n",
@@ -679,7 +678,6 @@
" loc[1] += 1\n",
" elif agent.direction.direction == Direction.U:\n",
" loc[1] -= 1\n",
- " #print('{} at {} facing {}'.format(agent, loc, agent.direction.direction))\n",
" if self.is_inbounds(loc):# move only if the target is a valid location\n",
" print('{} decided to move {}wards at location: {}'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" agent.moveforward()\n",
@@ -1157,7 +1155,9 @@
{
"cell_type": "code",
"execution_count": 4,
- "metadata": {},
+ "metadata": {
+ "collapsed": true
+ },
"outputs": [],
"source": [
"from ipythonblocks import BlockGrid\n",
@@ -1252,7 +1252,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.5.4rc1"
+ "version": "3.6.4"
}
},
"nbformat": 4,