| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,7 @@ | |||
| 38 | 38 | from utils import * | |
| 39 | 39 | import random | |
| 40 | 40 | import copy | |
| 41 | + import collections | ||
| 41 | 42 | ||
| 42 | 43 | #______________________________________________________________________________ | |
| 43 | 44 | ||
@@ -80,8 +81,8 @@ def __init__(self, program=None): | |||
| 80 | 81 | self.bump = False | |
| 81 | 82 | if program is None: | |
| 82 | 83 | def program(percept): | |
| 83 | - return input('Percept={}; action? ' .format(percept)) | ||
| 84 | - assert callable(program) | ||
| 84 | + return eval(input('Percept={}; action? ' .format(percept))) | ||
| 85 | + assert isinstance(program, collections.Callable) | ||
| 85 | 86 | self.program = program | |
| 86 | 87 | ||
| 87 | 88 | def can_grab(self, thing): | |
@@ -95,7 +96,7 @@ def TraceAgent(agent): | |||
| 95 | 96 | old_program = agent.program | |
| 96 | 97 | def new_program(percept): | |
| 97 | 98 | action = old_program(percept) | |
| 98 | - print('{} perceives {} and does {}'.format(agent, percept, action)) | ||
| 99 | + print(('{} perceives {} and does {}'.format(agent, percept, action))) | ||
| 99 | 100 | return action | |
| 100 | 101 | agent.program = new_program | |
| 101 | 102 | return agent | |
@@ -280,9 +281,9 @@ def delete_thing(self, thing): | |||
| 280 | 281 | except(ValueError, e): | |
| 281 | 282 | print(e) | |
| 282 | 283 | print(" in Environment delete_thing") | |
| 283 | - print(" Thing to be removed: {} at {}" .format(thing, thing.location)) | ||
| 284 | - print(" from list: {}" .format([(thing, thing.location) | ||
| 285 | - for thing in self.things])) | ||
| 284 | + print((" Thing to be removed: {} at {}" .format(thing, thing.location))) | ||
| 285 | + print((" from list: {}" .format([(thing, thing.location) | ||
| 286 | + for thing in self.things]))) | ||
| 286 | 287 | if thing in self.agents: | |
| 287 | 288 | self.agents.remove(thing) | |
| 288 | 289 | ||
@@ -504,7 +505,7 @@ def score(env): | |||
| 504 | 505 | env.add_thing(agent) | |
| 505 | 506 | env.run(steps) | |
| 506 | 507 | return agent.performance | |
| 507 | - return mean(map(score, envs)) | ||
| 508 | + return mean(list(map(score, envs))) | ||
| 508 | 509 | ||
| 509 | 510 | #_________________________________________________________________________ | |
| 510 | 511 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments