Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ba1aed

Browse files
seenivasanseeninorvig
authored andcommitted
Remove commented codes in agents.ipynb (aimacode#805)
1 parent d4877cd commit 1ba1aed

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

agents.ipynb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7+
"\n",
78
"# AGENT #\n",
89
"\n",
910
"An agent, as defined in 2.1 is anything that can perceive its <b>environment</b> through sensors, and act upon that environment through actuators based on its <b>agent program</b>. 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 @@
1718
"cell_type": "code",
1819
"execution_count": 1,
1920
"metadata": {
21+
"collapsed": true,
2022
"scrolled": true
2123
},
2224
"outputs": [],
@@ -80,7 +82,9 @@
8082
{
8183
"cell_type": "code",
8284
"execution_count": 3,
83-
"metadata": {},
85+
"metadata": {
86+
"collapsed": true
87+
},
8488
"outputs": [],
8589
"source": [
8690
"class Food(Thing):\n",
@@ -151,7 +155,9 @@
151155
{
152156
"cell_type": "code",
153157
"execution_count": 4,
154-
"metadata": {},
158+
"metadata": {
159+
"collapsed": true
160+
},
155161
"outputs": [],
156162
"source": [
157163
"class BlindDog(Agent):\n",
@@ -163,14 +169,12 @@
163169
" def eat(self, thing):\n",
164170
" '''returns True upon success or False otherwise'''\n",
165171
" if isinstance(thing, Food):\n",
166-
" #print(\"Dog: Ate food at {}.\".format(self.location))\n",
167172
" return True\n",
168173
" return False\n",
169174
" \n",
170175
" def drink(self, thing):\n",
171176
" ''' returns True upon success or False otherwise'''\n",
172177
" if isinstance(thing, Water):\n",
173-
" #print(\"Dog: Drank water at {}.\".format(self.location))\n",
174178
" return True\n",
175179
" return False\n",
176180
" \n",
@@ -456,7 +460,9 @@
456460
{
457461
"cell_type": "code",
458462
"execution_count": 10,
459-
"metadata": {},
463+
"metadata": {
464+
"collapsed": true
465+
},
460466
"outputs": [],
461467
"source": [
462468
"from random import choice\n",
@@ -487,14 +493,12 @@
487493
" def eat(self, thing):\n",
488494
" '''returns True upon success or False otherwise'''\n",
489495
" if isinstance(thing, Food):\n",
490-
" #print(\"Dog: Ate food at {}.\".format(self.location))\n",
491496
" return True\n",
492497
" return False\n",
493498
" \n",
494499
" def drink(self, thing):\n",
495500
" ''' returns True upon success or False otherwise'''\n",
496501
" if isinstance(thing, Water):\n",
497-
" #print(\"Dog: Drank water at {}.\".format(self.location))\n",
498502
" return True\n",
499503
" return False\n",
500504
" \n",
@@ -546,11 +550,9 @@
546550
" if action == 'turnright':\n",
547551
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
548552
" agent.turn(Direction.R)\n",
549-
" #print('now facing {}'.format(agent.direction.direction))\n",
550553
" elif action == 'turnleft':\n",
551554
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
552555
" agent.turn(Direction.L)\n",
553-
" #print('now facing {}'.format(agent.direction.direction))\n",
554556
" elif action == 'moveforward':\n",
555557
" loc = copy.deepcopy(agent.location) # find out the target location\n",
556558
" if agent.direction.direction == Direction.R:\n",
@@ -561,7 +563,6 @@
561563
" loc[1] += 1\n",
562564
" elif agent.direction.direction == Direction.U:\n",
563565
" loc[1] -= 1\n",
564-
" #print('{} at {} facing {}'.format(agent, loc, agent.direction.direction))\n",
565566
" if self.is_inbounds(loc):# move only if the target is a valid location\n",
566567
" print('{} decided to move {}wards at location: {}'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
567568
" agent.moveforward()\n",
@@ -664,11 +665,9 @@
664665
" if action == 'turnright':\n",
665666
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
666667
" agent.turn(Direction.R)\n",
667-
" #print('now facing {}'.format(agent.direction.direction))\n",
668668
" elif action == 'turnleft':\n",
669669
" print('{} decided to {} at location: {}'.format(str(agent)[1:-1], action, agent.location))\n",
670670
" agent.turn(Direction.L)\n",
671-
" #print('now facing {}'.format(agent.direction.direction))\n",
672671
" elif action == 'moveforward':\n",
673672
" loc = copy.deepcopy(agent.location) # find out the target location\n",
674673
" if agent.direction.direction == Direction.R:\n",
@@ -679,7 +678,6 @@
679678
" loc[1] += 1\n",
680679
" elif agent.direction.direction == Direction.U:\n",
681680
" loc[1] -= 1\n",
682-
" #print('{} at {} facing {}'.format(agent, loc, agent.direction.direction))\n",
683681
" if self.is_inbounds(loc):# move only if the target is a valid location\n",
684682
" print('{} decided to move {}wards at location: {}'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
685683
" agent.moveforward()\n",
@@ -1157,7 +1155,9 @@
11571155
{
11581156
"cell_type": "code",
11591157
"execution_count": 4,
1160-
"metadata": {},
1158+
"metadata": {
1159+
"collapsed": true
1160+
},
11611161
"outputs": [],
11621162
"source": [
11631163
"from ipythonblocks import BlockGrid\n",
@@ -1252,7 +1252,7 @@
12521252
"name": "python",
12531253
"nbconvert_exporter": "python",
12541254
"pygments_lexer": "ipython3",
1255-
"version": "3.5.4rc1"
1255+
"version": "3.6.4"
12561256
}
12571257
},
12581258
"nbformat": 4,

0 commit comments

Comments
 (0)