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

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

?? astarlibrary - demo 4a (loop based).bb

?? 國外的一個A*算法演示
?? 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			

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃免费网站一区二区三区| 欧美激情在线观看视频免费| 99久久99久久精品免费观看| 国产盗摄女厕一区二区三区| 激情丁香综合五月| 精品一区二区免费| 国产精一区二区三区| 国产一区二区精品久久91| 久久狠狠亚洲综合| 国产乱国产乱300精品| 国产成人一级电影| 成人av在线看| 色综合久久久网| 欧美男男青年gay1069videost | 午夜亚洲国产au精品一区二区| 中文字幕一区二区在线观看| 亚洲人成网站影音先锋播放| 亚洲一区二区三区视频在线播放 | 欧美视频第二页| 欧美视频完全免费看| 欧美一卡在线观看| 精品国产91洋老外米糕| 国产精品水嫩水嫩| 亚洲黄一区二区三区| 日本成人在线视频网站| 精品一区二区三区在线播放| 不卡一区二区中文字幕| 欧亚洲嫩模精品一区三区| 日韩亚洲欧美综合| 国产精品视频第一区| 亚洲在线成人精品| 国产美女av一区二区三区| 91在线免费看| 日韩限制级电影在线观看| 国产精品美女久久久久久| 三级精品在线观看| caoporm超碰国产精品| 欧美日韩精品一区二区三区 | 777xxx欧美| 精品成人佐山爱一区二区| 国产精品国产自产拍在线| 日本欧美韩国一区三区| av综合在线播放| 日韩欧美国产综合一区 | 成人国产精品免费观看动漫| 欧美精品在线观看一区二区| 中文字幕av一区二区三区| 日韩电影免费在线| 在线一区二区三区| 欧美国产精品中文字幕| 蜜臀av性久久久久av蜜臀妖精| 不卡电影一区二区三区| 精品99久久久久久| 日本欧美一区二区在线观看| 在线视频中文字幕一区二区| 久久久精品tv| 久久97超碰色| 正在播放亚洲一区| 亚洲综合视频网| 成人高清视频免费观看| 久久精品在线观看| 韩国毛片一区二区三区| 日韩欧美专区在线| 亚洲成人先锋电影| 91成人免费在线| 综合色天天鬼久久鬼色| 成人网男人的天堂| 国产片一区二区| 国产乱妇无码大片在线观看| xnxx国产精品| 激情成人综合网| 久久久欧美精品sm网站 | 国产精品二区一区二区aⅴ污介绍| 久久91精品久久久久久秒播| 日韩欧美亚洲国产另类| 久久电影国产免费久久电影 | 国产精品99久久久| 26uuu国产日韩综合| 精品一区二区三区视频 | 欧美午夜精品久久久久久超碰| 国产精品久久久久久一区二区三区| 国产乱人伦偷精品视频不卡| 久久精品人人做人人综合| 国产91丝袜在线观看| 欧美激情资源网| 91丨国产丨九色丨pron| 亚洲一区免费视频| 欧美日韩一二三区| 日本欧美加勒比视频| 久久精品欧美一区二区三区不卡| 成人免费观看视频| 亚洲精品第一国产综合野| 欧美日韩一区精品| 黄一区二区三区| 中文字幕一区日韩精品欧美| 在线观看视频91| 免费高清在线一区| 欧美国产日本韩| 91黄色激情网站| 日本91福利区| 国产精品每日更新| 欧美日韩精品高清| 国产成人免费视频网站| 亚洲免费资源在线播放| 欧美一卡2卡三卡4卡5免费| 国产成人精品一区二区三区四区| 亚洲色图色小说| 69av一区二区三区| 成人亚洲一区二区一| 亚洲成精国产精品女| 久久久久久久电影| 欧美影视一区二区三区| 国内精品在线播放| 一区二区三区丝袜| 久久久久久99精品| 欧美日韩高清在线| caoporm超碰国产精品| 老司机免费视频一区二区三区| 国产精品美女一区二区在线观看| 制服丝袜在线91| 99免费精品在线观看| 国产揄拍国内精品对白| 午夜日韩在线观看| 1024成人网| 久久久久高清精品| 日韩一级在线观看| 欧美日韩你懂得| 91麻豆swag| 成人免费视频视频在线观看免费| 日韩不卡在线观看日韩不卡视频| 亚洲欧美一区二区视频| 国产亚洲一本大道中文在线| 欧美一区二区免费视频| 在线观看成人免费视频| 成人国产亚洲欧美成人综合网| 精品一区二区免费看| 日韩综合小视频| 亚洲一区中文在线| 一区二区三区四区精品在线视频 | 日本麻豆一区二区三区视频| 一区二区高清免费观看影视大全 | 欧美白人最猛性xxxxx69交| 99久久精品国产导航| 国产福利不卡视频| 国产精品自拍毛片| 国精产品一区一区三区mba视频 | 国产白丝精品91爽爽久久| 日本最新不卡在线| 奇米影视7777精品一区二区| 五月天丁香久久| 午夜免费久久看| 亚洲二区在线观看| 性感美女极品91精品| 五月天精品一区二区三区| 日韩二区三区四区| 日韩1区2区日韩1区2区| 日韩中文字幕区一区有砖一区| 亚洲无人区一区| 亚洲444eee在线观看| 日日摸夜夜添夜夜添亚洲女人| 日韩精品一级二级 | 久久综合久久99| 久久久亚洲高清| 国产精品欧美一区二区三区| 国产欧美日韩麻豆91| 国产精品天美传媒沈樵| 亚洲精品成人在线| 亚洲午夜影视影院在线观看| 视频一区二区欧美| 久久66热偷产精品| 夫妻av一区二区| 色偷偷久久人人79超碰人人澡| 欧美日韩一区中文字幕| 欧美成va人片在线观看| 欧美国产97人人爽人人喊| 亚洲男人的天堂在线观看| 一区二区国产盗摄色噜噜| 奇米一区二区三区av| 成人午夜av在线| 欧美性大战xxxxx久久久| 91精品免费观看| 欧美激情一区二区| 偷拍一区二区三区| 国产黑丝在线一区二区三区| 色综合久久久久综合体| 欧美一区二区在线免费观看| 国产日韩欧美精品电影三级在线| 一级中文字幕一区二区| 国产综合成人久久大片91| 色哦色哦哦色天天综合| 日韩一区二区影院| 亚洲人成电影网站色mp4| 精东粉嫩av免费一区二区三区| 99在线精品免费| 欧美草草影院在线视频| 亚洲一区二区三区中文字幕在线 | 91捆绑美女网站| 欧美成人在线直播| 亚洲影院久久精品| 国产不卡视频在线观看|