def pygame_testai(ais): """ 输入ai列表, 跑一个pygame的测试游戏看看 """ from snake_game import Game from game_controller import Controller game = Game() c = Controller(game) m = c.map() for ai in ais: ai.setmap(m) result = c.add(ai.name, ai.type) ai.seq = result['seq'] ai.id = result['id'] clock = Clock(3) s = Shower(m) while True: clock.tick() info = c.info() for ai in ais: d = ai.onprocess(info) c.turn(ai.id, d, game.round) game.step() s.flip(info)
def __init__(self, w, h): GWTCanvas.__init__(self, w, h) self.width = w self.height = h self.model = Model(w, h) self.controller = Controller(self.model) images = [ './images/ship1.png', './images/ship2.png', './images/asteroid.png' ] loadImages(images, self) self.sinkEvents(Event.KEYEVENTS)