我的单子有问题。 显然,我错过了一些东西。:页
有人能告诉我这里出了什么问题,怎么解决吗? 这里是我的故障:
On = [0, 0, [[0, 0],[0,1]]]
tempList = []
tempList.append(On[2])
print(tempList)
tempList.append([On[0],On[1]+1])
print(tempList)
以防万一这很重要,这是我的人工智能寻路。你知道吗
第一次打印:
[[[[0, 0]], [0, 1]]]
我想要:
[[0,0],[0,1]]
第二次印刷:
[[[[0, 0]], [0, 1]], [0, 2]]
我想要:
[[0,0],[0,1],[0,2]]
On[2]
应该追踪我过去的行动。
我试图让我过去的动作(On[2]
)与现在的动作结合起来。你知道吗
我希望tempList
是这样的:
[[0,1],[0,2],[0,3]]
但我得到的却是:
[[[0,1],[0,2]],[0,3]]
On
以这种格式存储(或者应该是):[CurrentX,CurrentY,[[Step1X,Step1Y],[Step2X,Step2Y]]
等
如果你需要更多的信息,告诉我你需要什么。你知道吗
编辑:问题在于On
和tempList
。你知道吗
如果你们需要的话,我可以发布所有的代码,这样你们就可以运行它了。:/
…收益率。。。你知道吗
……这是所说的理想结果。你知道吗
这条线:
将列表附加到列表。你想要这个:
如果你的
Bottom
显示为。。。你知道吗…当你想要的时候。。。你知道吗
…那么问题可能根本不在于
tempList
及其构造,而在于append
调用,它将其参数作为单个元素附加。你知道吗也就是说:
…结果是。。。你知道吗
…而不是。。。你知道吗
…我想这是你真正想要的。你知道吗
对于该结果,请使用
或者
相关问题 更多 >
编程相关推荐