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

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

?? astarlibrary - demo 4b (time based).bb

?? A STAR 算法源碼, 比較初級的算法, 適合初學的朋友研究
?? BB
?? 第 1 頁 / 共 2 頁
字號:
;A* Pathfinder (Version 2.0) by Patrick Lester. Used by permission.
;==================================================================
;Last updated 03/22/04

;This version of the aStar library has been modified to handle 
;pathfinding around other units.

;An article describing A* and this code in particular can be found at:
;http://www.policyalmanac.org/games/aStarTutorial.htm

;If you want to use this AStar Library, you may do so free of charge so 
;long as the author byline (above) is retained. Thank you to CaseyC 
;at the Blitz Forums for suggesting the use of binary heaps for the open 
;list. Email comments and questions to Patrick Lester at 
;pwlester@policyalmanac.org.

;==========================================================
;DECLARE VARIABLES
.declareVariables

	;Adjust these variables to match your map dimensions
	Global tileSize = 50, mapWidth = 16, mapHeight = 12

	;Create needed arrays
	Dim walkability(mapWidth+1,mapHeight+1) ;array that holds wall/obstacle information	
	Dim openList(mapWidth*mapHeight+2) ;1 dimensional array holding ID# of open list items
	Dim whichList(mapWidth+1,mapHeight+1)  ;2 dimensional array used to record 
		;whether a cell is on the open list or on the closed list.
	Dim openX(mapWidth*mapHeight+2) ;1d array stores the x location of an item on the open list
	Dim openY(mapWidth*mapHeight+2) ;1d array stores the y location of an item on the open list
	Dim parentX(mapWidth+1,mapHeight+1) ;2d array to store parent of each cell (x)
	Dim parentY(mapWidth+1,mapHeight+1) ;2d array to store parent of each cell (y)
	Dim Fcost(mapWidth*mapHeight+2)	;1d array to store F cost of a cell on the open list
	Dim Gcost(mapWidth+1,mapHeight+1) 	;2d array to store G cost for each cell.
	Dim Hcost(mapWidth*mapHeight+2)	;1d array to store H cost of a cell on the open list		
	
	Dim tempUnwalkability(mapWidth+1,mapHeight+1) ;array that holds info about adjacent units
	Dim claimedNode.unit(mapWidth+1,mapHeight+1); array that stores claimed nodes	
	
	;Declare constants
	Global onClosedList = 10 ;openList variable	
	Const notfinished = 0, notStarted = 0, found = 1 ; pathStatus constants 
	Const nonexistent = 2, tempStopped = 3; pathStatus constants 
	Const walkable = 0, unwalkable = 1 ; walkability array constants	

;==========================================================
;FIND PATH: This function finds the path and saves it. Non-Blitz users please note,
;the first parameter is a pointer to a user-defined object called a unit, which contains all
;relevant info about the unit in question (its current location, speed, etc.). As an
;object-oriented data structure, types are similar to structs in C.
;	Please note that targetX and targetY are pixel-based coordinates relative to the
;upper left corner of the map, which is 0,0.
Function FindPath(unit.unit,targetX,targetY)

;1.	Convert location data (in pixels) to coordinates in the walkability array.
	startX = Floor(unit\xLoc/tileSize) : startY = Floor(unit\yLoc/tileSize)	
	targetX = Floor(targetX/tileSize) : targetY = Floor(targetY/tileSize)

;2.	Check for redirects	
	result = CheckRedirect(unit,targetX,targetY)	
	If result = failed Then Goto noPath ;target is unwalkable and could not find a redirect.
	If result = succeeded Then targetX = gInt1 : targetY = gInt2

	;If starting location and target are in the same location...
	If startX = targetX And startY = targetY 
		unit\pathLength = 0 : unit\pathLocation = 0	
		PokeShort unit\pathBank,0,startX ;store starting x value	
		PokeShort unit\pathBank,2,startY ;store starting y value		
		Return found
	End If

;3.	a. Reset some variables that need to be cleared
	If onClosedList > 1000000 ;occasionally redim whichList
		Dim whichList(mapWidth,mapHeight) : onClosedList = 10
	End If	
	onClosedList = onClosedList+5 ;changing the values of onOpenList and onClosed list is faster than redimming whichList() array
	onOpenList = onClosedList-1
	tempUnwalkable = onClosedList-2
	unit\pathLength = notstarted ;i.e, = 0
	unit\pathLocation = notstarted ;i.e, = 0
	Gcost(startX,startY) = 0 ;reset starting square's G value to 0

	;b. Create a footprint for any nearby unit that the pathfinding unit 
	;may be about to collide with. Such nodes are designated as tempUnwalkable.	
	CreateFootPrints(unit.unit)

;4.	Add the starting location to the open list of squares to be checked.
	numberOfOpenListItems = 1
	openList(1) = 1 ;assign it as the top (and currently only) item in the open list, which is maintained as a binary heap (explained below)
	openX(1) = startX : openY(1) = startY

;5.	Do the following until a path is found or deemed nonexistent.
	Repeat
	
;6.	If the open list is not empty, take the first cell off of the list.
	;This is the lowest F cost cell on the open list.
	If numberOfOpenListItems <> 0 Then

	;Pop the first item off the open list.
	parentXval = openX(openList(1)) : parentYVal = openY(openList(1)) ;record cell coordinates of the item
	whichList(parentXval,parentYVal) = onClosedList ;add the item to the closed list

	;Open List = Binary Heap: Delete this item from the open list, which
	;is maintained as a binary heap. For more information on binary heaps, see:
	;http://www.policyalmanac.org/games/binaryHeaps.htm
	numberOfOpenListItems = numberOfOpenListItems - 1 ;reduce number of open list items by 1	
	openList(1) = openList(numberOfOpenListItems+1) ;move the last item in the heap up to slot #1
	v = 1	
	Repeat ;Repeat the following until the new item in slot #1 sinks to its proper spot in the heap.
		u = v	
		If 2*u+1 <= numberOfOpenListItems ;if both children exist
		 	;Check if the F cost of the parent is greater than each child.
			;Select the lowest of the two children.	
			If Fcost(openList(u)) >= Fcost(openList(2*u)) Then v = 2*u
			If Fcost(openList(v)) >= Fcost(openList(2*u+1)) Then v = 2*u+1		
		Else
			If 2*u <= numberOfOpenListItems ;if only child #1 exists
			 	;Check if the F cost of the parent is greater than child #1	
				If Fcost(openList(u)) >= Fcost(openList(2*u)) Then v = 2*u
			End If	
		End If
		If u<>v ;if parent's F is > one of its children, swap them
			temp = openList(u)
			openList(u) = openList(v)
			openList(v) = temp				
		Else
			Exit ;otherwise, exit loop
		End If	
	Forever

	
;7.	Check the adjacent squares. (Its "children" -- these path children
	;are similar, conceptually, to the binary heap children mentioned
	;above, but don't confuse them. They are different. Path children
	;are portrayed in Demo 1 with grey pointers pointing toward
	;their parents.) Add these adjacent child squares to the open list
	;for later consideration if appropriate (see various if statements
	;below).
	For b = parentYVal-1 To parentYVal+1
	For a = parentXval-1 To parentXval+1

	;If not off the map (do this first to avoid array out-of-bounds errors)
	If a <> -1 And b <> -1 And a <> mapWidth And b <> mapHeight

	;If not already on the closed list (items on the closed list have
	;already been considered and can now be ignored).			
	If whichList(a,b) <> onClosedList 
	
	;If not a wall/obstacle square
	If walkability(a,b) <> unwalkable
	
	;If not an adjacent node that is temporarily unwalkable
	;as defined by CreateFootprints()
	If tempUnwalkability(a,b) <> tempUnwalkable
	
	;If not occupied by a stopped unit
	node = unwalkable
	If claimedNode(a,b) = Null
		node = walkable
	Else If claimedNode(a,b)\pathStatus <> stopped 
		node = walkable	
	End If
	If node = walkable
			
	;Don't cut across corners (this is optional)
	corner = walkable	
	If a = parentXVal-1 
		If b = parentYVal-1 
			If walkability(parentXval-1,parentYval) = unwalkable Then corner = unwalkable
			If walkability(parentXval,parentYval-1) = unwalkable Then corner = unwalkable						
		Else If b = parentYVal+1 
			If walkability(parentXval,parentYval+1) = unwalkable Then corner = unwalkable 
			If walkability(parentXval-1,parentYval) = unwalkable Then corner = unwalkable 							
		End If
	Else If a = parentXVal+1 
		If b = parentYVal-1 
			If walkability(parentXval,parentYval-1) = unwalkable Then corner = unwalkable 
			If walkability(parentXval+1,parentYval) = unwalkable Then corner = unwalkable 							
		Else If b = parentYVal+1 
			If walkability(parentXval+1,parentYval) = unwalkable Then corner = unwalkable 
			If walkability(parentXval,parentYval+1) = unwalkable Then corner = unwalkable 			
		End If
	End If			
	If corner = walkable
	
	;If not already on the open list, add it to the open list.			
	If whichList(a,b) <> onOpenList	

		;Create a new open list item in the binary heap.
		newOpenListItemID = newOpenListItemID + 1; each new item has a unique ID #
		m = numberOfOpenListItems+1
		openList(m) = newOpenListItemID	 ;place the new open list item (actually, its ID#) at the bottom of the heap
		openX(newOpenListItemID) = a : openY(newOpenListItemID) = b ;record the x and y coordinates of the new item

		;Figure out its G cost
		If Abs(a-parentXval) = 1 And Abs(b-parentYVal) = 1 Then
			addedGCost = 14 ;cost of going to diagonal squares	
		Else	
			addedGCost = 10 ;cost of going to non-diagonal squares				
		End If
		Gcost(a,b) = Gcost(parentXval,parentYVal)+addedGCost
			
		;Figure out its H and F costs and parent
		Hcost(openList(m)) = 10*(Abs(a - targetx) + Abs(b - targety)) ; record the H cost of the new square
		Fcost(openList(m)) = Gcost(a,b) + Hcost(openList(m)) ;record the F cost of the new square
		parentX(a,b) = parentXval : parentY(a,b) = parentYVal	;record the parent of the new square	
		
		;Move the new open list item to the proper place in the binary heap.
		;Starting at the bottom, successively compare to parent items,
		;swapping as needed until the item finds its place in the heap
		;or bubbles all the way to the top (if it has the lowest F cost).
		While m <> 1 ;While item hasn't bubbled to the top (m=1)	
			;Check if child's F cost is < parent's F cost. 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
			End If
		Wend 
		numberOfOpenListItems = numberOfOpenListItems+1 ;add one to the number of items in the heap

		;Change whichList to show that the new item is on the open list.
		whichList(a,b) = onOpenList


;8.	If adjacent cell is already on the open list, check to see if this 
	;path to that cell from the starting location is a better one. 
	;If so, change the parent of the cell and its G and F costs.	
	Else; If whichList(a,b) = onOpenList
	
		;Figure out the G cost of this possible new path
		If Abs(a-parentXval) = 1 And Abs(b-parentYVal) = 1 Then
			addedGCost = 14;cost of going to diagonal tiles	
		Else	
			addedGCost = 10 ;cost of going to non-diagonal tiles				
		End If
		tempGcost = Gcost(parentXval,parentYVal)+addedGCost
		
		;If this path is shorter (G cost is lower) then change
		;the parent cell, G cost and F cost. 		
		If tempGcost < Gcost(a,b) Then 	;if G cost is less,
			parentX(a,b) = parentXval 	;change the square's parent
			parentY(a,b) = parentYVal
			Gcost(a,b) = tempGcost 	;change the G cost			

			;Because changing the G cost also changes the F cost, if
			;the item is on the open list we need to change the item's
			;recorded F cost and its position on the open list to make
			;sure that we maintain a properly ordered open list.
			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.	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲女性喷水在线观看一区| 亚洲无线码一区二区三区| 色94色欧美sute亚洲线路一ni| 成人精品gif动图一区| 亚洲一区二区三区视频在线| 久久久久久麻豆| 欧美一级理论片| 91色在线porny| 床上的激情91.| 麻豆精品国产91久久久久久| 亚洲一区视频在线| 国产精品第一页第二页第三页| 精品福利在线导航| 欧美美女网站色| 在线看日韩精品电影| 高清成人在线观看| 国产美女主播视频一区| 日av在线不卡| 午夜成人免费视频| 亚洲欧美日韩系列| 欧美国产日本视频| 亚洲精品一区二区三区影院| 欧美一区二区精美| 欧美人体做爰大胆视频| 在线视频你懂得一区二区三区| 成人精品视频网站| 国产精品911| 国产精品伊人色| 精品无人码麻豆乱码1区2区 | 欧美激情在线一区二区| 精品乱码亚洲一区二区不卡| 日韩一区二区三| 91精品国产全国免费观看| 欧美精品黑人性xxxx| 欧美日韩国产一级片| 日本高清不卡视频| 色婷婷综合久久| 色婷婷综合激情| 欧美优质美女网站| 欧美日韩另类一区| 91精品国产综合久久蜜臀| 欧美精品黑人性xxxx| 337p亚洲精品色噜噜噜| 91麻豆精品国产自产在线观看一区 | 国产精品系列在线播放| 国产精品911| 波多野结衣在线一区| 成人激情动漫在线观看| 99久久精品免费看国产| www.亚洲在线| 欧美亚洲国产一区二区三区va| 欧美优质美女网站| 欧美久久久久免费| 欧美www视频| 国产日韩在线不卡| 亚洲丝袜精品丝袜在线| 亚洲五码中文字幕| 日本午夜精品视频在线观看 | 91精品国产综合久久香蕉的特点 | 亚洲一区二区中文在线| 丝袜亚洲另类欧美综合| 久久69国产一区二区蜜臀| 国内外精品视频| 99久久免费精品| 欧美主播一区二区三区美女| 56国语精品自产拍在线观看| 精品欧美一区二区三区精品久久| 国产欧美一区二区精品久导航| 亚洲日本欧美天堂| 日韩av一区二区三区| 国产一区视频网站| 色综合天天综合色综合av| 在线成人av网站| 久久久精品黄色| 一区二区三区不卡视频| 美女mm1313爽爽久久久蜜臀| 国产不卡视频在线播放| 欧美性猛交xxxxxx富婆| 2021久久国产精品不只是精品| 中文字幕在线免费不卡| 五月天一区二区三区| 高清beeg欧美| 欧美猛男男办公室激情| 国产日韩欧美精品一区| 亚洲国产一区二区a毛片| 久久99久久99精品免视看婷婷 | 亚洲综合在线五月| 麻豆成人久久精品二区三区红| av欧美精品.com| 日韩一区二区不卡| 亚洲视频在线一区| 激情av综合网| 欧美视频三区在线播放| 日韩欧美一区二区视频| 亚洲狠狠丁香婷婷综合久久久| 国内精品写真在线观看| 一本大道久久a久久精品综合| 精品不卡在线视频| 亚洲第一激情av| www.66久久| 2023国产精华国产精品| 三级久久三级久久久| 91小视频免费观看| 久久这里只精品最新地址| 午夜精品久久久久久久久久| 91麻豆国产在线观看| 91精品国产全国免费观看| 一区二区三区欧美在线观看| 成人免费av资源| 欧美一区二区大片| 午夜伦理一区二区| 色天使色偷偷av一区二区| 欧美国产欧美综合| 国产精品综合二区| 日韩一区二区三区在线观看| 亚洲一区二区av在线| 一本久久精品一区二区| 欧美激情一二三区| 国产精品自拍三区| 精品美女一区二区| 久久aⅴ国产欧美74aaa| 91麻豆精品国产91久久久| 亚洲一区二区三区四区在线免费观看 | 一本到不卡精品视频在线观看| 国产日韩欧美a| 国产九九视频一区二区三区| 精品国产乱码久久久久久夜甘婷婷| 五月激情六月综合| 欧美日韩国产经典色站一区二区三区 | 在线视频观看一区| 亚洲三级电影网站| 97se狠狠狠综合亚洲狠狠| 中文字幕在线观看不卡| 不卡欧美aaaaa| 国产精品国产三级国产专播品爱网| 国产福利91精品一区二区三区| 精品国产乱码久久久久久闺蜜| 久久99精品一区二区三区| 精品国产sm最大网站免费看| 激情综合五月天| 2019国产精品| 国产.欧美.日韩| 国产欧美一区二区三区网站| 大陆成人av片| 亚洲美女在线一区| 欧美亚洲动漫精品| 日本成人在线网站| 日韩欧美一级特黄在线播放| 精彩视频一区二区三区| 久久久久久久久久久黄色| 成人一级片网址| 亚洲女人的天堂| 欧美人妇做爰xxxⅹ性高电影 | 日韩国产一二三区| 日韩视频永久免费| 国产一区欧美二区| 中文字幕亚洲精品在线观看| 91同城在线观看| 亚洲国产美国国产综合一区二区| 欧美久久久久免费| 国产精品自在在线| 樱花影视一区二区| 日韩午夜电影av| 波多野结衣一区二区三区 | 国产一区二区三区视频在线播放| 久久精品综合网| 91免费观看视频在线| 亚洲国产一区二区视频| 欧美tickling网站挠脚心| 成人性生交大片免费| 亚洲图片欧美一区| 精品对白一区国产伦| 一本一道波多野结衣一区二区| 日韩精品91亚洲二区在线观看| 久久这里只有精品视频网| 99精品视频在线观看| 奇米综合一区二区三区精品视频| 欧美国产日本视频| 91.com在线观看| 国产成人午夜99999| 亚洲国产精品久久久久秋霞影院 | 精品视频123区在线观看| 国内精品久久久久影院薰衣草 | 国产精品456| 天堂资源在线中文精品| 国产网站一区二区三区| 欧美亚洲另类激情小说| 国产精品香蕉一区二区三区| 亚洲chinese男男1069| 国产目拍亚洲精品99久久精品| 欧美三级电影精品| 成人性生交大片免费| 美腿丝袜亚洲综合| 亚洲综合网站在线观看| 国产日本一区二区| 日韩色视频在线观看| 91国产视频在线观看| 成人激情午夜影院| 国产一区二区按摩在线观看| 婷婷国产v国产偷v亚洲高清|