def formatTarget(rawTarget, apidMap): tInfoMap = {} for bssid in rawTarget: if int(bssid, 16) not in apidMap.bssid2Apid: continue tInfoMap[apidMap.getApid(bssid)] = TargetInfo(rawTarget[bssid], True) return Target(0, Position(0, 0), tInfoMap)
def start(): aTarget = Target() #initializes both objects aPursuer = Pursuer() interactions = interactionsChecker( ) #calling these two functions to check user is stupid aTarget.xIntProb = probabilityChecker() interactionsCount = STARTING_COUNTER numTotMatches = STARTING_COUNTER while (interactionsCount < interactions): #runs while interactions are all complete targXBhvr = aTarget.behaviorGeneration( ) #generates Target behavior, returns it is variable to pass xCount, yCount = aTarget.tallyTarget( ) #tallies results each loop, returns it as variable to pass aPursuer.behaviorGeneration() #generates Pursuer behavior aPursuer.tallyPursuer() #tally results each loop aPursuer.tallySuccessful( targXBhvr) #checks each interaction, tallies successful ones aPursuer.probabilityShift( ) #calls shifting probability function from Pursuer to adjust x based on successful interactions interactionsCount = interactionsCount + 1 #update loop control aPursuer.displayEnd(interactions, xCount, yCount) #finalresults after loop done
def readTargetFile(targetFilePath, apidMap): targets = [] f = open(targetFilePath, 'r+') for line in f.readlines(): line = line.replace('\r', '').replace('\n', '').replace(':', ',') if len(line) == 0: continue columns = line.split(' ') # require at least 3 dimensions (APs or beacons) if len(columns) < 4: continue # x, y values = columns[0].split(',') x = float(values[0]) y = float(values[1]) pos = Position(x, y) # ap tInfoMap = {} for column in columns[1:]: if len(column) == 0: continue values = column.split(',') bssid = values[0].upper() apid = apidMap.getApid(bssid) level = float(values[1]) tInfoMap[apid] = TargetInfo(level, True) targets.append(Target(len(targets), pos, tInfoMap)) f.close() return targets
def __init__(self, window): self.window = window self.frogs = [] self.popsize = 300 self.dna = DNA() self.target = Target(self.window) self.lilly_pads = [] self.matingpool = [] self.count = 0 for lillypad in range(0, 30): self.lilly_pads.append( LillyPad(self.window, (random.randrange( 0, window.width), random.randrange(0, window.height)))) self.lilly_pads.append( LillyPad(self.window, (self.window.width / 2, self.window.height - 50))) self.lilly_pads.append( LillyPad(self.window, (self.target.cord[0], self.target.cord[1]))) for frog in xrange(self.popsize): self.frogs.append( Frogs(self.window, self.dna.get_random_dna(), self.lilly_pads, self.target)) frog_nodes = (lambda x, y: [(x - 10, y - 10), (x + 10, y - 10), (x + 10, y + 10), (x - 10, y + 10)]) self.frogs[frog].add_nodes( frog_nodes(self.window.width / 2, self.window.height - 50))
def execute_agama(self, data_agama): #cek operator operator = data_agama[2] if operator == 'INS': try: #set id agama, anama agama id_agama = data_agama[0] nama_agama = data_agama[1] data_agama_2 = (id_agama, nama_agama) #calling insert method inserting_data = myTarget.Target() result = inserting_data.insert_agama(data_agama_2) #result = 'Calling insert method successed' except: result = 'Calling Error' elif operator == 'DEL': try: result = 'Callinf insert method' except: result = 'Calling error' else: try: result = 'Calling update method' except: result = 'Calling error' return result
def var_init(self, amount_of_sensors, amount_of_targets, range_of_sensor, capacity, map_high, map_width): self.amount_of_sensors = amount_of_sensors self.amount_of_targets = amount_of_targets self.range_of_sensor = range_of_sensor self.capacity = capacity self.map_high = map_high self.map_width = map_width self.sensor_list = [] self.target_list = [] for x in range(0, amount_of_sensors): self.sensor_list.append( Sensor.Sensor( capacity, range_of_sensor, Point.Point( randrange(range_of_sensor, map_width - range_of_sensor), randrange(range_of_sensor, map_high - range_of_sensor)))) for x in range(0, amount_of_targets): self.target_list.append( Target.Target( Point.Point( randrange(map_width - 2 * 0.1 * map_width) + 0.1 * map_width, randrange(map_high - 2 * 0.1 * map_high) + 0.1 * map_width)))
def radar(width, height, color): #radar display config screen_width = width screen_height = height x = pygame.init() pygame.font.init() defaultFont = pygame.font.get_default_font() fontRenderer = pygame.font.Font(defaultFont, 20) #screen_width = 800 #screen_height =500 radarDisplay = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption('Radar Screen') #GPIO setup RangerRead = GroveUltrasonicRanger(5) # targets list targets = {} a = 0 #radar read and write to dict while True: for angle in range(0, 180): distance = RangerRead.get_distance() distance = round(distance, 2) if distance != -1 and distance <= 50: targets[angle] = Target(angle, distance) draw(radarDisplay, targets, angle, distance, fontRenderer, screen_width, screen_height, color) time.sleep(0.0001) #draw_bck(radarDisplay, fontRenderer, screen_width, screen_height) targets = {} for angle in range(180, 0, -1): distance = RangerRead.get_distance() distance = round(distance, 2) if distance != -1 and distance <= 50: targets[angle] = Target(angle, distance) draw(radarDisplay, targets, angle, distance, fontRenderer, screen_width, screen_height, color) time.sleep(0.0001) #draw_bck(radarDisplay, fontRenderer, screen_width, screen_height) targets = {}
def calibrate(target, cf): if not cf.needCalibration: return target tInfoMap = {} for apid in target.tInfoMap: level = target.tInfoMap[apid].level tInfoMap[apid] = TargetInfo(level + cf.offset, True) return Target(target.tid, Position(target.pos.x, target.pos.y), tInfoMap)
def __init__(self, target_lat, target_lon, target_char): self.target = Target.Target(target_lon, target_lat, target_char) self.conn = sqlite3.connect("training_data.db") self.c = self.conn.cursor() self.c.execute('''CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY AUTOINCREMENT, DATETIME, uas_height DOUBLE, uas_long DOUBLE, uas_lat DOUBLE, uas_heading DOUBLE, uas_pitch DOUBLE, uas_roll DOUBLE, target_long DOUBLE, target_lat DOUBLE, target_letter CHAR, img_name TEXT)''') self.conn.commit()
def new_game(self): """Само тело игры""" print("HERE") for i in range(len(self.t)): self.t[i] = Tg.Target(self.canv) self.t[i].new_target(400 + 110 * i) self.t[i].live = 1 Tg.lives += 1 return
def string2Target(apidMap, fingerprint): tInfoMap = {} for bssidRssi in fingerprint.split('__'): pair = bssidRssi.split('_') bssid = pair[0].upper() rssi = float(pair[1]) apid = apidMap.getApid(bssid) tInfoMap[apid] = TargetInfo(rssi, True) return Target(0, Position(0, 0), tInfoMap)
def __init__(self, ): super().__init__() self.setMouseTracking(True) self.targets = [] f = open("src_tp_bubble.csv") for line in f: x, y, size = line.split(",") self.targets.append(Target(int(x), int(y), int(size))) self.cursor = BubbleCursor(self.targets)
def probabilityChecker(): #this function checks user input by recursion aTarget = Target() try: aTarget.xIntProb = int(input("Enter the probability of x (0 - 100): ")) if aTarget.xIntProb < LOWER_BOUND_RANDOM or aTarget.xIntProb > UPPER_BOUND_RANDOM: print("Number must be between 0 - 100, try again!") aTarget.xIntProb = probabilityChecker() except: print("Non numerical input - Try again!") aTarget.xIntProb = probabilityChecker() return (aTarget.xIntProb)
def __init__(self): super().__init__() self.targets = list() self.cursor = RopeCursor(self.targets) self.setMouseTracking(True) with open('src_tp_bubble.csv', 'r') as csvfile: spamreader = csv.reader(csvfile, delimiter=',') for row in spamreader: self.targets.append( Target(int(row[0]), int(row[1]), int(row[2]))) self.cursor.selectTarget()
def reset(self): # called when ready to play a round of the game self.nClicks = 0 self.nTargetsHit = 0 self.nMissedTargets = 0 self.nMissedClicks = 0 self.targetList = [] timeNow = time.perf_counter() for i in range(0, N_TARGETS): oTarget = Target(self.window, self.windowWidth, self.windowHeight, timeNow, N_SECONDS) self.targetList.insert(0, oTarget) # add at the beginning of the list self.state = PLAYING
def generate_targets(bits): targets = [] count = 0 for sequence in generate_sequences(bits): log.debug(str(sequence)) if sequence.count(True) == 0: continue if test_if_exists(sequence, targets): continue else: count += 1 target = Target(count, sequence) targets.append(target) return targets
def new_game(self): """Само тело игры""" print("HERE") for i in range(len(self.t)): self.t[i] = Tg.Target(self.canv) self.t[i].new_target(400 + 110 * i) self.t[i].live = 1 Tg.lives += 1 while Tg.lives: for i in range(len(self.t)): if self.t[i].live: self.t[i].move() for b in G.balls: if b.live: b.move() for i in range(len(self.t)): ''' if t[i].live: t[i].move()''' if b.hittest(self.t[i]) and self.t[i].live: self.t[i].live = 0 self.t[i].hit() Bl.points += 1 self.canv.itemconfig(self.id_points, text=Bl.points) self.canv.delete(b.id) b.live = 0 Tg.lives -= 1 self.canv.update() time.sleep(self.zzz) self.g1.targetting() self.g1.power_up() for i in G.balls: self.canv.delete(i.id) G.balls = [] tx = dt.datetime.now() delta = 1 self.canv.itemconfig(self.screen1, text='Вы уничтожили 2 цели за ' + str(G.bullet) + ' выстрелов') while (dt.datetime.now() - tx).seconds < delta: self.canv.update() time.sleep(self.zzz) self.g1.targetting() self.g1.power_up() G.bullet = 0 Bl.points = 0 self.canv.itemconfig(self.screen1, text='') self.canv.itemconfig(self.id_points, text=0) self.root.after(1, self.new_game)
def set_layout(self, obcp): ins = INS.INSdata() ins_code = ins.getCodeByName(obcp) self.__set_aliases(ins_code) qtwidget = QtGui.QWidget() self.target = Target.Target(qtwidget, obcp=ins_code, \ logger=self.logger) self.vlayout = QtGui.QVBoxLayout() self.vlayout.setContentsMargins(0, 0, 0, 0) self.vlayout.setSpacing(0) self.vlayout.addWidget(self.target,stretch=1) self.root.setLayout(self.vlayout)
def __init__(self): self.gameStatus = MachineOfStates( ) # say a game status main, gameOPT, 1pvsCp, 1pvs2p self.configureGameStatus() # Balls self.ballTarget = "" # Ball to Hit (white, yellow, red) self.ballWhite = Ball() self.ballYellow = Ball() self.ballRed = Ball() self.balls = [self.ballWhite, self.ballYellow, self.ballRed] # Array with all balls # Table self.SizeOfTable = 0 # Autoconfigure when the game is run >> L # Players self.target = Target( ) # This is a interface usert to hit the ball and configures self.Players = []
def main(): rad = 2 time_step = 0.05 win_x = 200.0 win_y = 100.0 # create window m_win = GraphWin("My Application", 1000, 500) # set up coordinate system m_win.setCoords(0, 0, win_x, win_y) # fill in background m_win.setBackground("light blue") wall_a = Wall(Point(80, 20), Point(85, 80), m_win) wall_b = Wall(Point(150, 0), Point(152, 20), m_win) wall_c = Wall(Point(150, 80), Point(152, 100), m_win) walls = [wall_a, wall_b, wall_c] m_sim = Simulation(time_step, win_x, win_y, walls, m_win) aim_tool = Aimer(m_win) m_sim.set_vel(aim_tool.aim_loop()) # goal setup llx = 80 lly = 0 urx = 85 ury = 4 m_target = Target(Point(llx, lly), Point(urx, ury), m_win, True) # run loop for i in range(1000): # plot one pixel m_sim.loop() if m_target.hit_target(m_sim.ball, m_win): message = Text(Point(50, 50), "YOU WON!") message.setSize(30) message.setStyle("bold") message.setTextColor("green") message.draw(m_win) print("YOU WON! CONGRATULATIONS!") break time.sleep(time_step / 10) # wait for click m_win.getMouse()
def __init__(self, level_num, difficulty, moving_target): self.curr_time = int(round(time.time() * 1000)) self.a_curr_time = int(round(time.time() * 1000)) self.difficulty = difficulty self.moves = moving_target self.level_num = level_num self.rad = 1 self.time_step = 0.05 self.win_x = 200.0 self.win_y = 100.0 self.center = Point(self.win_x / 2, self.win_y / 2) # create window self.m_win = GraphWin(("Level" + str(self.level_num)), 1000, 500, autoflush=False) # set up coordinate system self.m_win.setCoords(0, 0, self.win_x, self.win_y) self.prime_msg() # fill in background self.m_win.setBackground("light blue") # make walls self.walls = self.get_walls() # start simulation self.sim = Simulation(self.time_step, self.win_x, self.win_y, self.walls, 0.8, "orange", self.m_win) # static target for now self.target = Target(Point(175, 0), Point(180, 5), False, self.m_win) # if no moving target if (self.moves == False): # create aiming tool self.aim_tool = Aimer(self.m_win) self.sim.set_vel(self.aim_tool.aim_loop()) self.target.set_moves(False) else: # dont use aimer vel = [random.randint(15, 30), random.randint(15, 30)] self.sim.set_vel(vel) # make target move self.target.set_moves(True)
def main(): rad = 2 time_step = 0.05 win_x = 200.0 win_y = 100.0 xv = 25.0 yv = 20.0 m_sim = Simulation(time_step, win_x, win_y, xv, yv) # create window m_win = GraphWin("My Application", 1000, 500) # set up coordinate system m_win.setCoords(0, 0, win_x, win_y) # fill in background m_win.setBackground("light blue") # goal setup llx = 80 lly = 0 urx = 85 ury = 4 m_target = Target(Point(llx, lly), Point(urx, ury), m_win) c = Circle(Point(m_sim.ball.getX(), m_sim.ball.getY()), rad) c.setFill("orange") c.draw(m_win) # run loop for i in range(1000): # plot one pixel c.undraw() c = Circle(Point(m_sim.ball.getX(), m_sim.ball.getY()), rad) c.setFill("orange") c.draw(m_win) m_sim.loop() if m_target.hit_target(m_sim.ball, m_win): message = Text(Point(50, 50), "YOU WON!") message.setSize(30) message.setStyle("bold") message.setTextColor("green") message.draw(m_win) print("YOU WON! CONGRATULATIONS!") break time.sleep(.005) # wait for click m_win.getMouse()
minRadius = 0.2 maxRadius = 1.4 maxAccel = 850 cannonL = 0.5 maxCannonL = 1.5 minCannonL = 0.25 dt = 0.02 angle1 = 45.0 angle2 = 165.0 cannon = Vector.Vector3D(0, 0, 0) target = Target.Target() head = Ball.node() ballList = [] def init(): mat_specular = [1.0, 1.0, 1.0, 0.0 ] mat_shininess = [10.0] light_position = [1.0, 1.0, 1.0, 0.0] light_ambient = [0.8, 0.8, 0.8, 1.0] light_diffuse = [1.0, 1.0, 1.0, 1.0] light_specular = [0.8, 0.8, 0.8, 1.0] glClearColor(0.0, 0.0, 0.0, 0.0) glShadeModel(GL_SMOOTH)
import Adafruit_TCS34725 import RPi.GPIO as GPIO import Display import Button import Game i2c = I2C servo = Adafruit_PCA9685.PCA9685(address=0x40, busnum=1) mux = Mux.Mux() # GPIO.setmode(GPIO.BOARD) # Set frequency to 60hz, good for servos. servo.set_pwm_freq(60) display = Display.Display(mux, 0) t1 = Target.Target(mux, 1, servo, 2, 4) t2 = Target.Target(mux, 2, servo, 3, 17) t3 = Target.Target(mux, 3, servo, 0, 27) t4 = Target.Target(mux, 4, servo, 4, 22) t5 = Target.Target(mux, 5, servo, 1, 10) green = Button.Button(23) yellow = Button.Button(24) red = Button.Button(25) blue = Button.Button(8) # Initialize all targets for t in [t1, t2, t3, t4, t5]: t.down() t.led_off()
def get_model_environment(): # This method is used to get the input from the user interactively to create the simulation environment. # in order to run the program, the user can type python3 simulation.py in command line, or # %run simulation.py inside a jupyter notebook that is created in the same directory as this project. # After obtaining the user input, method creates the Pedestrians, Obstacles, Target objects, # and calls init_simulation method to initialize the simulation. sys.stdout.write("Hello! Welcome to our simulation. The instructions below are designed to have an interactive " "simulation process.\n\n" "First, you have to indicate the environment area. Please type the length of cell size after " "you are asked.\n\nThen, please indicate the target location with a space between. (ex: '25 25') " "after you are asked. \n\nAfter that, please indicate the location of obstacles OR pedestrians as " "stated below. \n\n\nFor obstacles: 'o x y', where x and y indicate the x and y coordinate " "locations, from 0 until cell size you provided (that is excluded.).\n\n\n" "For pedestrians: 'p x y', where x and y indicate the x and y coordinate locations.\n\n" "When you are done, please write 'exit'. Thank you!\n\n") time = int(input("Please enter the simulation run time. (Ex: 25) If there is no specific time requirement, please write 0.\n")) speed_or_not = int(input("Please type 0 for simulation without speed involved. Else, type 1.\n")) if not speed_or_not: mode = int(input( "Please enter the simulation mode. Write 0 for simulation by using Eucledian Distance, and Write 1 for simulation by using a cost function. \n")) while not(mode == 1 or mode == 0): sys.stdout.write("Invalid mode.") mode = int(input("Please enter the simulation mode. Write 0 for simulation by using Eucledian Distance, and Write 1 for simulation by using a cost function. \n")) size_x = int(input("Please indicate the width of the area\n")) size_y = int(input("Please indicate the height of the area\n")) target = input("\nPlease indicate the target location with a space between. (ex: '25 25')\n") rmax = int(input("\nPlease indicate the minimum distance between pedestrians for pedestrian avoidance.\n")) sys.stdout.write("\nPlease indicate the location of obstacles OR pedestrians as stated below, with locations, from " "0 until cell size you provided (that is excluded.)\n\nFor obstacles: 'o x y'" ", where x and y indicate the x and y coordinate locations.\nFor pedestrians: 'p x y', where x and " "y indicate the x and y coordinate locations.\n\n" "If you want to add objects from txt file, please write 'text' and the name of the file as 'example.txt'\n\n" "When you are done, please write 'exit'\n\n") target.strip() i = target.index(" ") x = int(target[0:i]) y = int(target[i + 1:]) target = Target(y,x) obstacle_list = [] pedestrian_list = [] while True: req = input("Please enter the request.") req.strip() if req == "exit": sys.stdout.write("\n") break elif req == "text": read_from_file(pedestrian_list, obstacle_list, size_x, size_y, 1) elif not(any(i in ["o", "p"] for i in ["o", "p"])): sys.stdout.write("Invalid object.") else: add_to_map(req, size_x, size_y, obstacle_list, pedestrian_list) else: mode = 1 size_x = int(input("Please indicate the width of the area\n")) size_y = int(input("Please indicate the height of the area\n")) target = input("\nPlease indicate the target location with a space between. (ex: '25 25')\n") target.strip() i = target.index(" ") x = int(target[0:i]) y = int(target[i + 1:]) target = Target(y,x) rmax = int(input("\nPlease indicate the minimum distance between pedestrians for pedestrian avoidance.\n")) default_speed_not = int(input("\nDefault pedestrian speed is 1.33 m/s. Please type 0 for manual speed input for pedestrians. Else, type 1.\n")) if default_speed_not: sys.stdout.write( "\nPlease indicate the location of obstacles OR pedestrians as stated below, with locations, from " "0 until cell size you provided (that is excluded.)\n\nFor obstacles: 'o x y'" ", where x and y indicate the x and y coordinate locations.\nFor pedestrians: 'p x y', where x and " "y indicate the x and y coordinate locations.\n\n" "If you want to add objects from txt file, please write 'text' and the name of the file as 'example.txt'\n\n" "When you are done, please write 'exit'\n\n") obstacle_list = [] pedestrian_list = [] while True: req = input("Please enter the request.") req.strip() if req == "exit": sys.stdout.write("\n") break elif req == "text": read_from_file(pedestrian_list, obstacle_list, size_x, size_y, 2) elif not (any(i in ["o", "p"] for i in ["o", "p"])): sys.stdout.write("Invalid object.") else: add_to_map2(req, size_x, size_y, obstacle_list, pedestrian_list) else: speed_range_or_not = int(input("\nPlease type 0 for giving a speed range for whole pedestrians. Please note that speed will be assigned randomly. Else, type 1 to provide speed manually.\n")) if not speed_range_or_not: lower = float(input("Please provide a lower limit for speed.\n")) upper = float(input("Please provide a upper limit for speed.\n")) sys.stdout.write( "\nPlease indicate the location of obstacles OR pedestrians as stated below, with locations, from " "0 until cell size you provided (that is excluded.)\n\nFor obstacles: 'o x y'" ", where x and y indicate the x and y coordinate locations.\nFor pedestrians: 'p x y', where x and " "y indicate the x and y coordinate locations.\n\n" "If you want to add objects from txt file, please write 'text' and the name of the file as 'example.txt'\n\n" "When you are done, please write 'exit'\n\n") obstacle_list = [] pedestrian_list = [] while True: req = input("Please enter the request.") req.strip() if req == "exit": sys.stdout.write("\n") break elif req == "text": read_from_file(pedestrian_list, obstacle_list, size_x, size_y, 3, lower, upper) elif not(any(i in ["o", "p"] for i in ["o", "p"])): sys.stdout.write("Invalid object.") else: add_to_map3(req, size_x, size_y, obstacle_list, pedestrian_list, lower, upper) else: sys.stdout.write( "\nPlease indicate the location of obstacles OR pedestrians as stated below, with locations, from " "0 until cell size you provided (that is excluded.)\n\nFor obstacles: 'o x y'" ", where x and y indicate the x and y coordinate locations.\nFor pedestrians: 'p x y s', where x and " "y indicate the x and y coordinate locations and s indicates the speed.\n\n" "If you want to add objects from txt file, please write 'text' and the name of the file as 'example.txt'\n\n" "When you are done, please write 'exit'\n\n") obstacle_list = [] pedestrian_list = [] while True: req = input("Please enter the request.") req.strip() if req == "exit": sys.stdout.write("\n") break elif req == "text": read_from_file(pedestrian_list, obstacle_list, size_x, size_y, 4) elif not(any(i in ["o", "p"] for i in ["o", "p"])): sys.stdout.write("Invalid object.") else: add_to_map4(req, size_x, size_y, obstacle_list, pedestrian_list) init_simulation(time, size_x, size_y, pedestrian_list, obstacle_list, target, rmax, mode, speed_or_not)
global red,blue,green, dt, yPlane, head, ball, target, cannon, curRadius, minRadius, maxRadius, maxAccel, cannonL, maxcannonL, mincannonL, angel1, angel2, bbx red=float(1.0) blue=float(1.0) green=float(1.0) dt = float(0.065) yPlane = float(-4) #head = None cannon = Vector3d(0,0,0) ball = Ball() allBalls = [] # a singular target target = Target() # cannon position # ball radius curRadius = float(0.6); minRadius = float(0.2); maxRadius = float(1.4); # maximum acceleration maxAccel = float(850); # cannon length cannonL = float(0.5); maxCannonL = float(1.5); minCannonL = float(0.25); # angle1 for rotating cannon angle1 = float(45.0); angle2 = float(165.0);
for i in range(len(green_lasers)): green_lasers[i].drawLaser(color1, img) purple_lasers, frame = LaserFire.laserFire(team2_laser_start, 20, 0.2, mirrorBLockerList, frame) for i in range(len(purple_lasers)): purple_lasers[i].drawLaser(color2, img) # Activate the target. Should return the team that scored as well as the amount of points scored. # Initialize a target when there's less than 2 and the game is still running. while targetCount < 2 and totalPointCount < maxPoints: totalPointCount += 1 targetCount += 1 x = np.random.randint(cropXLeft, width-cropXRight) y = np.random.randint(cropYTop, height-cropYbottom) if totalPointCount is specialTarget: temp_target = Target.Target(True, x, y) targetArray.append(temp_target) else: temp_target = Target.Target(False, x, y) targetArray.append(temp_target) # Call the targetCollision function. for i in range(len(targetArray)): green_collision, green_doublePoints = targetArray[i].targetCollision(green_lasers) purple_collision, purple_doublePoints = targetArray[i].targetCollision(purple_lasers) # should check if there is collision and what team has achieved it. Then checks how many points they scored. if green_collision: if green_doublePoints: team1.addDoublePoints() else: team1.addPoint()
def setUp(self): # self.arch = Architecture("AVR8") self.target = Target("MyBoard")
targetMatch = target # Check if a target match was found if targetMatch == None: sys.exit(error['target not matched'] % designXML.design.target.getText()) else: print "Target file %s.xml found!" % designXML.design.target.getText() # Check the design has recipes if designXML.design.recipe == None: sys.exit(error['no recipe tag']) else: print "Validating design..." # Create the model of the target targetModel = Target.Target(designXML.design.target.getText()) targetModel.parseXML(targetMatch) recipes = [] # Validate the design by checking the pins in the design exist on the target and that the recipies exist for recipe in designXML.findAll('recipe'): # Check the recipe exists recipeSource = glob.glob(dir_Recipes + '/' + recipe['name'] + '*.c') recipeHeader = glob.glob(dir_Recipes + '/' + recipe['name'] + '*.h') recipeXML = glob.glob(dir_Recipes + '/' + recipe['name'] + '*.xml') # Print an error if it doesn't, otherwise add it to the list of source files if len(recipeSource) != 1 or len(recipeHeader) != 1 or len(recipeXML) != 1: sys.exit(error['recipe not found'] % recipe['name'])
radarDisplay = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption('Radar Screen') #GPIO setup RangerRead = GroveUltrasonicRanger(5) # targets list targets = {} a = 0 #radar read and write to dict while True: for angle in range(0, 180): distance = RangerRead.get_distance() distance = round(distance, 2) if distance != -1 and distance <= 50: targets[angle] = Target(angle, distance) draw(radarDisplay, targets, angle, distance, fontRenderer, screen_width, screen_height) time.sleep(0.0001) #draw_bck(radarDisplay, fontRenderer, screen_width, screen_height) targets = {} for angle in range(180, 0, -1): distance = RangerRead.get_distance() distance = round(distance, 2) if distance != -1 and distance <= 50: targets[angle] = Target(angle, distance) draw(radarDisplay, targets, angle, distance, fontRenderer, screen_width, screen_height)