def render(self, color=None):
        # graphics,
        ''' Draw the triangle agent with color'''
        # self.graphics = Graphics()
        # draw the path if it exists and the mode is follow.
        if self.mode == 'follow_path':
            self.path.render()
            pass
        # draw the ship.
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # add some handy debug drawing info lines - force and velocity.
        if self.show_info:
            s = 0.5  # <-- scaling factor.
            # force.
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity.
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change.
            egi.white_pen()
            egi.line_with_arrow(self.pos + self.vel * s,
                                self.pos + (self.force + self.vel) * s, 5)
            egi.line_with_arrow(self.pos,
                                self.pos + (self.force + self.vel) * s, 5)
Exemple #2
0
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        # draw the ship
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # draw the border
        egi.blue_pen()
        egi.closed_shape(self.walls, False)
        egi.red_pen()
        egi.line_with_arrow(self.pos, self.pos + self.vel * 0.5, 5)    #feeler1

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5 # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos+self.vel * s, self.pos+ (self.force+self.vel) * s, 5)
            egi.line_with_arrow(self.pos, self.pos+ (self.force+self.vel) * s, 5)
Exemple #3
0
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        # draw the ship
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # draw the border
        egi.blue_pen()
        egi.closed_shape(self.walls, False)
        egi.red_pen()
        egi.line_with_arrow(self.pos, self.pos + self.vel * 0.5, 5)  #feeler1

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5  # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos + self.vel * s,
                                self.pos + (self.force + self.vel) * s, 5)
            egi.line_with_arrow(self.pos,
                                self.pos + (self.force + self.vel) * s, 5)
Exemple #4
0
    def render(self):
        if self.hunter is not None:
            self.hunter.render()
        for agent in self.agents:
            agent.render()
        for hide in self.hideObjects:
            hide.render()
        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.showinfo:
            # added additional info to info text in regards to emergant group behaviour ##2018-04-16
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
            infotext = ': '.join(('Cohesion Modifier', str(self.cohesion)))
            egi.white_pen()
            egi.text_at_pos(0, 12, infotext)
            infotext = ': '.join(('Seperation Modifier', str(self.seperation)))
            egi.white_pen()
            egi.text_at_pos(0, 24, infotext)
            infotext = ': '.join(('Alignment Modifier', str(self.alignment)))
            egi.white_pen()
            egi.text_at_pos(0, 36, infotext)
            infotext = ': '.join(('Radius', str(self.radius)))
            egi.white_pen()
            egi.text_at_pos(0, 48, infotext)
Exemple #5
0
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)

        if (self.mode == 'hunt'):
            wnd_pos = Vector2D(self.wander_dist, 0)
            wld_pos = self.world.transform_point(wnd_pos, self.pos,
                                                 self.heading, self.side)
            egi.green_pen()
            egi.circle(wld_pos, self.wander_radius)
            egi.red_pen()
            wnd_pos = (self.wander_target + Vector2D(self.wander_dist, 0))
            wld_pos = self.world.transform_point(wnd_pos, self.pos,
                                                 self.heading, self.side)
            egi.circle(wld_pos, 3)
        # draw it!
        egi.closed_shape(pts)

        if self.show_info:
            s = 0.5  # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos + self.vel * s,
                                self.pos + (self.force + self.vel) * s, 5)
            egi.line_with_arrow(self.pos,
                                self.pos + (self.force + self.vel) * s, 5)
Exemple #6
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        for obstacle in self.obstacle:
            obstacle.render()

        if self.show_info:
            infotext = ': '.join(('Radius', str(self.radius)))
            egi.white_pen()
            egi.text_at_pos(0, 487, infotext)
            infotext = ': '.join(('Cohesion', str(self.cohesion)))
            egi.white_pen()
            egi.text_at_pos(0, 448, infotext)
            infotext = ': '.join(('Seperation', str(self.separation)))
            egi.white_pen()
            egi.text_at_pos(0, 461, infotext)
            infotext = ': '.join(('Alignment', str(self.alignment)))
            egi.white_pen()
            egi.text_at_pos(0, 474, infotext)
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #7
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #8
0
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        # draw the path if it exists and the mode is follow
        if self.mode == 'follow_path':
            self.path.render()

        # draw the ship
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # draw wander info?
        if self.mode == 'wander':
            ## ...
            pass

        #draw neighbour radius
        cntr_pos = Vector2D()
        cntrwld_pos = self.world.transform_point(cntr_pos, self.pos,
                                                 self.heading, self.side)

        egi.white_pen()
        egi.circle(cntrwld_pos, self.neighbour_radius)

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5  # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos + self.vel * s,
                                self.pos + (self.force + self.vel) * s, 5)
            egi.line_with_arrow(self.pos,
                                self.pos + (self.force + self.vel) * s, 5)

        if (self.mode == 'wander'):
            #calculate center of the wander circle in front of agent
            wnd_pos = Vector2D(self.wander_dist, 0)
            wld_pos = self.world.transform_point(wnd_pos, self.pos,
                                                 self.heading, self.side)
            #draw the wander circle
            egi.green_pen()
            egi.circle(wld_pos, self.wander_radius)
            #draw the wander target (little circle on big circle)
            egi.red_pen()
            wnd_pos = (self.wander_target + Vector2D(self.wander_dist, 0))
            wnd_pos = self.world.transform_point(wnd_pos, self.pos,
                                                 self.heading, self.side)
            egi.circle(wld_pos, 3)
Exemple #9
0
    def render(self, color=None):
        egi.blue_pen()
        egi.cross(self.predictedtarget, 5)
        ''' Draw the triangle agent with color'''
        # draw the path if it exists and the mode is follow
        if self.mode == 'follow_path':
            ## ...
            self.path.render()
            pass

        if self.is_hit:
            self.visible = False

        # draw the ship
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)

        # draw it!
        egi.closed_shape(pts)

        self.is_hit = False

        # draw wander info?
        if self.mode == 'wander':
            wnd_pos = Vector2D(self.wander_dist, 0)
            wld_pos = self.world.transform_point(wnd_pos, self.pos,
                                                 self.heading, self.side)
            # draw the wander circle
            egi.green_pen()
            egi.circle(wld_pos, self.wander_radius)
            # draw the wander target (little circle on the big circle)
            egi.red_pen()
            wnd_pos = (self.wander_target + Vector2D(self.wander_dist, 0))
            wld_pos = self.world.transform_point(wnd_pos, self.pos,
                                                 self.heading, self.side)
            egi.circle(wld_pos, 3)
            ## ...
            pass

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5  # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos + self.vel * s,
                                self.pos + (self.force + self.vel) * s, 5)
            egi.line_with_arrow(self.pos,
                                self.pos + (self.force + self.vel) * s, 5)
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        if self.BestHidingSpot is not None:
            egi.white_pen()
            egi.cross(Vector2D(self.BestHidingSpot.x, self.BestHidingSpot.y),
                      5)

        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)
Exemple #11
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.showinfo:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #12
0
    def render(self):
        if self.shooter:
            self.shooter.render()

        if self.target:
            self.target.render()

        if self.bullet:
            self.bullet.render()

        if self.show_info:
            infotext = self.shooter.weapon
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #13
0
    def render(self):
        for agent in self.agents:
            agent.render()

        for target in self.targets:
            target.render()

        for projectile in self.projectiles:
            projectile.render()

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #14
0
    def render(self):
        for agent in self.agents:
            agent.render()

        for enemy in self.enemies:
            enemy.render()

        for projectile in self.projectiles:
            projectile.render()

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #15
0
    def render(self):
        for projectile in self.projectiles:
            projectile.render()

        if self.target:
            self.target.render()

        if self.attacker:
            self.attacker.render()

        if self.show_info:
            infotext = 'Weapon: ' + self.attacker.weapon
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #16
0
    def render(self, color = None):
        if self.show_info:
            s = 0.5 # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.acceleration * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos+self.vel * s, self.pos+ (self.acceleration+self.vel) * s, 5)
            egi.line_with_arrow(self.pos, self.pos+ (self.acceleration+self.vel) * s, 5)

        return super().render(color)
Exemple #17
0
    def render(self):
        self.hunter.render()
        self.cannon.render()

        for projectile in self.projectiles:
            projectile.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.showinfo:
            infotext = ', '.join(
                set(projectile.mode for projectile in self.projectiles))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #18
0
    def render(self):
        for agent in self.agents:
            agent.render()

        self.hunter.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.showinfo:
            controltext = 'Cohesion [Q/W]\nSeparation [T\Y]\nAlignment [K/L]\nNeighbourhood Radius [N/M]'
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 15, controltext)
            egi.text_at_pos(0, 0, infotext)
Exemple #19
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.show_info:
            text = 'Mode: ' + self.agents[0].mode + \
            '\nWander: ' + str(round(self.agents[0].wanderAmount, 2)) + \
            '\nSeparation: ' + str(round(self.agents[0].separationAmount, 2)) + \
            '\nCohesion: ' + str(round(self.agents[0].cohesionAmount, 2)) + \
            '\nAlignment ' + str(round(self.agents[0].alignmentAmount, 2))

            egi.white_pen()
            egi.text_at_pos(10, 420, text)
Exemple #20
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.show_info:
            infotext = \
                'Mode: ' + self.agents[0].mode + \
                ', Local group radius: ' + str(round(self.agents[0].local_group_radius, 2)) + \
                ', Separation: ' + str(round(self.agents[0].separation_multiplier, 2)) + \
                ', Cohesion: '   + str(round(self.agents[0].cohesion_multiplier, 2)) + \
                ', Alignment: '  + str(round(self.agents[0].alignment_multiplier, 2))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #21
0
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        # draw the path if it exists and the mode is follow
        if self.mode == 'follow_path':
            ## ...
            self.path.render()

        # draw the ship
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # draw wander info?
        if self.mode == 'wander':
            ## ...
            wnd_pos = Vector2D(self.wander_dist, 0)
            wld_pos = self.world.transform_point(wnd_pos, self.pos, self.heading, self.side)

            egi.green_pen()
            egi.circle(wld_pos, self.wander_radius)

            egi.red_pen()
            wnd_pos = (self.wander_target + Vector2D(self.wander_dist, 0))
            wld_pos = self.world.transform_point(wnd_pos, self.pos, self.heading, self.side)
            egi.circle(wld_pos, 3)

        if self.mode == 'hide':
            egi.green_pen()
            egi.cross(self.besthidingspot, 5)

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5 # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos+self.vel * s, self.pos+ (self.force+self.vel) * s, 5)
            egi.line_with_arrow(self.pos, self.pos+ (self.force+self.vel) * s, 5)
Exemple #22
0
	def drawBody(self, color=None):
		egi.set_pen_color(color)

		if(self.world.drawDebug):
			if(self.isNeighbour): 
				egi.blue_pen()
			if(self.tagged):
				egi.green_pen()
		if(self.chosenOne): 
			if(self.world.drawDebug or self.world.drawComponentForces):
				egi.white_pen()

		pts = self.pointsInWorldSpace(self.vehicle_shape, self.renderPosition)
		# pts = self.world.transform_points(self.vehicle_shape, self.renderPosition, self.heading, self.side, self.scale)
		# draw it!
		egi.closed_shape(pts)

		self.drawEye(color)
Exemple #23
0
    def render(self):

        self.agent.render()

        for agent in self.enemies:
            agent.render()

        self.targett.render()

        for bullet in self.bullet:
            bullet.render()

        if self.show_info:
            infotext = ', '.join(set(self.agent.mode))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)

        self.refuelst.render()
Exemple #24
0
    def render(self):
        
        for hidingspot in self.hidingspots:
            egi.blue_pen()
            egi.cross(hidingspot, 5)

        for obstacle in self.obstacles:
            obstacle.render()

        self.hunter.render()

        for agent in self.agents:
            agent.render()

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #25
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.hunter:
            agent.render('GREEN')

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            infotext += ', '
            infotext += ' , '.join(
                set(agent.attribute for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #26
0
    def render(self):
        for agent in self.agents:
            agent.render()

        for hunter in self.hunters:
            hunter.render()

        for obstacle in self.obstacles:
            obstacle.render()


        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #27
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            for obstacle in self.obstacles:
                egi.circle(obstacle.pos, obstacle.radius, filled=True)

        if self.show_info:
            massText = "Mass(q,w): " + str(agent.mass)
            maxTurnText = "Max Turn Force(a,s): " + str(agent.max_force)
            maxSpeedText = "Max Speed(z,x): " + str(agent.max_speed)
            agent = self.agents[0]
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
            egi.text_at_pos(150, 0, massText)
            egi.text_at_pos(150, 13, maxTurnText)
            egi.text_at_pos(150, 26, maxSpeedText)
Exemple #28
0
    def render(self):
        for agent in self.agents:
            if agent is not self.hunter:
                agent.render()
            else:
                agent.render("GREEN")

        for obs in self.obstacles:
            obs.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            infotext += ', '
            infotext += ' , '.join(
                set(agent.attribute for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #29
0
    def render(self,delta):


        for agent in self.agents:
            agent.render()

        for obstacle in self.obstacle:
            obstacle.render()

        self.marksman.render()

        self.hitpoint.render()

        for bullet in self.bullet:
            bullet.render()

        if self.show_info:

            infotext = ', '.join(set(bullet.mode for bullet in self.bullet))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #30
0
    def render(self):
        for agent in self.agents:
            if agent is not self.hunter:
                agent.render()
            else:
                agent.render("GREEN")


        for obs in self.obstacles:
            obs.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)


        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            infotext += ', '
            infotext += ' , '.join(set(agent.attribute for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
Exemple #31
0
    def render(self):
        for agent in self.agents:
            if agent.mode == 'hunt':
                egi.blue_pen()
                for spot in agent.hiding_spots:
                    egi.cross(spot, 10)
            elif agent.mode == 'prey':
                egi.green_pen()
                egi.circle(agent.best_spot, 10)
            agent.render()

        for obstacle in self.obstacles:
            obstacle.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.show_info:
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
    def render(self, color=None):
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5  # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos + self.vel * s,
                                self.pos + (self.force + self.vel) * s, 5)
            egi.line_with_arrow(self.pos,
                                self.pos + (self.force + self.vel) * s, 5)
Exemple #33
0
    def render(self):
        for agent in self.agents:
            agent.render()

        if self.target:
            egi.red_pen()
            egi.cross(self.target, 10)

        if self.show_info:
            botSpeedText = "Bot Speed(q,w): " + str(agent.max_speed)
            alignFactText = "Alignment Factor(a,s): " + str(
                agent.AlignmentFactor)
            cohFactText = "Cohesion Factor(z,x): " + str(agent.CohesionFactor)
            sepFactText = "Separation Factor(c,v): " + str(
                agent.SeparationFactor)
            agent = self.agents[0]
            infotext = ', '.join(set(agent.mode for agent in self.agents))
            egi.white_pen()
            egi.text_at_pos(0, 0, infotext)
            egi.text_at_pos(150, 0, botSpeedText)
            egi.text_at_pos(150, 13, alignFactText)
            egi.text_at_pos(150, 26, cohFactText)
            egi.text_at_pos(150, 39, sepFactText)
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                          self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)

        # draw wander info?
        ## ...
        # calculate the center of the wander circle in front of the agent
        wnd_pos = Vector2D(self.wander_dist, 0)
        wld_pos = self.world.transform_point(wnd_pos, self.pos, self.heading, self.side)
        # draw the wander circle
        egi.green_pen()
        egi.circle(wld_pos, self.radius)
        # draw the wander target (little circle on the big circle)
        egi.red_pen()
        wnd_pos = (self.wander_target + Vector2D(self.wander_dist, 0))
        wld_pos = self.world.transform_point(wnd_pos, self.pos, self.heading, self.side)
        
       # egi.circle(self.pos, self.radius)
        
        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5 # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos+self.vel * s, self.pos+ (self.force+self.vel) * s, 5)
            egi.line_with_arrow(self.pos, self.pos+ (self.force+self.vel) * s, 5)
Exemple #35
0
    def render(self, color=None):
        ''' Draw the triangle agent with color'''
        # draw the path if it exists and the mode is follow
        if self.mode == 'follow_path':
            ## ...
            self.path.render()
            pass

        egi.set_pen_color(name=self.color)
        pts = self.world.transform_points(self.vehicle_shape, self.pos,
                                        self.heading, self.side, self.scale)
        # draw it!
        egi.closed_shape(pts)


        
        if self.mode == 'neighbourhood':
            if self.tagged == True:
                self.color = 'BLUE'
            if self.tagged == False:
                self.color = 'ORANGE'
            pass

        # add some handy debug drawing info lines - force and velocity
        if self.show_info:
            s = 0.5 # <-- scaling factor
            # force
            egi.red_pen()
            egi.line_with_arrow(self.pos, self.pos + self.force * s, 5)
            # velocity
            egi.grey_pen()
            egi.line_with_arrow(self.pos, self.pos + self.vel * s, 5)
            # net (desired) change
            egi.white_pen()
            egi.line_with_arrow(self.pos+self.vel * s, self.pos+ (self.force+self.vel) * s, 5)
            egi.line_with_arrow(self.pos, self.pos+ (self.force+self.vel) * s, 5)
Exemple #36
0
 def render(self):
     egi.white_pen()
     egi.set_stroke(3)
     egi.circle(self.pos, self.radius)
Exemple #37
0
def draw_weighting():
    weightingtext = '\n'.join(key + ' : ' + str(value) for key, value in BEHAVIOUR_WEIGHTS.items())
    egi.white_pen()
    egi.text_at_pos(0, world.cy-100, weightingtext)