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


Python BZRC.get_constants方法代码示例

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


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

示例1: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_constants [as 别名]
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,代码行数:33,代码来源:grid_agent_02.py

示例2: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_constants [as 别名]
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()
开发者ID:okiobe,项目名称:bzflag470,代码行数:33,代码来源:straightPigeon.py

示例3: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_constants [as 别名]
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,代码行数:36,代码来源:KalmanFilterAgent.py

示例4: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_constants [as 别名]
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()
开发者ID:okiobe,项目名称:bzflag470,代码行数:48,代码来源:shootingAgent.py

示例5: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_constants [as 别名]
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()
开发者ID:thyer,项目名称:CS470,代码行数:45,代码来源:GridFilterAgent.py


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