此代碼是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