当前位置: 首页>>代码示例>>Python>>正文


Python bzrc.BZRC类代码示例

本文整理汇总了Python中bzrc.BZRC的典型用法代码示例。如果您正苦于以下问题:Python BZRC类的具体用法?Python BZRC怎么用?Python BZRC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BZRC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    # Process CLI arguments.
    try:
        execname, host, port, foodSupply = 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))

    gridPlotter = GridFilter()
    cc = CommandCenter(bzrc, foodSupply,gridPlotter)
    gridPlotter.init_window(800, 800,cc.tick)

    prev_time = time.time()

    # Run the agent
    try:
        while True:
            time_diff = time.time() - prev_time
            action = threading.Thread(target =cc.tick, args=[time_diff])
            action.start()
            action.join()
    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        bzrc.close()
开发者ID:VanWardawg,项目名称:BZRFlag,代码行数:30,代码来源:TerranAgent.py

示例2: main

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))
    
    gridVisualizer = GridFilter(-400,800,-400,800,0.9,0.97)
    
    agent = Agent(bzrc)

    prev_time = time.time()

    # Run the agent
    try:
        gridVisualizer.init_window(801, 801)
        while True:
            time_diff = time.time() - prev_time
            gridVisualizer = agent.tick(time_diff, gridVisualizer)
            if (time_diff >= 1):
                gridVisualizer.update_grid()
                gridVisualizer.draw_grid()
                prev_time = time.time()
    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        bzrc.close()
开发者ID:okiobe,项目名称:bzflag470,代码行数:33,代码来源:testAgent.py

示例3: main

 def main(self):
     
     # 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))
     mytanks = bzrc.get_mytanks()
     for i in range(len(mytanks)):
         if i < 8:
             if i < 5:
                 self.tanks.append(SuperUberAgent(bzrc,mytanks[i],"a"))
             else:
                 self.tanks.append(SuperUberAgent(bzrc,mytanks[i],"d"))  
         else:
             self.tanks.append(BayesAgent(bzrc,mytanks[i],self.grid, self.obsList))
     
        
     try:
         while True:
             self.tick(self.tanks,bzrc)
            
     except KeyboardInterrupt:
         print "Exiting due to keyboard interrupt."
         bzrc.close()
开发者ID:Altair3,项目名称:Tanks,代码行数:32,代码来源:Driver.py

示例4: main

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))

    agent = Agent(bzrc)

    prev_time = time.time()
    # thread = threading.Thread(target=init_window, args=(int(800),int(800)))
    # thread.start()
    init_window(int(800),int(800))
    # Run the agent
    try:
        while True:
            time_diff = time.time() - prev_time
            agent.tick(time_diff)
            draw_grid(time_diff > 10)
            if time_diff > 10:
                prev_time = time.time()
    except (KeyboardInterrupt, SystemExit):
        print "Exiting due to keyboard interrupt."
        bzrc.close()
        draw_grid(True)
开发者ID:brainwood-school,项目名称:cs470,代码行数:32,代码来源:agentBayesFilter.py

示例5: main

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))
    agent = PFAgent(bzrc)
    agent.tick()

    plot_single(agent.calculate_obstacles_force, agent.obstacles, 'obstacles.png')
    plot_single(agent.calculate_goal_force, agent.obstacles, 'goal.png')
    plot_single(agent.calculate_random_force, agent.obstacles, 'random.png')
    plot_single(agent.calculate_tangential_force, agent.obstacles, 'tangential.png')

    plot_single(agent.get_forces_on_tank, agent.obstacles, 'combined.png')

    print("finished")
    bzrc.close()
开发者ID:thyer,项目名称:CS470,代码行数:25,代码来源:show_field.py

示例6: main

def main():
    # Process CLI arguments.
    try:
        execname, host, port, mode = sys.argv
    except ValueError:
        execname = sys.argv[0]
        print >>sys.stderr, '%s: incorrect number of arguments' % execname
        print >>sys.stderr, 'usage: %s hostname port [sit|const|wild]' % sys.argv[0]
        sys.exit(-1)

    bzrc = BZRC(host, int(port))
    cur_time = time.time()
    
    agent = PigeonAgent(bzrc, mode, cur_time)

    # Run the agent
    try:
        
        while True:
            cur_time = time.time()
            agent.behave(cur_time)
            
                    
                
    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        agent.stop()
        bzrc.close()
开发者ID:Altair3,项目名称:Tanks,代码行数:28,代码来源:PigeonAgent.py

示例7: main

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()
开发者ID:lwthatcher,项目名称:CS-470,代码行数:31,代码来源:grid_agent_02.py

示例8: main

def main():
    # Process CLI arguments.
    try:
        #noise needs to be passed into the necessary functions
        execname, host, port, psi, noise = sys.argv
    except ValueError:
        execname = sys.argv[0]
        print >>sys.stderr, '%s: incorrect number of arguments' % execname
        print >>sys.stderr, 'usage: %s hostname port psi noise' % sys.argv[0]
        sys.exit(-1)

    # Connect.
    #bzrc = BZRC(host, int(port), debug=True)
    gridPlotter = GridFilter()
    bzrc = BZRC(host, int(port))
    nexus = Nexus(bzrc, int(psi), int(noise),gridPlotter)
    gridPlotter.init_window(800, 800,nexus.tick)

    prev_time = time.time()

    # Run the agent
    try:
        while True:
            time_diff = time.time() - prev_time
            action = threading.Thread(target =nexus.tick, args=[time_diff])
            action.start()
            action.join()
    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        bzrc.close()
开发者ID:VanWardawg,项目名称:BZRFlag,代码行数:30,代码来源:ProtossAgent.py

示例9: main

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))

    agent = basicAgent(bzrc)

    init_window(800,800)
    # Run the agent
    try:
        tickCounter = 0
        prev_time = time.time()
        while True:
            time_diff = time.time() - prev_time
            prev_time = time.time()
            agent.tick(time_diff)
            if tickCounter % 10 == 0:
                draw_grid()
                update_grid(numpy.array(zip(*agent.beliefMap)))
                #update_grid(numpy.array(agent.beliefMap))
            tickCounter = tickCounter + 1
    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        bzrc.close()
开发者ID:bweaver2,项目名称:bzrFlag,代码行数:33,代码来源:basicAgent.py

示例10: main

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))

    # Create our army
    agents = []
    index = 0
    for tank in range(len(bzrc.get_mytanks())):
        agent = StraightLineAgent(bzrc, index)
        agents.append(agent)
        index += 1

    # Run the agent
    try:
        while True:
            for agent in agents:
                agent.tick()

    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        bzrc.close()
开发者ID:thyer,项目名称:CS470,代码行数:31,代码来源:StraightLineAgent.py

示例11: main

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))

    agent = Agent(bzrc)

    prev_time = time.time()

    # Run the agent
    try:

        # initialize all the tanks to 'not turning'
        mytanks = bzrc.get_mytanks()
        for tank in mytanks:
            print tank.index
            agent.angleset.append(False)
            agent.startangle.append(0)

        while True:
            time_diff = time.time() - prev_time
            prev_time += time_diff
            agent.tick(time_diff)
    except KeyboardInterrupt:
        print "Exiting due to keyboard interrupt."
        bzrc.close()
开发者ID:lwthatcher,项目名称:CS-470,代码行数:35,代码来源:dumbagent.py

示例12: main

def main():
    # Process CLI arguments.
    try:
        execname, host, port, use_penalized_mode = sys.argv
    except ValueError:
        execname = sys.argv[0]
        print >> sys.stderr, "%s: incorrect number of arguments" % execname
        print >> sys.stderr, "usage: %s hostname port enablepenalties" % sys.argv[0]
        sys.exit(-1)

    # Connect.
    # bzrc = BZRC(host, int(port), debug=True)
    bzrc = BZRC(host, int(port))

    use_penalized_mode = use_penalized_mode == "1"  # convert into a boolean
    print "use_penalized_mode is %d" % use_penalized_mode
    agent = Agent(bzrc, use_penalized_mode)

    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()
开发者ID:swesonga,项目名称:cs470,代码行数:28,代码来源:multi_agent_search.py

示例13: main

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()
开发者ID:thyer,项目名称:CS470,代码行数:34,代码来源:KalmanFilterAgent.py

示例14: main

def main():
	# Process CLI arguments.
	try:
		execname, host, port, search = 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))

	if search == 'b':
		agent = VisibilityGraphAgent(bzrc, BreadthFirstSearch(False))
	elif search == 'd':
		agent = VisibilityGraphAgent(bzrc, DepthFirstSearch(False))
	elif search == 'a':
		agent = VisibilityGraphAgent(bzrc, AStarSearch(False))
	else:
		print >>sys.stderr, 'bad search value. must be a d or b'
		sys.exit(-1)

	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()
开发者ID:Seiji42,项目名称:cs-470-labs,代码行数:35,代码来源:VisibilityGraphAgent.py

示例15: main

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))

    agent = Agent(bzrc)

    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()
开发者ID:mikebcurtis,项目名称:bzrflag,代码行数:26,代码来源:dumbagent.py


注:本文中的bzrc.BZRC类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。