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


Python Map.fillMap90方法代码示例

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


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

示例1: Map

# 需要导入模块: import Map [as 别名]
# 或者: from Map import fillMap90 [as 别名]
class AI:
	room = Map([])
	movement = Move()
	sensor = Sensor()
	botAngle = 0
	botPos = [0,0]
    
	turnAngle  = 15 # the angle the bot will turn to sense
	'''
	def mapRoom(self):
		if 
		
		while not room.isMapped():
			sense()
			route = room.nextRoute()
			for i in route:
				break
			break
		return
	'''
	def __init__(self, port = 13000, host = "localhost"):
		"""
			This function has two objects right now
			move will control the movement of the pibot
			com controls the communication.
			Basically the AI gets information from the sensors (Maybe thats a class aswell?)
			does its AI stuff, calls move to move the bot and calls com to update the laptop
		"""
		self.move = Move()
		self.room = Map([[0,0]])
		self.com = Com(port = port, host = host)
	def sense(self):
		"""
			This function is a temp function it just takes in input from the user
			The user can send a message to the laptop or update the map (the map right now is
			just a X Y coordination)
			This entire function will be replaced its just for testing
		"""
		points = list()
		for i in range(360/self.turnAngle):
			if self.botAngle ==0:
				points.insert(0,[self.sensor.getDistance(),self.botAngle])
			elif self.botAngle == 90:
				points.insert(1,[self.sensor.getDistance(),self.botAngle])
			elif self.botAngle == 180:
				points.insert(2,[self.sensor.getDistance(),self.botAngle])
			elif self.botAngle == 270:
				points.insert(3,[self.sensor.getDistance(),self.botAngle])
			else:
				points.append([self.sensor.getDistance(),self.botAngle])
			self.movement.turn(self.turnAngle)
			self.botAngle = self.botAngle+self.turnAngle
			time.sleep(1)
			if self.botAngle >= 360:
				self.botAngle = self.botAngle-360
				#self.movement.turn(self.turnAngle)
				#self.botAngle = self.botAngle+self.turnAngle
			
				#break
			#if self.botAngle == 0:
			#	break
		return points

	def mapRoom90(self):
		self.turnAngle = 90
		while(not self.room.isMapped()):
			points = self.sense()
			self.botPos = self.room.updateMap(points)
			self.room.fillMap90()
			nextDir = self.room.nextRoute90()
			if nextDir=="U":
				if self.botAngle!=0:
					self.movement.turn(360-self.botAngle)
					self.botAngle=0
				self.movement.move(MAXVIEW-20)
				self.botPos[0]=self.botPos[0]-MAXVIEW+20
				self.room.updatePos(self.botPos)
			elif nextDir=="D":
				if self.botAngle!=180:
					self.movement.turn(180-self.botAngle)
					self.botAngle=180
				self.movement.move(MAXVIEW-20)
				self.botPos[0]=self.botPos[0]+MAXVIEW-20
				self.room.updatePos(self.botPos)
			elif nextDir=="R":
				if self.botAngle!=90:
					self.movement.turn(90-self.botAngle)
					self.botAngle=90
				self.movement.move(MAXVIEW-20)
				self.botPos[1]=self.botPos[1]+MAXVIEW-20
				self.room.updatePos(self.botPos)
			elif nextDir=="L":
				if self.botAngle!=270:
					self.movement.turn(270-self.botAngle)
					self.botAngle=270
				self.movement.move(MAXVIEW-20)
				self.botPos[1]=self.botPos[1]-MAXVIEW+20
				self.room.updatePos(self.botPos)
			elif nextDir == None:
				self.room.showRoom()
#.........这里部分代码省略.........
开发者ID:stevenkaza,项目名称:GroupSixBot,代码行数:103,代码来源:AI.py


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