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


Python BZRC.get_flags方法代码示例

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


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

示例1: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_flags [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))

	agent = BritAgent(bzrc)

	prev_time = time.time()

	# Run the agent
	try:
		
		flags = bzrc.get_flags()
		
		print flags[0].color
		
	except KeyboardInterrupt:
		print "Exiting due to keyboard interrupt."
		bzrc.close()
开发者ID:Altair3,项目名称:Tanks,代码行数:30,代码来源:britAgent.py

示例2: __init__

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_flags [as 别名]
	def __init__(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), debug=True)
		__bzrc__ = BZRC(host, int(port))
		
		realobs = __bzrc__.get_obstacles()
		enemies = __bzrc__.get_othertanks()
		bases = __bzrc__.get_bases()
		flags = __bzrc__.get_flags()

		AGENT = Agent(__bzrc__)
		
		
		plotter = Plot()
		
		plotter.plotToFile(realobs)
		
		plotter.appendToFile(flags, enemies)
		
		self.obstacles = __bzrc__.get_obstacles()
		self.mytanks = __bzrc__.get_mytanks()
		self.othertanks = __bzrc__.get_othertanks()
		self.flags = __bzrc__.get_flags()
		self.bases = __bzrc__.get_bases()
		self.enemycolors = []
		for tank in othertanks:
			if tank.color not in self.enemycolors:
				self.enemycolors.append(tank.color)
		
		vector = self.get_vector(0, 0)
		
		#s = raw_input(tanks)
		
		#plotter.plotToFile(plotter.draw_points(flags, "flags"))
		
		plotter.animate(realobs)
开发者ID:itcropper,项目名称:tanks,代码行数:47,代码来源:potentialFields.py

示例3: main

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_flags [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))

    agent = Agent(bzrc)
    prev_time = time.time()

    start = bzrc.get_mytanks()[0]
    goal = next(flag for flag in bzrc.get_flags() if flag.color == 'green')

    agent.init_screen()
    agent.refresh_screen()

    #agent.test_occgrid()
    #agent.uniform_search(start, goal)
    #agent.greedy_search(start, goal)
    # agent.depth_first(start, goal)
    #agent.breadth_first(start, goal)
    #agent.iterative_search(start, goal)
    
    path = agent.run(5)
    for i in range(len(path)):
        if i < len(path) - 1:
            print "set arrow from", str(path[i][0]) + ', ' + str(path[i][1]), "to ", str(path[i + 1][0]) + ', ' + str(path[i + 1][1]), "as 2"
    print "plot NaN notitle"
    
    #print time.time() - prev_time
    return

    
    

    # 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:itcropper,项目名称:tanks,代码行数:52,代码来源:displaypathfindingagent.py

示例4: Grid

# 需要导入模块: from bzrc import BZRC [as 别名]
# 或者: from bzrc.BZRC import get_flags [as 别名]
class Grid():

	def __init__(self, port):

		self.bzrc = BZRC("localhost", int(port))
		self.grid = self.bzrc.get_occgrid(0)

		#print self.grid

		
		self.height = len(self.grid[1])
		self.width  = len(self.grid[1][3])

		self.bottom = int(self.grid[0][0])
		self.top = self.bottom + self.height

		self.left = int(self.grid[0][0])
		self.right = self.left + self.width

		# print "Left: " , self.left
		# print 'Right: ', self.right
		# print 'Top: ', self.top
		# print 'Bottom: ', self.bottom


		#print self.height, self.width

		self.number_grid = self.grid[1:][0]

		#print self.number_grid

		self.grid = []

		self.goal =  (int(self.bzrc.get_flags()[2].x), int(self.bzrc.get_flags()[2].y))
		# print "Goal: ", self.goal
		self.start = (int(self.bzrc.get_mytanks()[0].x), int(self.bzrc.get_mytanks()[0].y))
		# print "START: " , self.start


	'''
	@param goal: tuple(x, y)
	@returns grid of cell objects
	'''
	def get_grid(self):

		xList = []
		
		for x in range(self.height):
			#g = raw_input(self.number_grid[y])
			yList = []

			for y in range(self.width):

				reachable = True

				if self.number_grid[x][y] == 1:
					reachable = False
				else:
					reachable = True
					#print "reachable at: " + str(x) + " : " + str(y)

				cell = Cell(self.left + x, self.bottom + y, reachable, self.distance(self.left + x, self.right + y, self.goal))
				
				if (self.left + x, self.top + y) == self.goal:
					cell.end = True

				#s = raw_input("Goal Location: " + str(x + self.left) + " : " + str(y + self.bottom) + " : " + str(self.number_grid[y][x]))

				yList.append(cell)


			xList.append(yList)

		#print len(yList), len(xList)

		self.grid = xList

		return y
				
	def distance(self, x, y, goal):
		return math.sqrt((abs(x - goal[0])**2 + (abs(y - goal[1])**2)))

	def get_cell(self, x, y):

		x = int(x + self.right)
		y = int(y + self.top)

		#print "Get Cell: ", x, y

		try:
			return self.grid[x][y]
		except(IndexError):
			print "Max is: " + str(len(self.grid)) + ", " + str(len(self.grid[0]))
			print "Error on: Index: " + str(x) + ", " + str(y)
			sys.exit(0)

	def get_cell_tuple(self, xy):
		x = int(xy[0] + self.right)
		y = int(xy[1] + self.top)

#.........这里部分代码省略.........
开发者ID:itcropper,项目名称:tanks,代码行数:103,代码来源:occGrid.py


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