亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? astarlibrary - demo 5.bb

?? A STAR 算法源碼, 比較初級的算法, 適合初學的朋友研究
?? BB
?? 第 1 頁 / 共 3 頁
字號:
			For x = 1 To numberOfOpenListItems ;look for the item in the heap
			If openX(openList(x)) = a And openY(openList(x)) = b Then ;item found
				FCost(openList(x)) = Gcost(a,b) + HCost(openList(x)) ;change the F cost
				
				;See if changing the F score bubbles the item up from it's current location in the heap
				m = x
				While m <> 1 ;While item hasn't bubbled to the top (m=1)	
					;Check if child is < parent. If so, swap them.	
					If Fcost(openList(m)) < Fcost(openList(m/2)) Then
						temp = openList(m/2)
						openList(m/2) = openList(m)
						openList(m) = temp
						m = m/2
					Else
						Exit ;while/wend
					End If
				Wend 
				
				Exit ;for x = loop
			End If ;If openX(openList(x)) = a
			Next ;For x = 1 To numberOfOpenListItems

		End If ;If tempGcost < Gcost(a,b) Then			

	End If ;If not already on the open list				
	End If ;If corner = walkable
	End If ;If not occupied by a stopped unit
	End If ;If not an adjacent, temporarily unwalkable node
	End If ;If not a wall/obstacle cell.	
	End If ;If not already on the closed list	
	End If ;If not off the map.	
	Next
	Next

;9.	If open list is empty then there is no path.	
	Else
		path = nonExistent : Exit
	End If

;10.	Check to see if desired target has been found.
	If mode = normal  ;exit when target is added to open list.
		If whichList(targetX,targetY) = onOpenList Then path = found : Exit	
	Else If mode = randomMove 
		If Gcost(parentXval,parentYVal) > 20 + Rand(20)
			targetX = parentXval : targetY = parentYval 
			path = found : Exit		
		End If		
	End If		

	Forever ;repeat until path is found or deemed nonexistent
	
	
;11.	Save the path if it exists. Copy it to a bank. 
	If path = found
		
		;a. Working backwards from the target to the starting location by checking
		;each cell's parent, figure out the length of the path.
		pathX = targetX : pathY = targetY	
		Repeat
			tempx = parentX(pathX,pathY)		
			pathY = parentY(pathX,pathY)
			pathX = tempx
			unit\pathLength = unit\pathLength + 1	
		Until pathX = startX And pathY = startY
	
		;b. Resize the data bank to the right size (leave room to store step 0,
		;which requires storing one more step than the length)
		ResizeBank unit\pathBank,(unit\pathLength+1)*4

		;c. Now copy the path information over to the databank. Since we are
		;working backwards from the target to the start location, we copy
		;the information to the data bank in reverse order. The result is
		;a properly ordered set of path data, from the first step to the
		;last.	
		pathX = targetX : pathY = targetY				
		cellPosition = unit\pathLength*4 ;start at the end	
		While Not (pathX = startX And pathY = startY)			
			PokeShort unit\pathBank,cellPosition,pathX ;store x value	
			PokeShort unit\pathBank,cellPosition+2,pathY ;store y value	
			cellPosition = cellPosition - 4 ;work backwards		
			tempx = parentX(pathX,pathY)		
			pathY = parentY(pathX,pathY)
			pathX = tempx
		Wend	
		PokeShort unit\pathBank,0,startX ;store starting x value	
		PokeShort unit\pathBank,2,startY ;store starting y value

		;Record the path's cost. This is used by ClaimNodes().
		gPathCost = Gcost(targetX,targetY)

	End If ;If path = found Then 

;12. Return info on whether a path has been found.
	Return path; Returns 1 if a path has been found, 2 if no path exists. 

;13.If there is no path to the selected target, set the pathfinder's
	;xPath and yPath equal to its current location and return that the
	;path is nonexistent.
	.noPath
	unit\xPath = startingX
	unit\yPath = startingY
	Return nonexistent

End Function
	

;==========================================================
;READ PATH DATA: These functions read the path data and convert
;it to screen pixel coordinates.
Function ReadPath(unit.unit)			
	unit\xPath = ReadPathX(unit.unit,unit\pathLocation)
	unit\yPath = ReadPathY(unit.unit,unit\pathLocation)
End Function

Function ReadPathX#(unit.unit,pathLocation)
	If pathLocation <= unit\pathLength
		x = PeekShort (unit\pathBank,pathLocation*4)
		Return tileSize*x + .5*tileSize ;align w/center of square	
	End If
End Function	

Function ReadPathY#(unit.unit,pathLocation)
	If pathLocation <= unit\pathLength
		y = PeekShort (unit\pathBank,pathLocation*4+2)
		Return tileSize*y + .5*tileSize ;align w/center of square		
	End If
End Function


;==========================================================
;COLLISION/NODE CLAIMING FUNCTIONS: These functions handle node claiming
;and collision detection (which occurs when a unit tries to claim a node that
;another unit has already claimed).

;This function checks whether the unit is close enough to the next
;path node to advance to the next one or, if it is the last path step,
;to stop.
Function CheckPathStepAdvance(unit.unit)	
	
	;If starting a new path ...
	If unit\pathLocation = 0			
		If unit\pathLength > 0 
			unit\pathLocation = unit\pathLocation+1
			ClaimNodes(unit.unit)
			ReadPath(unit) ;update xPath and yPath
		Else If unit\pathLength = 0			
			ReadPath(unit) ;update xPath and yPath
			If unit\xLoc = unit\xPath And unit\yLoc = unit\yPath
				unit\pathStatus = notstarted
				ClearNodes(unit.unit)							
			End If
		End If		
	
	;If reaching the next path node.		
	Else If unit\xLoc = unit\xPath And unit\yLoc = unit\yPath
		If unit\pathLocation = unit\pathLength 
			unit\pathStatus = notstarted
			ClearNodes(unit.unit)	
		Else
			unit\pathLocation = unit\pathLocation + 1
			ClaimNodes(unit.unit)
			ReadPath(unit) ;update xPath and yPath		
		End If	
	End If
			
End Function

;This function claims nodes for a unit. It is called by CheckPathStepAdvance().
Function ClaimNodes(unit.unit)
		
	;Clear previously claimed nodes and claim the node the unit is currently occupying.
	ClearNodes(unit.unit)
	
	;Check next path node for a collision.
	unit\unitCollidingWith.unit = DetectCollision(unit.unit)	
	
	;If no collision is detected, claim the node and figure out
	;the distance to the node.
	If unit\unitCollidingWith = Null		
		x2 = PeekShort (unit\pathBank,unit\pathLocation*4)
		y2 = PeekShort (unit\pathBank,unit\pathLocation*4+2)	
		claimedNode(x2,y2) = unit	
		ReadPath(unit.unit) ;update xPath/yPath			
		unit\distanceToNextNode = GetDistance#(unit\xLoc,unit\yLoc,unit\xPath,unit\yPath)	
	
	;Otherwise, if a collision has been detected ...
	Else		
					
		;If node is occupied by a unit not moving normally, repath.
		If unit\unitCollidingWith\pathStatus = stopped		
			unit\pathStatus = FindPath(unit.unit,unit\targetX,unit\targetY)					

		;If there is a pending collision between the two units, repath.
		Else If UnitOnOtherUnitPath(unit.unit,unit\unitCollidingWith)
			unit\pathStatus = FindPath(unit.unit,unit\targetX,unit\targetY)	

		;If the pending collision is not head-on, repathing is optional. Check
		;to see if repathing produces a short enough path, and if so, use it.
		;Otherwise, tempStop.
		Else If gDiagonalBlockage = False					
			pathLength = unit\pathLength ;save current path stats
			pathLocation = unit\pathLocation ;save current path stats	
			currentPathBank = unit\pathBank ;save current path stats
			currentPathCost = RemainingPathCost(unit)	
			If unit\pathBank = unit\pathBank1 ;switch the pathBank
				unit\pathBank = unit\pathBank2
			Else
				unit\pathBank = unit\pathBank1
			End If
			unit\pathStatus = FindPath(unit.unit,unit\targetX,unit\targetY) ;check the path
			
			;Is resulting path nonexistent or too long? Then reset back to the
			;original path info saved above and tempStop. Otherwise, the path 
			;just generated will be used.
			If unit\pathStatus = nonexistent Or gPathCost > currentPathCost+35
				unit\pathLength = pathLength
				unit\pathLocation = pathLocation 	
				unit\pathBank = currentPathBank 
				unit\pathStatus = tempStopped									
			End If
			
		;If the pending collision is with a unit crossing diagonally right in
		;front of the unit, then tempStop.	This global variable is set by
		;the DetectCollision() function.	
		Else If gDiagonalBlockage = True	
			unit\pathStatus = tempStopped											
		End If
				
	End If
		
End Function

;This function calculates the remaining cost of the current path. This
;is used by the ClaimNodes() function to compare the unit's current
;path to a possible new path to determine which is better.
Function RemainingPathCost(unit.unit)
	lastX = Floor(unit\xLoc/tileSize)
	lastY = Floor(unit\yLoc/tileSize)
	For pathLocation = unit\pathLocation To unit\pathLength
		currentX = PeekShort (unit\pathBank,pathLocation*4)
		currentY = PeekShort (unit\pathBank,pathLocation*4+2)		
		If lastX<>currentX And lastY<>currentY 
			pathCost = pathCost+14 ;cost of going to diagonal squares	
		Else	
			pathCost = pathCost+10 ;cost of going to non-diagonal squares				
		End If
		lastX = currentX : lastY = currentY		
	Next
	Return pathCost
End Function

;This function clears a unit's claimed nodes. This function is
;called principally by ClaimNodes() before new nodes are
;claimed. It is also called by CheckPathStepAdvance() when the 
;final path node is reached and by LaunchProgram() to initialize
;each unit's initial location.
Function ClearNodes(unit.unit)
	x = Floor(unit\xLoc/tileSize) : y = Floor(unit\yLoc/tileSize)
	For a = x-1 To x+1
	For b = y-1 To y+1
		If a>=0 And a<mapWidth And b>=0 And b<mapHeight
			If claimedNode(a,b) = unit Then claimedNode(a,b) = Null
		End If		
	Next
	Next
	claimedNode(x,y) = unit ;reclaim the one the unit is currently occupying.						
End Function

;This function checks to see if the next path step is free. 
;It is called from ClaimNodes() and by UpdatePath() when the
;unit is tempStopped.
Function DetectCollision.unit(unit.unit)
	gDiagonalBlockage = False	
	x2 = PeekShort (unit\pathBank,unit\pathLocation*4)
	y2 = PeekShort (unit\pathBank,unit\pathLocation*4+2)			
	If claimedNode(x2,y2) = Null	
		x1 = Floor(unit\xLoc/tileSize)
		y1 = Floor(unit\yLoc/tileSize)	
		If x1<>x2 And y1<>y2 ;if next path step is diagonal
			If claimedNode(x1,y2) <> Null			
				If claimedNode(x1,y2) = claimedNode(x2,y1)	
					gDiagonalBlockage = True				
					Return claimedNode(x1,y2)
				End If	
			End If								
		End If
	Else
		Return claimedNode(x2,y2)	
	End If	
End Function

;This function checks to see whether a unit is on another unit's 
;path. It is called by ClaimNodes().
Function UnitOnOtherUnitPath(unit.unit,otherUnit.unit)	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
老司机精品视频一区二区三区| 国产精品麻豆99久久久久久| 天堂va蜜桃一区二区三区漫画版| 欧美日韩久久一区| 婷婷久久综合九色综合绿巨人| 欧美日本在线播放| 精品亚洲国内自在自线福利| 久久午夜色播影院免费高清| 国产成人免费视频网站| 亚洲人成小说网站色在线| 色老综合老女人久久久| 日韩综合一区二区| 精品国产凹凸成av人导航| 国产成人精品www牛牛影视| 亚洲欧洲av在线| 337p亚洲精品色噜噜| 黄一区二区三区| 国产精品久久久久久久岛一牛影视| 成人av中文字幕| 亚洲风情在线资源站| 久久蜜桃av一区精品变态类天堂| 不卡在线视频中文字幕| 午夜精品福利一区二区三区av| 精品动漫一区二区三区在线观看| 波多野结衣一区二区三区 | 一本色道久久加勒比精品 | 91麻豆文化传媒在线观看| 亚洲国产精品一区二区www| 欧美成人欧美edvon| 色视频一区二区| 激情综合网av| 亚洲午夜精品在线| 日本一区二区三区免费乱视频| 在线国产电影不卡| 国产美女精品一区二区三区| 一区二区成人在线| 亚洲欧美一区二区久久| 91精品国产高清一区二区三区蜜臀| 国产曰批免费观看久久久| 亚洲综合在线免费观看| 久久综合中文字幕| 6080yy午夜一二三区久久| 成人免费视频视频| 久久国产综合精品| 亚洲国产欧美在线| 中文字幕亚洲区| 久久久亚洲国产美女国产盗摄 | 午夜久久电影网| 国产精品久久精品日日| 精品理论电影在线| 欧美福利视频导航| 91蝌蚪国产九色| 国产精品综合二区| 日韩中文字幕不卡| 亚洲黄色尤物视频| 亚洲三级电影全部在线观看高清| 欧美r级电影在线观看| 51久久夜色精品国产麻豆| 日本高清不卡视频| www.99精品| 国产91在线观看丝袜| 美国十次了思思久久精品导航| 午夜视频在线观看一区二区| 亚洲美女视频一区| 国产精品国产a| 久久精品综合网| 制服丝袜亚洲播放| 69堂精品视频| 777精品伊人久久久久大香线蕉| 欧美视频精品在线观看| 91久久精品一区二区| 精品国产成人在线影院| 日韩欧美不卡在线观看视频| 制服丝袜亚洲色图| 日韩午夜在线观看| 日韩精品中文字幕一区| 欧美精品一卡两卡| 91精品欧美久久久久久动漫| 欧美日韩精品一二三区| 欧美日韩成人在线一区| 欧美狂野另类xxxxoooo| 欧美日韩精品免费观看视频| 欧美另类久久久品| 日韩精品中午字幕| wwwwww.欧美系列| 国产精品天天看| 中文字幕一区日韩精品欧美| 亚洲精品一卡二卡| 亚洲成人动漫精品| 蜜臀av性久久久久av蜜臀妖精| 另类小说欧美激情| 国产精品99久久久久久有的能看 | 美日韩一区二区| 国产一区视频网站| 成人污视频在线观看| av一区二区三区在线| 91精彩视频在线观看| 欧美精品成人一区二区三区四区| 欧美一区二区网站| 国产清纯在线一区二区www| 精品国产乱子伦一区| 国产欧美一区二区精品性| 亚洲日本青草视频在线怡红院| 亚洲自拍偷拍九九九| 97精品超碰一区二区三区| 成人免费不卡视频| 欧洲av一区二区嗯嗯嗯啊| 91 com成人网| 久久久久久一二三区| 久久久久久久免费视频了| 最新热久久免费视频| 亚洲bt欧美bt精品777| 国产精品系列在线播放| 91免费视频观看| 日韩精品专区在线影院观看| 中文字幕在线不卡| 日韩av一区二区三区| 福利91精品一区二区三区| 欧美视频一区二区三区四区 | 欧美伊人久久大香线蕉综合69| 欧美日本国产一区| 日韩亚洲欧美中文三级| 国产精品青草综合久久久久99| 夜夜嗨av一区二区三区网页| 蜜桃一区二区三区在线| 一本大道综合伊人精品热热| 日韩欧美中文字幕一区| 一区二区三区精密机械公司| 国模一区二区三区白浆| 欧美日韩在线播| 中日韩av电影| 六月婷婷色综合| 91极品视觉盛宴| 日本一区二区三区在线观看| 日本伊人精品一区二区三区观看方式| 成人自拍视频在线观看| 欧美大黄免费观看| 亚洲国产成人91porn| 99久久99久久精品国产片果冻 | 国产suv一区二区三区88区| 欧美日韩精品欧美日韩精品| 综合欧美亚洲日本| 国产一区二区精品久久| 日韩一区二区三区观看| 亚洲午夜电影网| 91在线观看一区二区| 欧美精品一区二区久久婷婷| 婷婷综合另类小说色区| 日本丶国产丶欧美色综合| 日日欢夜夜爽一区| 色激情天天射综合网| 国产精品久久久久aaaa樱花 | 99这里只有精品| 中文欧美字幕免费| 久草精品在线观看| 日韩亚洲欧美一区| 久久精品国产久精国产| 3d成人动漫网站| 午夜精品福利一区二区三区蜜桃| 日本韩国一区二区三区视频| 亚洲欧美偷拍三级| 99精品久久只有精品| 综合亚洲深深色噜噜狠狠网站| 成人av网站大全| 中文字幕制服丝袜成人av| 国产成人免费视频网站| 国产喷白浆一区二区三区| 国产成人av自拍| 国产精品欧美一区喷水| 国产在线精品一区在线观看麻豆| 欧美一级一级性生活免费录像| 亚洲一区在线电影| 精品视频123区在线观看| 天堂av在线一区| 日韩三级av在线播放| 寂寞少妇一区二区三区| 久久影院电视剧免费观看| 国产福利视频一区二区三区| 国产精品高清亚洲| 日本精品裸体写真集在线观看| 依依成人综合视频| 欧美日韩色综合| 蜜桃免费网站一区二区三区 | 中文字幕一区二区三区四区 | 国产一区二区三区在线观看精品| 精品国产一区二区亚洲人成毛片| 久久99精品久久久久久国产越南 | 91视频一区二区三区| 一区二区在线免费观看| 欧美日韩视频专区在线播放| 日本美女视频一区二区| 日韩精品一区二区三区视频| 国产麻豆午夜三级精品| 亚洲三级免费观看| 欧美日本在线播放| 国产乱码精品一区二区三| **欧美大码日韩| 日韩一区二区在线观看视频| 国产成人免费av在线| 亚洲美女一区二区三区|