用Python和Pygame写游戏-从入门到精通(14) 在继续我们的AI之旅前,分享一个在煎蛋上看到的有趣新闻,能通过读说明书来学习的AI,这个世界真是变得越来越不可琢磨啦!机器人很快就要超越咱了…… 因为这一次是接着上面的内容的,所以请不要跳过直接看这里。 哭!!!写完了上传出错,丢失啊,重伤重写~~~~~~~~~~~ 蚂蚁实例类 在我们正式建造大脑之前,我们得先做一个蚂蚁类出来,就是下面的这个,从GameEntity继承而来: Python class Ant(GameEntity): def __init__(self, world, image): # 执行基类构造方法 GameEntity.__init__(self, world, "ant", image) # 创建各种状态 exploring_state = AntStateExploring(self) seeking_state = AntStateSeeking(self) delivering_state = AntStateDelivering(self) hunting_state = AntStateHunting(self) self.brain.add_state(exploring_state) self.brain.add_state(seeking_state) self.brain.add_state(delivering_state) self.brain.add_state(hunting_state) self.carry_image = None def carry(self, image): self.carry_image = image def drop(self, surface): # 放下carry图像 if self.carry_image: x, y = self.location w, h = self.ca
用python和pygame写游戏-从入门到精通 pdf_用Python和Pygame写游戏-从入门到精通(14)...
最新推荐文章于 2024-05-08 15:29:50 发布