Exemplo n.º 1
0
    def spawn(self):
        self.windowSurface.fill((255,255,255)) #white screen
        self.draw_map()
        self.draw_walls()
        self.goal_x,self.goal_y = dispUtils.noCollideSpawn(self.windowSurface,self.blacklist,200)
        self.update_blacklist((self.goal_x,self.goal_y))
        self.agent.set_goal(self.goal_x,self.goal_y)
        self.draw_goals()
        self.agent.x,self.agent.y = dispUtils.noCollideSpawn(self.windowSurface,self.blacklist,300)
        self.update_blacklist(( self.agent.x,self.agent.y))
        self.agent.draw()
        if creeps_enabled: 
            self.creep0.draw()
            self.creep1.draw()
            self.creep2.draw()
            self.creep3.draw()

        pygame.display.update()
currentSubgoalIndex = dataUtils.listOfSize(numberOfAgents,-1)
goalsHit = dataUtils.listOfSize(numberOfAgents,0)
last20 = dataUtils.listOfSize(numberOfAgents,dataUtils.listOfSize(20,0))

# Spawn All Agents and Goals
# Agent colours
agentColours = [[255,0,0],[0,255,0],[0,0,255],[255,255,0],[255,0,255]]
pathColours = [[255,128,0],[0,255,128],[128,0,255],[255,255,128],[255,128,255]]

robots = []
goals = []
subgoalIndex = []
for i in range(numberOfAgents):
    # create agent
    robots.append({'position':[100,100], 'size':25 , 'dir':0, 'linearSpeed': 50, 'angularSpeed': 0.1})
    dispUtils.noCollideSpawn(windowSurface,robots[-1],robots[:-1],200)

    # spawn goalpoint
    blacklist = []
    blacklist.extend(robots)
    blacklist.extend(goals)
    goals.append({'position':[100,100], 'size':100})
    dispUtils.noCollideSpawn(windowSurface,goals[-1],blacklist,200)
    if dispUtils.corridorOfSight(windowSurface,robots[-1],goals[-1],55,65)==False:
        pathdata[i] = planner.planPath(windowSurface,robots[i],goals[i])
        subgoalIndex.append(len(pathdata[i][1])-1)
    else:
        pathdata[i] = 0
        subgoalIndex.append(-1)

# PerformanceCheck variables
Exemplo n.º 3
0
 def reset_goal(self):
     self.blacklist = []
     self.update_blacklist(( self.agent.x,self.agent.y))
     self.goal_x,self.goal_y = dispUtils.noCollideSpawn(self.windowSurface,self.blacklist,200)
     self.update_blacklist((self.goal_x,self.goal_y))
     self.agent.set_goal(self.goal_x,self.goal_y)
Exemplo n.º 4
0
    agentY = WINDOWHEIGHT / 2 + math.sin(math.pi - (float(i) * 2 * math.pi) /
                                         float(numberOfAgents)) * 200
    robots.append({
        'position': [int(agentX), int(agentY)],
        'size': 25,
        'dir': 0,
        'linearSpeed': 50,
        'angularSpeed': 0.1
    })

    # spawn goalpoint
    blacklist = []
    blacklist.extend(robots)
    blacklist.extend(goals)
    goals.append({'position': [100, 100], 'size': 100})
    dispUtils.noCollideSpawn(goals[-1], blacklist, 200)

done = False

# run the game loop

while (True):
    sim.doStep()

    #Fill Screen with white background
    windowSurface.fill([255, 255, 255])

    # check for the QUIT event
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()