0
我建立一個三維陣列self.QL={}
和「擦除」的陣列0的:KeyError異常的蟒蛇......
for loop0 in range(50):
for loop1 in range(50):
for loop2 in range(self.actions):
self.QL[loop0, loop1, loop2] = 0
但是當我運行該程序,並嘗試從陣列得到的值,它牛逼hrows的錯誤:
File "Bots/QL.py", line 135, in _chooseaction
self.vQ = self.QL[state[0],state[1],a]
KeyError: (0, 63, 0)
管線135,我有:
def _chooseaction(self, state):
self.vQ = 0
self.action = 0
self.temp = -1000
for a in range(self.actions):
self.vQ = self.QL[state[0],state[1],a]
if self.vQ > self.temp:
self.temp=self.vQ
self.action=a
return self.action
我做了什麼WRO NG?