def randomise_Chests_Bandits (sign,xSize,ySize,grid,pX,pY) :
import random
x = random.randint(0,xSize-1) #get a random x coordinate
y = random.randint(0,ySize-1) #get a random y coordinate
if (x == pX and y == pY) or (grid[x][y] != " "):
grid = randomise_Chests_Bandits(sign,xSize,ySize,grid,pX,pY)
else:
grid[x][y] = sign
return grid
它由以下人员调用:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^{pr2}$为什么它总是说TypeError:“generator”对象在调用预定义进程时不可下标?在
Traceback (most recent call last):
File "E:\AQA Game Final Coding With Help.py", line 271, in <module>
Overall_Menu ()
File "E:\AQA Game Final Coding With Help.py", line 264, in Overall_Menu
grid = add_Chests_Bandits(grid,chestCount,banditCount,xSize,ySize,pX,pY)
File "E:\AQA Game Final Coding With Help.py", line 223, inadd_Chests_Bandits
grid = randomise_Chests_Bandits ('0',xSize,ySize,grid,pX,pY)
File "E:\AQA Game Final Coding With Help.py", line 215, in randomise_Chests_Bandits
if (x == pX and y == pY) or (grid[x][y] != " "):
TypeError: 'generator' object is not subscriptable
以下是我对你问题的解释:
可能你忘了初始化数组,这是输出:
^{pr2}$相关问题 更多 >
编程相关推荐