模块:
simulation.py
sumulation_function.py
robot.py
status.py
service_msg.py
settings.py
类:
class robot:机器人的各种行为,属性的定义
class settings:参数的设定
class status:机器人状态
class Msg:转递动作指令
simulation.py
robots = [Robot(settings, screen, status, 1, (200,600))
Robot(settings, screen, status, 2, (100,700))
robot3
robot4]
status.is_active:是否点击了开始按钮==机器人是否能移动
robot.move(robots):机器人移动
robot.is_ready:所有机器人是否已经准备好一起移动(self.is_ready = self.set_same_direction())
class Robot
self.init
pygame中,把图片和屏幕设置为【矩形】,然后可以对矩形进行各种移动、变换操作:blog.csdn.net/qq_36554582…
self.rect = self.image.get_rect()
self.screen_rect = screen.get_rect()
函数:
def blitme(self):在指定坐标绘制机器人
def calculate_distentce(self, location):计算机器人和location的距离
def calculate_goal_force:计算领航者与目标的势场力
def move_to_goal(self):形成编队并有相同朝向后,领航者将向目标运动
def detectFormation(self, robots):编队是否出现异常情况
def calculate_force(self, robots):计算跟随者机器人所受的势场合力
def move(self, robots):形成编队并有相同朝向后,跟随者将按照领航者动作运动
def set_same_direction(self):跟随者机器人转到和领航者一样的角度
def formming(self,robots):每个机器人对周围进行势场的分析
4 actions:
def move_forwards(self)
def move_backwards(self)
def turn_left(self)
def turn_right(self)
流程图
