我有一种遗传算法,可以在自上而下的游戏空间中模拟“鱼”。创建模拟时,将删除一半创建的内容,其余一半将其后代(从一对父母那里深深复制)填充到空人口中。
该系统在集成到pygame中之前运行良好。但是现在我收到一个错误“ pygame.error:显示曲面退出”。
创建“代理”时,也会生成其所有特征,包括其精灵。然后,我将精灵详细信息存储在一个元组中,以便在需要呈现代理时进行检索。
打印的元组如下所示:
[<Surface(1152x48x32 SW)>, 48, 48, 24, 20]
#[loaded sprite, width,height,frames, current_frame]
我已安排在第二个模拟开始时打印我的12个代理的精灵详细信息,得到的结果如下:
[<Surface(1152x48x32 SW)>, 48, 48, 24, 20]
[<Surface(1152x48x32 SW)>, 48, 48, 24, 21]
[<Surface(Dead Display)>, 48, 48, 24, 20]
[<Surface(Dead Display)>, 48, 48, 24, 21]
[<Surface(1152x48x32 SW)>, 48, 48, 24, 19]
[<Surface(1152x48x32 SW)>, 48, 48, 24, 5]
[<Surface(Dead Display)>, 48, 48, 24, 19]
[<Surface(Dead Display)>, 48, 48, 24, 5]
[<Surface(1152x48x32 SW)>, 48, 48, 24, 7]
[<Surface(1152x48x32 SW)>, 48, 48, 24, 0]
[<Surface(Dead Display)>, 48, 48, 24, 7]
[<Surface(Dead Display)>, 48, 48, 24, 0]
子画面细节块是顶部的两个父级,然后是下面的两个后代。
完整错误如下:
Traceback (most recent call last):
File "/home/christian/Desktop/Simulation Fish/main.py", line 32, in <module>
game_loop()
File "/home/christian/Desktop/Simulation Fish/main.py", line 20, in game_loop
fitnessLedger = test.run(agentLedger,foodLedger)
File "/home/christian/Desktop/Simulation Fish/_bin/test.py", line 11, in run
render(agentLedger,foodLedger)
File "/home/christian/Desktop/Simulation Fish/_bin/test.py", line 25, in render
gameDisplay.blit(i.sprite[0],(i.x-(i.sprite[1]/2),i.y-(i.sprite[2]/2)),(i.sprite[4]*i.sprite[1],0,i.sprite[1],i.sprite[2]))
pygame.error: display Surface quit
有人可以解释为什么未完全复制精灵详细信息吗?
非常感谢所有帮助。