本文整理汇总了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()
示例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()
示例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()
示例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()
示例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()