def __init__(self, world=None, scale=15.0, mass=100.0, mode='wander'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random dir = radians(random()*360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass self.radius = 200 # limits? self.max_speed = 100.0 # data for drawing this agent self.color = 'RED' self.vehicle_shape = [ Point2D(-3.0, 1.8), Point2D( 3.0, 0.0), Point2D(-3.0, -1.8) ] self.turnRate = 3 # debug draw info? self.show_info = False ### wander details self.wander_target = Vector2D(1,0) self.wander_dist =1.0 * scale self.wander_radius =1.0 * scale self.wander_jitter =10.0 * scale self.bRadius =scale
def __init__(self, world=None, scale=30.0, mass=1.0, mode='none'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(0) self.pos = self.initial_pos() self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 3), Point2D(-1.0, 0.0), Point2D(1.0, 0.0), Point2D(1.0, 3) ] # Force and speed limiting code # limits self.max_speed = 20.0 * scale ## max_force self.max_force = 500.0 # debug draw info? self.show_info = True self.target_pos = self.pos
def __init__(self, world=None, scale=10.0): self.world = world self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.accel = Vector2D() dir = radians(random() * 360) self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] self.color = 'RED' self.scale = Vector2D(scale, scale) self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale # limits? self.max_speed = 20.0 * scale ## max_force ?? self.max_force = 500.0
def __init__(self, world=None, scale=30.0, mass=1.0, mode='seek'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass self.path = Path() self.randomise_path() self.waypoint_threshold = 0.0 self.wander_target = Vector2D(1, 0) self.wander_dist = 15 * scale self.wander_radius = 0.5 * scale self.wander_jitter = 10 * scale self.bRadius = 2 * scale # limits? self.max_speed = 500.0 * (randrange(50, 100) / 100) # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ]
def __init__(self, world=None, scale=30.0, mass=1.0, mode='seek'): # keep a reference to the world object self.world = world self.mode = mode self.tagged = False # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass # limits? self.max_speed = 1000.0 # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] ### wander details self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale self.BestHidingSpot = None # limits? self.max_speed = 20.0 * scale self.max_force = 500.0
def __init__(self, world=None, scale=30.0, mass=1.0, mode='flee'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass # limits? self.max_speed = 20.0 * scale self.max_force = 500.0 # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] self.detect_width = 1.0 self.min_detect_length = 50.0 self.hide_locations = []
def __init__(self, world=None, scale=30.0, mass=1.0, mode='seek'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass self.neighbours = [] self.hiding_spot = None # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] # Force and speed limiting code # limits self.max_speed = 20.0 * scale ## max_force self.max_force = 500.0 # debug draw info? self.show_info = False
def __init__(self, world=None, scale=30.0, mass=1.0, mode='seek'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random dir = radians(random()*360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass # limits? self.max_speed = 1000.0 # data for drawing this agent self.color = 'BLUE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D( 1.0, 0.0), Point2D(-1.0, -0.6) ] self.path = Path() self.randomise_path() self.waypoint_threshold = 150.0 self.turnRate = 3
def __init__(self, world=None, gun_type = None, scale=30.0, mass=0.5): # keep a reference to the world object self.world = world self.tagged = False self.target_pos = None self.gun_type = gun_type # where am i and where am i going? random dir = radians(random()*360) self.pos = Vector2D(self.world.agents[0].pos.x,self.world.agents[0].pos.y) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass self.radius = 35.00 # limits? # data for drawing this agent self.color = 'WHITE' self.vehicle_shape = [ Point2D(-0.2, 0.1), Point2D( 0.2, 0.0), Point2D(-.2, -0.1) ] self.moving_speed = 'slow' # limits? self.max_speed = 100.0 * scale self.max_force = 500.0 self.turnRate = 3
def __init__(self, world=None, scale=30.0, mass=1.0, mode='shoot'): # keep a reference to the world object self.world = world self.points = 1 self.mode = mode # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(100.00, randrange(0.00, 600.00)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass # limits? # data for drawing this agent self.color = 'BLUE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] # limits? self.max_speed = 20.0 * scale self.max_force = 500.0 ## max_force ?? # debug draw info? self.show_info = False
def __init__(self, world=None, scale=30.0, mass=1.0, weapon='RIFLE'): # keep a reference to the world object self.world = world self.weapon = weapon self.mode = "FOLLOW_PATH" self.pos = self.initial_pos() self.vel = Vector2D() self.heading = Vector2D(sin(0), cos(0)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.max_speed = 100 self.max_force = 500.0 # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] ### path to follow? self.path = Path() self.randomise_path() # <-- Doesn’t exist yet but you’ll create it self.waypoint_threshold = 0.0 # <-- Work out a value for this as you test
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 hiding spots egi.blue_pen() egi.circle(self.obstacles[0], 25) egi.circle(self.obstacles[1], 50) egi.circle(self.obstacles[2], 75) #draw detection box egi.blue_pen() length = 1.0 * (self.speed() / self.max_speed) * 3.0 #db length dbox = [ Point2D(-1.0, 0.6), Point2D(length, 0.6), #new Point2D(length, 0.0), #new Point2D(length, -0.6), #new Point2D(-1.0, -0.6) ] pts = self.world.transform_points(dbox, self.pos, self.heading, self.side, self.scale) egi.closed_shape(pts, False)
def __init__(self, world=None, scale=30.0, mass=1.0, mode='wander', visible=False): self.world = world self.mode = mode self.visible = visible dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) self.acceleration = Vector2D() self.mass = mass # wander info self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # limits self.max_speed = 20.0 * scale self.max_force = 500.0 # data for drawing hunter self.color = 'BLUE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ]
def __init__(self, world=None, scale=30.0, mass=1.0, mode=None, color=None): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # Force and speed limiting code self.max_speed = 2.0 * scale self.max_force = 5.0 * scale # data for drawing this agent self.color = color self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] # wander details self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # group based weight values self.wander_wt = 1.0 self.align_wt = 1.0 self.cohesion_wt = 1.0 self.separate_wt = 1.0 self.neighbours = [] self.neighbour_radius = 150 # debug draw info? self.show_info = False # data for drawing walls self.walls = [ Vector2D(10.0, 490.0), Vector2D(490.0, 490.0), Vector2D(490.0, 10.0), Vector2D(10.0, 10.0) ]
def __init__(self, world=None, scale=30.0, mass=1.0, mode='seek', hunter=False, id=0): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] ### path to follow? # self.path = ?? self.path = Path() self.randomise_path() # <-- Doesn’t exist yet but you’ll create it self.waypoint_threshold = 50.0 # <-- Work out a value for this as you test! ### wander details # self.wander_?? ... # NEW WANDER INFO # NEW WANDER INFO self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # Force and speed limiting code self.max_speed = 40.0 * scale self.max_force = 500.0 # limits? self.max_speed = 20.0 * scale ## max_force ?? # neighbourhood self.tagged = False # debug draw info? self.show_info = False self.hunter = hunter if self.hunter == True: self.max_speed = 20 * scale self.visible = True
def __init__(self, world=None, scale=30.0, mass=0.5, mode='seek'): # keep a reference to the world object. self.world = world self.mode = mode # where am i and where am i going? random start pos. dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size. self.force = Vector2D() # current steering force. self.accel = Vector2D() # current acceleration due to force. self.mass = mass # data for drawing this agent. self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] ### Spike 7 definitions ### self.neighbour_radius = 2.0 * scale ## Spike 7 definitions end ### ### follow path mode edit 1 ### self.path = Path() self.randomise_path() # <-- Doesn’t exist yet but you’ll create it. self.waypoint_threshold = 50.0 # <-- Work out a value for this as you test! ### end follow path mode edit 1 ### ### added wonder info part 2 ### # NEW WANDER INFO ### wander details. self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # Force and speed limiting code # max speed is here. # limits? self.max_speed = 20.0 * scale self.max_force = 500.0 ### end add wander infor part 2 ### # debug draw info? self.show_info = False
def __init__(self, world=None, scale=10.0, mass=1.0, mode='wander'): # keep a reference to the world object self.world = world self.mode = mode self.tagged = False # where am i and where am i going? random start pos dir = radians(random()*360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D( 1.0, 0.0), Point2D(-1.0, -0.6) ] ### path to follow? self.path = Path() self.randomise_path() self.waypoint_threshold = 20 ### wander details # self.wander_?? ... self.wander_target = Vector2D(1,0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale #Neighbourhood radius self.tag_radius = 5.0 * scale self.cohesion_toggle = False self.alignment_toggle = False self.seperation_toggle = False #Obstacle Avoidance params self.min_box_length = 5.0 * scale # limits? self.max_speed = 20.0 * scale ## max_force ?? self.max_force = 500.0 # debug draw info? self.show_info = False
def __init__(self, world=None, scale=5.0, mass=1.0, mode='wander'): # keep a reference to the world object self.world = world self.mode = mode self.AlignmentFactor = self.world.botAlignmentFactor self.CohesionFactor = self.world.botCohesionFactor self.SeparationFactor = self.world.botSeparationFactor # where am i and where am i going? random start pos dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] self.path = Path() self.waypoint_threshold = 9.0 self.randomise_path() ### wander details self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale self.tagged = False self.botList = self.world.agents self.overlapping = False self.neighbour_radius = 6 * scale # Force and speed limiting code self.max_speed = self.world.botMaxSpeed self.max_force = 500.0 # debug draw info? self.show_info = False
def __init__(self, world=None, hunter=None, scale=30.0, mass=1.0, mode='seek'): # keep a reference to the world object self.world = world self.hunter = hunter self.mode = mode # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass # Wander info self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # limits? self.max_speed = 20.0 * scale self.max_force = 500.0 # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] self.path = Path() self.waypoint_threshold = 10.0 self.randomise_path() # flocking self.cohesion_amount = 0.0 self.alignment_amount = 0.0 self.separation_amount = 0.0 # cohesion, separation and alignment field setups self.tagged = list() self.neighbourhood_radius = 10.0
def __init__(self, world=None, pos=Vector2D(), scale=30.0, mass=1.0, mode='', color=None, speed=0.0): # keep a reference to the world object self.world = world self.mode = mode ang = random() * 360 # where am i and where am i going? random start pos dir = radians(random() * 360) self.pos = pos self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass self.health = 100 self.ammo = 10 self.idx = 0 #bullet info self.bullet_pos = Vector2D() self.step_count = 0 self.avg = Vector2D() self.enemy = Vector2D() # data for drawing this agent self.color = color self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] # wander details self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # speed self.max_speed = speed * scale
def __init__(self, world=None, scale=30.0, mass=1.0, mode='combined'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(random()*360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass self.neighbours = [] # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D( 1.0, 0.0), Point2D(-1.0, -0.6) ] ### path to follow? self.path = Path() self.randomise_path() # <-- Doesn’t exist yet but you’ll create it self.waypoint_threshold = 0.0 # <-- Work out a value for this as you test ### wander details self.wander_target = Vector2D(1, 0) self.wander_dist = 3.9 * scale self.wander_radius = 0.2 * scale self.wander_jitter = 4.3 * scale self.bRadius = scale # Force and speed limiting code # limits self.max_speed = 20.0 * scale ## max_force self.max_force = 500.0 # debug draw info? self.show_info = False #group variables self.wander_var = 1 self.alignment_var = 1 self.cohesion_var = 1
def __init__(self, world=None, scale=30.0, mass=1.0, mode='patrol'): # keep a reference to the world object.py self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] ### path to follow? # self.path = ?? self.path = Path() self.randomise_path(10) self.waypoint_threshold = 10.0 ### wander details # self.wander_?? ... self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale # limits? self.max_speed = 100.0 self.max_force = 200.0 self.bulletspeed = 500.0 self.bullets = 6 self.reload_time = 1 self.current_reload_time = 0.0 self.gun_state = 'loaded' # debug draw info? self.show_info = False
def __init__(self, world=None, scale=30.0, mass=1.0, mode=None, color=None, speed=0.0): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going self.angle = 0 dir = radians(self.angle) self.pos = Vector2D(250,250) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # Force and speed limiting code self.max_speed = speed self.max_force = 500.0 # data for drawing this agent self.color = color self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D( 1.0, 0.0), Point2D(-1.0, -0.6) ] self.margin = Vector2D(self.world.cx - 10, self.world.cy - 10) # data for drawing target self.x0 = 10 #x left pt self.x1 = 120 #x right pt self.y0 = 490 #y top pt self.y1 = 450 #y bottom pt self.target_dir = 'right' self.target_mid = Vector2D((self.x1-self.x0) / 2, (self.y0-self.y1) / 2) self.target_pos = None #provided at each new render # data for drawing bullet self.steps = None #frequency of shots hitting target self.step_count = 0 self.bullet_pos = Vector2D(250,250) self.avg = Vector2D() self.size = None
def aim(self): ''' move towards target position ''' target = self.world.target if target: desired_vel = (target.pos - self.pos).normalise() return (desired_vel - self.vel) return Point2D()
def __init__(self, world=None, scale=30.0, mass=1.0, mode='seek', looped=True): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass # limits? self.max_speed = 20.0 * scale / 2 self.max_force = 500.0 # Random Path to follow in PathFollow mode self.path = Path() self.path_looped = looped self.randomise_path(looped) self.waypoint_threshold = 20 # Wander Info self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 1.0 * scale self.bRadius = scale # If Tagged is true, We are part of a neighbourhood self.tagged = False # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ]
def __init__(self, world=None, scale=30.0, mass=1.0, weapon='RIFLE'): # keep a reference to the world object self.world = world self.weapon = weapon self.pos = self.initial_pos() self.vel = Vector2D() self.heading = Vector2D(sin(0), cos(0)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ]
def __init__(self, world=None): # keep a reference to the world object self.world = world if len(self.world.agents) > 0: self.mode = 'prey' else: self.mode = 'hunt' # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() if self.mode == 'hunt': scale = 30.0 self.max_speed = 5.0 * scale self.max_force = 250.0 self.mass = 2.0 else: scale = 20.0 self.max_speed = 15.0 * scale self.max_force = 500.0 self.mass = 0.75 self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.acceeration = Vector2D() # current steering force # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] self.show_info = False self.wander_target = Vector2D(1, 0) self.wander_dist = 1.0 * scale self.wander_radius = 1.0 * scale self.wander_jitter = 10.0 * scale self.bRadius = scale self.hiding_spots = [] self.best_spot = None
def __init__(self, world=None, scale=10.0, mass=1.5, mode='neighbourhood'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(random()*360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.force = Vector2D() # current steering force self.accel = Vector2D() # current acceleration due to force self.mass = mass # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-0.5, 0.25), Point2D( 0.5, -0.3), Point2D(-0.5, -0.25) ] ### wander details self.wander_target = Vector2D(1,0) self.wander_dist =5.0 * scale self.wander_radius =3.0 * scale self.wander_jitter =1.0 * scale self.bRadius =scale # limits? self.max_speed = 20.0 * scale self.max_force = 500.0 ## max_force ?? self.tagged = False # debug draw info? self.show_info = False
def __init__(self, world=None, scale=30.0, mass=1.0, mode='shoot'): # keep a reference to the world object self.world = world self.points = 1 self.mode = mode self.looped = False self.move = False # where am i and where am i going? random dir = radians(random() * 360) self.pos = Vector2D(randrange(world.cx), randrange(world.cy)) self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size self.acceleration = Vector2D() # current steering force self.mass = mass self.hit = False self.hit_color = 'RED' # limits? # data for drawing this agent self.color = 'GREEN' self.vehicle_shape = [ Point2D(-1.0, 0.6), Point2D(1.0, 0.0), Point2D(-1.0, -0.6) ] self.path = Path() self.randomise_path() self.waypoint_threshold = 300.0 self.moving_speed = 'slow' # limits? self.max_speed = 20.0 * scale self.max_force = 500.0 ## max_force ?? # debug draw info? self.show_info = False
def __init__(self, world=None, scale=30.0, mass=1.0, mode='none'): # keep a reference to the world object self.world = world self.mode = mode # where am i and where am i going? random start pos dir = radians(0) self.pos = self.initial_pos() self.vel = Vector2D() self.heading = Vector2D(sin(dir), cos(dir)) self.side = self.heading.perp() self.scale = Vector2D(scale, scale) # easy scaling of agent size # data for drawing this agent self.color = 'ORANGE' self.vehicle_shape = [ Point2D(-1.0, 3), Point2D(-1.0, 0.0), Point2D(1.0, 0.0), Point2D(1.0, 3) ] self.health = 50