Python Pygame Sprite super()__初始化失败

Python Pygame Sprite super()__初始化失败,python,python-3.x,pygame,super,Python,Python 3.x,Pygame,Super,我正在用Pygame和Python3制作一个可视化的进化模拟器。运行模拟器的文件的我的代码: #!/usr/bin/python3 import pygame from organism import Organism def main(): pygame.init() screen_width, screen_height = screen_size = (800, 800) screen = pygame.display.set_mode(screen_size

我正在用Pygame和Python3制作一个可视化的进化模拟器。运行模拟器的文件的我的代码:

#!/usr/bin/python3

import pygame
from organism import Organism


def main():
    pygame.init()
    screen_width, screen_height = screen_size = (800, 800)
    screen = pygame.display.set_mode(screen_size)
    allOrganisms = pygame.sprite.Group()
    allOmnivores = pygame.sprite.Group()
    allHerbivores = pygame.sprite.Group()
    allCarnivores = pygame.sprite.Group()
    test = Organism(screen, (100, 100), allOrganisms, 0, None)


main()
我的生物体代码(super()初始化时代码失败):

#/usr/bin/python3
导入pygame
导入pygame.gfxdraw
从随机导入randint
类有机体(pygame.sprite.sprite):
定义初始(自我、屏幕、位置、所有组织、生成、父级):
#屏幕:pygame。表面对象
#位置:(x,y)
#组:pygame.sprite.Group对象的元组
#父对象:如果生成>1,请指定生物体的父对象,否则使用“无”
超级()。\uuuu初始化\uuuuu(自)
self.wheels速度=self.wheel1速度,self.wheel2速度=0,0
自我尺寸=10
self.pos=位置
self.x=位置[0]
self.y=位置[1]
sightRadiusSize=75
self.sightRadius=pygame.gfxdraw.aacircle(
屏幕,self.x,self.y,sightradiusize,(0,0,0,0))
self.sightRadius=pygame.gfxdraw.filled_圆(
屏幕,self.x,self.y,sightradiusize,(0,0,0,0))
self.foodRadiusSize=25
self.foodRadius=pygame.gfxdraw.aacircle(
屏幕,self.x,self.y,sightradiusize,(0,0,0,0))
self.foodRadius=pygame.gfxdraw.filled_圆(
屏幕,self.x,self.y,sightradiusize,(0,0,0,0))
自我生成
self.parents=父母
如果self.parents不是None:
如果len(自父母)==1:
self.colorOut=self.parents.colorOut
self.meat消化率=self.parents.meat消化率
self.plant消化率=self.parents.plant消化率
其他:
self.colorOut=((self.parents[0]。colorOut[0]+
self.parents[1]。着色[0])/2,
(self.parents[0]。着色[1]+
self.parents[1].coloroout[1])/2,
(self.parents[0]。着色[2]+
self.parents[1].coloroout[2])/2)
self.meat消化率=(self.parents[0]。meat消化率+
self.parents[1].消化率)/2
self.plant消化率=(self.parents[0]。植物消化率+
self.parents[1].植物消化率)/2
其他:
self.colorOut=(randint(50255)、randint(50255)、randint(50255))
自消化率=randint(0,100)
自身植物消化率=randint(0,100)
self.add(allOrganisms)
如果abs(肉类消化率-植物消化率)<10:
self.add(allOmnivores)
elif肉类消化率>植物消化率:
自我添加(所有食肉动物)
其他:
self.add(所有食草动物)
每当我创建一个新的有机体精灵时,我都会收到一条错误消息

File "/home/user/Programming/Python/Evolution Simulator/simulator_v2.py", line 18, in <module>
    main()
  File "/home/user/Programming/Python/Evolution Simulator/simulator_v2.py", line 15, in main
    test = Organism(screen, (100, 100), allOrganisms, 0, None)
  File "/home/user/Programming/Python/Evolution Simulator/organism_v2.py", line 14, in __init__
    super().__init__(self)
  File "/usr/local/lib/python3.5/dist-packages/pygame/sprite.py", line 124, in __init__
    self.add(*groups)
  File "/usr/local/lib/python3.5/dist-packages/pygame/sprite.py", line 142, in add
    self.add(*group)
TypeError: add() argument after * must be an iterable, not Organism
文件“/home/user/Programming/Python/Evolution Simulator/Simulator_v2.py”,第18行,在
main()
文件“/home/user/Programming/Python/Evolution Simulator/Simulator_v2.py”,第15行,主视图
测试=生物体(筛选,(100100),异种生物体,0,无)
文件“/home/user/Programming/Python/Evolution Simulator/organism_v2.py”,第14行,在__
超级()。\uuuu初始化\uuuuu(自)
文件“/usr/local/lib/python3.5/dist-packages/pygame/sprite.py”,第124行,在__
self.add(*组)
文件“/usr/local/lib/python3.5/dist-packages/pygame/sprite.py”,第142行,添加
self.add(*组)
TypeError:add()参数在*之后必须是一个iterable,而不是Organic
在我看来,要么是pygame.sprite.sprite文件中有错误,要么是我没有正确使用它,可能是后者

它需要是
super()。\uuuu init\uuuu()
而不是
super()。\uuuu init\uuuu(self)

super()

super()
它需要是
super()。\uuuu init\uuuu()
而不是
super()。\uuuu init\uuuuu(self)

super()

super()

为什么要将
self
传递给
super()。\uuuu init\uuuu
?这不是正确的语法吗?对不起,我还是个新手谢谢这修复了错误。为什么要将
self
传递给
super()。\uuuu init\uuuu
?这不是正确的语法吗?对不起,我还是个新手谢谢这修正了错误。
File "/home/user/Programming/Python/Evolution Simulator/simulator_v2.py", line 18, in <module>
    main()
  File "/home/user/Programming/Python/Evolution Simulator/simulator_v2.py", line 15, in main
    test = Organism(screen, (100, 100), allOrganisms, 0, None)
  File "/home/user/Programming/Python/Evolution Simulator/organism_v2.py", line 14, in __init__
    super().__init__(self)
  File "/usr/local/lib/python3.5/dist-packages/pygame/sprite.py", line 124, in __init__
    self.add(*groups)
  File "/usr/local/lib/python3.5/dist-packages/pygame/sprite.py", line 142, in add
    self.add(*group)
TypeError: add() argument after * must be an iterable, not Organism