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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? astarlibrary - demo 5.bb

?? A*尋路算法
?? BB
?? 第 1 頁 / 共 3 頁
字號:
;A* Pathfinder by Patrick Lester. Used by permission.
;==================================================================
;Last updated 4/7/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 = 25, mapWidth = 32, mapHeight = 24

	;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 nearByPath(mapWidth+1,mapHeight+1) 		
	Dim claimedNode.unit(mapWidth+1,mapHeight+1); array that stores claimed nodes	
	Dim gGroupUnit.unit(1) ;used to sort a selected group of units		
	Dim island(mapWidth+1,mapHeight+1) 
		
	;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	
	Global gDiagonalBlockage, gPathCost
	
	;FindPath() mode constants
	Const normal = 0, randomMove = 1

;==========================================================
;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,mode=normal)

	;Random move mode is used when a unit's main target is
	;currently unreachable. After the random move, the unit
	;will try to pathfind to its original target again. Random
	;moves can break up units that happen to be approaching
	;each other from opposite directions down tight corridors.
	;See the UpdatePath() function.
	If mode = randomMove Then useDijkstras = True	

;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
	penalized = onClosedList-3 
	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 base 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
		
		;If the node lies along the path of a nearby unit, add a penalty G cost.		
		If nearByPath(a,b) = penalized
			Gcost(a,b) = Gcost(a,b)+20
		Else If a<>parentXval And b<>parentYval
			If nearByPath(a,parentYval) = penalized
				If nearByPath(parentXval,b) = penalized
					Gcost(a,b) = Gcost(a,b)+28
				End If
			End If	
		End If		
			
		;Figure out its H and F costs and parent
		If useDijkstras = False
			Hcost(openList(m)) = 10*(Abs(a - targetx) + Abs(b - targety)) ; record the H cost of the new square
		Else
			Hcost(openList(m)) = 0	
		End If		
		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 base 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 the node lies along the path of a nearby unit, add a penalty G cost.			
		If nearByPath(a,b) = penalized
			tempGcost  = tempGcost+20
		Else If a<>parentXval And b<>parentYval
			If nearByPath(a,parentYval) = penalized
				If nearByPath(parentXval,b) = penalized
					tempGcost  = tempGcost+28
				End If
			End If	
		End If				
		
		;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.

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久久久久搜平片| 久久这里只有精品6| 另类专区欧美蜜桃臀第一页| 国产精品美女久久久久久2018| 91行情网站电视在线观看高清版| 国产米奇在线777精品观看| 亚洲已满18点击进入久久| 久久人人97超碰com| 欧美日韩国产片| 91在线视频播放地址| 精品一区二区三区免费毛片爱| 一二三区精品福利视频| 国产亚洲美州欧州综合国| 3d动漫精品啪啪一区二区竹菊| 91免费版在线| 国产成人在线免费观看| 天堂蜜桃91精品| 一区二区三区在线观看动漫| 亚洲国产精品精华液2区45| 日韩欧美一级二级| 欧美精品一级二级三级| 日本道在线观看一区二区| 高清久久久久久| 国产乱码精品一区二区三区五月婷| 亚洲aaa精品| 亚洲激情在线播放| 国产精品久久看| 国产精品视频线看| 久久综合久久久久88| 欧美大度的电影原声| 欧美精品亚洲二区| 欧美视频一区二区三区四区| 一本色道综合亚洲| av午夜一区麻豆| 成人午夜看片网址| 国产成人精品三级| 国产91在线观看丝袜| 成人在线视频首页| 床上的激情91.| 成人av综合在线| 成人h动漫精品一区二| 成人av网站大全| 99国产精品久久久久| 91女厕偷拍女厕偷拍高清| 99精品在线免费| 日本韩国精品在线| 欧美日韩小视频| 欧美一区二区精品| 久久综合一区二区| 久久久久综合网| 国产精品欧美经典| 亚洲激情六月丁香| 视频在线在亚洲| 看电视剧不卡顿的网站| 久草在线在线精品观看| 国产成人综合亚洲91猫咪| 国产91丝袜在线播放| 91在线看国产| 欧美男生操女生| 精品国产一区久久| 国产精品免费人成网站| 一区二区三区在线观看网站| 天天影视网天天综合色在线播放| 麻豆高清免费国产一区| 国产.精品.日韩.另类.中文.在线.播放 | 91网站视频在线观看| 色综合久久综合网97色综合| 欧美精品乱人伦久久久久久| 欧美成人性福生活免费看| 久久久精品蜜桃| 亚洲另类在线一区| 青娱乐精品在线视频| 国产夫妻精品视频| 色94色欧美sute亚洲线路二| 欧美久久久久久蜜桃| 久久久精品2019中文字幕之3| 中文字幕中文字幕一区二区| 亚洲一区二区三区四区在线观看| 美日韩一级片在线观看| 不卡视频一二三四| 51久久夜色精品国产麻豆| 国产情人综合久久777777| 亚洲免费伊人电影| 蜜臀av性久久久久蜜臀aⅴ流畅| 大尺度一区二区| 欧美电影一区二区| 国产精品久久久久aaaa樱花| 日本不卡在线视频| 99精品视频中文字幕| 欧美va亚洲va国产综合| 亚洲色图制服丝袜| 精品一区二区三区不卡| 色婷婷久久久亚洲一区二区三区| 日韩欧美激情在线| 亚洲一区视频在线| 粉嫩在线一区二区三区视频| 91精品国产一区二区人妖| 亚洲欧洲精品一区二区精品久久久 | 国产精品美女久久久久久久久| 婷婷成人综合网| 99精品久久99久久久久| 2023国产精品| 日日夜夜免费精品视频| 91色|porny| 国产偷国产偷精品高清尤物| 天天综合网 天天综合色| 91麻豆精东视频| www国产成人免费观看视频 深夜成人网| 亚洲亚洲人成综合网络| 成人免费三级在线| 久久夜色精品国产噜噜av| 夜夜精品视频一区二区| a亚洲天堂av| 国产香蕉久久精品综合网| 捆绑调教一区二区三区| 制服丝袜亚洲色图| 一区二区三区日韩在线观看| 成人美女在线视频| 亚洲精品一区在线观看| 蜜臀av在线播放一区二区三区 | 国产精品一区一区三区| 日韩欧美一区在线| 日韩在线一区二区| 欧美日韩国产一级片| 一区二区激情视频| 91精品91久久久中77777| 亚洲欧美一区二区在线观看| 国产99久久久国产精品免费看| 26uuu亚洲综合色欧美| 欧美aⅴ一区二区三区视频| 欧美日韩精品免费观看视频| 亚洲综合色在线| 欧美制服丝袜第一页| 亚洲亚洲人成综合网络| 欧美性色黄大片| 亚瑟在线精品视频| 欧美精品久久天天躁| 视频一区在线视频| 欧美美女视频在线观看| 日韩在线播放一区二区| 日韩午夜av一区| 九一九一国产精品| 久久精品亚洲一区二区三区浴池| 国产一区不卡精品| 亚洲国产精品国自产拍av| 不卡电影免费在线播放一区| 综合激情成人伊人| 色婷婷久久综合| 香蕉成人啪国产精品视频综合网 | 日韩一级免费观看| 久久成人av少妇免费| 国产亚洲一区二区三区| 成人黄色av网站在线| 日韩理论电影院| 欧美在线综合视频| 日产欧产美韩系列久久99| 日韩免费看的电影| 国产91精品一区二区麻豆网站 | 欧美videos中文字幕| 国产最新精品免费| 中文字幕一区二区三| 欧美性猛交xxxx乱大交退制版| 日韩国产欧美视频| 久久精品在这里| 99久久er热在这里只有精品15| 亚洲成人黄色小说| 久久这里只精品最新地址| 不卡的av电影在线观看| 亚洲成人黄色小说| 国产亚洲欧美一区在线观看| 色综合一个色综合| 免费av网站大全久久| 国产精品久久看| 制服丝袜亚洲网站| 国产成人午夜精品影院观看视频| 亚洲精品美国一| 精品国产制服丝袜高跟| 91亚洲国产成人精品一区二区三| 亚洲图片一区二区| 久久综合久久久久88| 日本国产一区二区| 韩国av一区二区三区四区| 亚洲精品第一国产综合野| 日韩免费福利电影在线观看| 97久久超碰精品国产| 人妖欧美一区二区| 亚洲天堂精品视频| 欧美电视剧在线看免费| 一本色道久久综合亚洲91| 麻豆成人91精品二区三区| 亚洲欧美日韩国产一区二区三区| 日韩欧美一二三区| 在线欧美小视频| 国产精品亚洲一区二区三区妖精| 亚洲国产日韩精品| 国产精品久线在线观看| 日韩欧美一级片| 欧美视频日韩视频在线观看| 懂色av中文字幕一区二区三区| 午夜电影一区二区三区|