def main(): # Process CLI arguments. try: execname, host, port = sys.argv except ValueError: execname = sys.argv[0] print >>sys.stderr, '%s: incorrect number of arguments' % execname print >>sys.stderr, 'usage: %s hostname port' % sys.argv[0] sys.exit(-1) # Connect. #bzrc = BZRC(host, int(port), debug=True) bzrc = BZRC(host, int(port)) bayes = Bayes() constants = bzrc.get_constants() bayes.self_not_obs_given_not_occ(float(constants['truenegative'])) bayes.set_obs_given_occ(float(constants['truepositive'])) agent = Agent(bzrc, bayes) prev_time = time.time() # Run the agent try: while True: time_diff = time.time() - prev_time agent.tick(time_diff) except KeyboardInterrupt: print "Exiting due to keyboard interrupt." bzrc.close()
def main(): # Process CLI arguments. try: execname, host, port = sys.argv except ValueError: execname = sys.argv[0] print >> sys.stderr, '%s: incorrect number of arguments' % execname print >> sys.stderr, 'usage: %s hostname port' % sys.argv[0] sys.exit(-1) # Connect. # bzrc = BZRC(host, int(port), debug=True) bzrc = BZRC(host, int(port)) # initialize the visualization stuff world_size = int(bzrc.get_constants()['worldsize']) viz = KalmanViz(world_size) # create our agent (just assume it's the first tank on our team) agent = KalmanFilterAgent(bzrc, 0, viz) prev_time = time.time() # Run the agent try: while True: time_diff = time.time() - prev_time prev_time = time.time() agent.tick(time_diff) except KeyboardInterrupt: print "Exiting due to keyboard interrupt." bzrc.close() viz.destroy()
def main(): # Process CLI arguments. try: execname, host, port = sys.argv except ValueError: execname = sys.argv[0] print >>sys.stderr, '%s: incorrect number of arguments' % execname print >>sys.stderr, 'usage: %s hostname port' % sys.argv[0] sys.exit(-1) # Connect. #bzrc = BZRC(host, int(port), debug=True) bzrc = BZRC(host, int(port)) constants = bzrc.get_constants() agent = Agent(bzrc) prev_tick = time.time() step = .001 # Run the agent try: while True: time_diff = time.time() - prev_tick if time_diff >= step: agent.tick(time_diff) prev_tick = time.time() except KeyboardInterrupt: print "Exiting due to keyboard interrupt." bzrc.close()
def main(): # Process CLI arguments. try: execname, host, port = sys.argv except ValueError: execname = sys.argv[0] print >>sys.stderr, '%s: incorrect number of arguments' % execname print >>sys.stderr, 'usage: %s hostname port' % sys.argv[0] sys.exit(-1) # Connect. # bzrc = BZRC(host, int(port), debug=True) bzrc = BZRC(host, int(port)) # initialize the visualization stuff world_size = int(bzrc.get_constants()['worldsize']) viz = KalmanViz(world_size) # create our agent (just assume it's the first tank on our team) agent = KalmanFilterAgent(bzrc, 0, viz) prev_time = time.time() # Run the agent try: while True: time_diff = time.time() - prev_time prev_time = time.time() agent.tick(time_diff) except KeyboardInterrupt: print "Exiting due to keyboard interrupt." bzrc.close() viz.destroy()
def main(): # Process CLI arguments. try: execname, host, port = sys.argv except ValueError: execname = sys.argv[0] print >>sys.stderr, '%s: incorrect number of arguments' % execname print >>sys.stderr, 'usage: %s hostname port' % sys.argv[0] sys.exit(-1) # Connect. #bzrc = BZRC(host, int(port), debug=True) bzrc = BZRC(host, int(port)) constants = bzrc.get_constants() agent = Agent(bzrc) prev_tick = time.time() vel_tick = time.time() viz_tick = time.time() calulateVel = False velStep = .25 vizStep = 1.0 step = .001 # Run the agent try: while True: newtime = time.time() time_diff = newtime - prev_tick vel_diff = newtime - vel_tick viz_diff = newtime - viz_tick if vel_diff >= velStep: calulateVel = True vel_tick = newtime if time_diff >= step: agent.tick(time_diff, calulateVel, velStep) prev_tick = newtime calulateVel = False if viz_diff >= vizStep: agent.updateVisualization() viz_tick = newtime except KeyboardInterrupt: print "Exiting due to keyboard interrupt." bzrc.close()
def main(): # Process CLI arguments. try: execname, host, port = sys.argv except ValueError: execname = sys.argv[0] print >>sys.stderr, '%s: incorrect number of arguments' % execname print >>sys.stderr, 'usage: %s hostname port' % sys.argv[0] sys.exit(-1) # Connect. # bzrc = BZRC(host, int(port), debug=True) bzrc = BZRC(host, int(port)) # Set up the occupancy grid and visualization world_size = int(bzrc.get_constants()['worldsize']) occupancy_grid = OccupancyGrid(world_size + 1, .97, .1, 50) viz = GFViz(occupancy_grid, world_size) # Create our army agents = [] index = 0 for tank in range(len(bzrc.get_mytanks())-5): agent = GridFilterAgent(bzrc, occupancy_grid, index) agents.append(agent) index += 1 # Run the agent try: counter = 0 while True: # TODO: While our occupancy grid isn't "good enough" for agent in agents: agent.tick() if counter % 10 == 0: viz.update_grid(occupancy_grid.get_grid()) counter += 1 # Our occupancy grid is "good enough", enter an eternal loop so the visualization will be visible viz.loop_eternally() except KeyboardInterrupt: print "Exiting due to keyboard interrupt." bzrc.close()