我尝试为minmax算法创建一个实现,需要创建一个包含所有可能移动的树。在Python3.7中使用anytree模块创建一个树,但当尝试在第一个树级别迭代并构建下一个级别时,会收到一个错误。在
Traceback (most recent call last):
Hello from the pygame community. https://www.pygame.org/contribute.html
File "C:/Users/User/PycharmProjects/Tema5AI/Main.py", line 217, in <module>
min_max_algorithm(game)
File "C:/Users/User/PycharmProjects/Tema5AI/Main.py", line 209, in min_max_algorithm
new_node = Node((game, i, 0), parent=(pre, fill, node))
File "C:\Users\User\PycharmProjects\Tema5AI\venv\lib\site-packages\anytree\node\node.py", line 66, in __init__
self.parent = parent
File "C:\Users\User\PycharmProjects\Tema5AI\venv\lib\site-packages\anytree\node\nodemixin.py", line 126, in parent
msg = "Parent node %r is not of type 'NodeMixin'." % (value)
TypeError: not all arguments converted during string formatting
我的构建树代码是:
^{pr2}$更确切的问题是: 如何通过遍历当前树向节点添加子节点?在
以下问题对我没有帮助: How to specify childrens in anytree and print a tree
Read data from a file and create a tree using anytree in python
How can I implement a tree in Python? Are there any built in data structures in Python like in Java?
目前没有回答
相关问题 更多 >
编程相关推荐