此代码是pacman编码项目的一部分,它用于初始化幻影行为。任何人都可以解释它做了什么?Python pacman代码:需要说明
class GhostAgent(Agent):
def __init__(self, index):
self.index = index
def getAction(self, state):
dist = self.getDistribution(state)
if len(dist) == 0:
return Directions.STOP
else:
return util.chooseFromDistribution(dist)
def getDistribution(self, state):
"Returns a Counter encoding a distribution over actions from the provided state."
util.raiseNotDefined()
然后代码为不同的行为概括了不同的类。 谢谢!
您需要阅读[如何创建最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 –
你刚才说了它的作用:它初始化鬼的行为。具体来说,你不了解这些代码吗? –
方法名称和注释似乎做了很好的陈述他们在做什么 – Sayse