我在下面有以下代码
def runRobot(self):
allActions = ('North','South','East','West','Suck')
bestActionUtility = 0
toDo = 'Suck'
for a in allActions:
actionUtility = self.getActionUtility(a)
if(actionUtility > bestActionUtility):
toDo = a
bestActionUtility = actionUtility
# Do lots of robot stuff here!
self.action = random.choice(['North','South','East','West','Suck'])
def getActionUtility(action):
return 0
当调用 runRobot 时,我不断收到错误消息,告诉我我提供getActionUtility(action)
了两个参数。我不明白这是怎么可能的。我认为我的 for 循环会剥离allActions
列表的每个元素(数组?或者是仅 python 列表)并调用getActionUtility
每个操作。我错了吗?
如果需要更多代码,请告诉我,但我认为这应该涵盖整个问题。