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

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

?? astarlibrary - demo 5.bb

?? 國外的一個A*算法演示
?? 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一区二区三区免费野_久草精品视频
国产精品久久午夜夜伦鲁鲁| 亚洲免费在线视频| 91女厕偷拍女厕偷拍高清| 免费视频一区二区| 日韩av一级电影| 精品一区二区三区的国产在线播放| 亚洲国产aⅴ天堂久久| 亚洲国产精品一区二区尤物区| 亚洲欧美一区二区三区极速播放| 1000精品久久久久久久久| 国产精品久久久久久久久晋中| 中文字幕亚洲电影| 亚洲你懂的在线视频| 亚洲精品视频观看| 石原莉奈一区二区三区在线观看 | 婷婷综合在线观看| 亚洲成人免费在线观看| 午夜精品福利一区二区三区蜜桃| 亚洲国产一区二区在线播放| 亚洲综合色丁香婷婷六月图片| 亚洲国产精品久久艾草纯爱| 免费观看一级特黄欧美大片| 国产一区二区主播在线| 97精品电影院| 欧美日本一区二区| 亚洲精品在线免费观看视频| 国产三级久久久| 亚洲视频一区二区免费在线观看| 一区二区三区免费观看| 视频一区二区欧美| 成人三级伦理片| 欧美中文字幕久久| 国产午夜精品理论片a级大结局| 亚洲免费在线观看| 日韩精品亚洲专区| 99视频精品全部免费在线| 欧美精品一级二级三级| 久久精品日韩一区二区三区| 一区二区三区在线视频观看58| 日本特黄久久久高潮| 国产suv一区二区三区88区| 91福利国产精品| 国产午夜精品福利| 日本视频一区二区| 色哟哟国产精品| 久久久国产一区二区三区四区小说 | 精品盗摄一区二区三区| 亚洲日本va午夜在线影院| 日本中文字幕一区二区视频| 91在线视频观看| 精品久久久久久无| 亚洲地区一二三色| jlzzjlzz亚洲女人18| 精品国产免费一区二区三区四区| 亚洲欧洲日产国码二区| 国产在线精品一区二区不卡了| 欧美日韩极品在线观看一区| 中文字幕在线不卡一区二区三区| 免费在线观看成人| 欧美日韩在线一区二区| 国产精品每日更新| 国产一区二区网址| 日韩片之四级片| 视频一区二区三区在线| 欧美丝袜第三区| 亚洲卡通动漫在线| 91丝袜美腿高跟国产极品老师 | 成人av动漫在线| 久久青草欧美一区二区三区| 狠狠色丁香久久婷婷综合_中| 91精品国产91综合久久蜜臀| 亚洲黄色av一区| 视频一区二区中文字幕| 中文字幕日韩欧美一区二区三区| 免费久久99精品国产| 欧美群妇大交群中文字幕| 亚洲最新在线观看| 日本道精品一区二区三区| 国产精品进线69影院| 波波电影院一区二区三区| 国产欧美日韩精品在线| 国产91精品露脸国语对白| 国产丝袜在线精品| 成人免费视频免费观看| 亚洲国产精品激情在线观看| 国产成人免费高清| 国产精品久久久久久久岛一牛影视| 成人午夜视频在线观看| 日韩理论片网站| 欧美视频你懂的| 日本伊人色综合网| 久久久久久久久免费| 成人高清视频在线| 亚洲色图另类专区| 欧美日本在线一区| 国产美女在线观看一区| 中文字幕的久久| 91麻豆精品在线观看| 亚洲妇女屁股眼交7| 日韩一区二区在线看| 国产在线播精品第三| 国产精品无人区| 欧美在线观看视频在线| 久久激情综合网| 国产精品成人一区二区三区夜夜夜| 99re8在线精品视频免费播放| 一区二区三区国产精华| 日韩一区二区三区视频在线| 丁香六月久久综合狠狠色| 亚洲欧美日韩国产成人精品影院| 欧美乱熟臀69xxxxxx| 国产一区二区在线观看免费 | 日韩毛片精品高清免费| 欧美一区二区在线播放| 不卡在线观看av| 亚洲aⅴ怡春院| 亚洲国产精品成人综合 | 中文字幕在线视频一区| 欧美色图在线观看| 国产一区二区在线免费观看| 一区二区三区精品在线| 国产亲近乱来精品视频| 欧美日韩久久一区| 北岛玲一区二区三区四区| 免费视频一区二区| 一区二区三区**美女毛片| 久久久精品免费网站| 欧美久久久久久蜜桃| 99v久久综合狠狠综合久久| 久久99久久99| 日韩中文字幕区一区有砖一区 | 最新不卡av在线| 久久亚洲精品国产精品紫薇| 在线成人av影院| 91丨国产丨九色丨pron| 国产成人一区在线| 激情五月激情综合网| 视频一区欧美精品| 亚洲成人自拍偷拍| 一区二区三区在线观看动漫| 中文字幕一区二区日韩精品绯色| www成人在线观看| 日韩精品在线网站| 91麻豆精品国产91| 欧美日本国产视频| 色就色 综合激情| 91在线国产观看| 91蝌蚪国产九色| 99国内精品久久| 99热在这里有精品免费| 91在线精品一区二区三区| 成人黄色av网站在线| 国产成人亚洲综合a∨婷婷图片| 麻豆国产91在线播放| 日本vs亚洲vs韩国一区三区二区 | 国产一区二区三区免费| 国内精品伊人久久久久av影院| 久久99精品久久久久久久久久久久| 日韩成人精品在线| 奇米色一区二区三区四区| 日本成人中文字幕| 国产资源在线一区| 国产成人99久久亚洲综合精品| 成人激情午夜影院| 99久久精品国产一区| 色综合久久久久网| 欧美视频在线一区二区三区| 欧美色成人综合| 日韩欧美国产wwwww| 精品电影一区二区| 国产精品免费丝袜| 亚洲女子a中天字幕| 丝袜亚洲另类欧美综合| 蜜乳av一区二区| 成人性色生活片| 在线看日本不卡| 日韩免费在线观看| 久久精品欧美一区二区三区不卡 | 激情综合色播五月| 丁香一区二区三区| 欧美羞羞免费网站| 精品久久久影院| 国产精品初高中害羞小美女文| 亚洲成年人影院| 精品一二三四在线| 91蜜桃视频在线| 日韩网站在线看片你懂的| 国产亚洲成年网址在线观看| 亚洲欧美激情小说另类| 麻豆精品新av中文字幕| 成人性色生活片免费看爆迷你毛片| 欧美少妇一区二区| 久久久99精品免费观看| 一区二区三区色| 国产最新精品免费| 色999日韩国产欧美一区二区| 欧美一级生活片| 亚洲美腿欧美偷拍| 国内成人自拍视频| 在线成人av网站|