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

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

?? astarlibrary - demo 3 (4 way).bb

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

;This version of the A* pathfinder is modified to only allow 4 directional
;movement, which may be better suited for platform games.

;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.

;Setup
;-----
;1. Include "includes/aStarLibrary.bb" at the top of your program.

;2. Create an array called walkability(x,y) that contains information
;	about the walkability of each square/tile on your map, with
;	0 = walkable (the default value) and 1 = unwalkable. The array
;	should range from (0,0) in the upper left hand corner to 
;	(mapWidth-1,mapHeight-1) in the bottom right hand corner.

;3. Adjust the following variables at the top of the .declareVariables
;	subroutine below. All three should be made global.
;	- tileSize = the width and height of your square tiles in pixels
;	- mapWidth = the width of your map in tiles = x value in
;		walkability array.
;	- mapHeight = the height of your map in tiles = y value in
;		walkability array.


;Calling the functions
;---------------------
;There are three main functions

;1.	FindPath(unit.unit,targetX,targetY)
;	- unit.unit = unit that is doing the pathfinding
;	- targetX,targetY = location of the target destination (pixel based coordinates)

;	The FindPath() function returns whether a path could be found (1) or
;	if it's nonexistent (2). If there is a path, it stores it in a bank
;	called unit\pathBank.

;2.   CheckPathStepAdvance(unit.unit)
;	This function updates the current path.

;3.	ReadPath(unit.unit)
; 	This function reads the path data generated by FindPath() and returns
;	the x and y coordinates of the next step on the path. They are stored
;	as xPath and yPath. These coordinates are pixel coordinates 
;	on the screen. See the function for more info.

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

	;Adjust these variables to match your map dimensions (see "setup" above)
	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		
	
	;Declare constants
	Global onClosedList = 10 ;openList variable	
	Const notfinished = 0, notStarted = 0, found = 1, nonexistent = 2; 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.	Quick Path Checks: Under the some circumstances no path needs to
	;be generated ...

	;If starting location and target are in the same location...
	If startX = targetX And startY = targetY And unit\pathLocation > 0 Then Return found
	If startX = targetX And startY = targetY And unit\pathLocation = 0 Then Return nonexistent

	;If target square is unwalkable, return that it's a nonexistent path.
	If walkability(targetX,targetY) = unwalkable Then Goto noPath

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

;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 direction = 1 To 4
	
	If direction = 1 
		a = parentXVal : b = parentYVal-1
	Else If direction = 2 
		a = parentXVal-1 : b = parentYVal
	Else If direction = 3 
		a = parentXVal+1 : b = parentYVal
	Else If direction = 4 
		a = parentXVal : b = parentYVal+1
	End If		

	;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 
	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产综合一区二区三区 | 久久久美女毛片| 欧美久久久久久久久| 91在线国产福利| av在线不卡电影| 色一区在线观看| 欧美性一级生活| 欧美夫妻性生活| 欧美va亚洲va| 国产精品视频你懂的| 1区2区3区欧美| 亚洲一区国产视频| 美女任你摸久久| 国产超碰在线一区| 色伊人久久综合中文字幕| 欧美高清激情brazzers| 精品乱码亚洲一区二区不卡| 久久久精品日韩欧美| 亚洲人成亚洲人成在线观看图片| 亚洲第一福利一区| 国内成+人亚洲+欧美+综合在线 | 欧美精品18+| 国产精品午夜在线观看| 亚洲sss视频在线视频| 日韩专区在线视频| 国产aⅴ综合色| 亚洲精品视频一区二区| 欧美午夜影院一区| 精品理论电影在线| 亚洲一区在线观看视频| 色噜噜夜夜夜综合网| 国产精品国产馆在线真实露脸| 日本成人在线电影网| 欧美日韩你懂的| 一区二区三区在线视频观看58 | 欧美xxxxx牲另类人与| 日韩精品一二三| 精品人在线二区三区| 蜜桃av一区二区在线观看| 日韩一级片在线播放| 日韩高清电影一区| 亚洲国产一区二区三区| 亚洲午夜免费电影| 自拍偷拍国产亚洲| 日韩欧美一区二区久久婷婷| 337p粉嫩大胆噜噜噜噜噜91av| 欧美日韩一区二区三区在线看 | 国产成人免费视频精品含羞草妖精| 欧美图片一区二区三区| 久久蜜桃香蕉精品一区二区三区| 日韩国产欧美三级| 欧美日韩国产高清一区二区| 亚洲国产精品激情在线观看| 国产精品一卡二| 欧美国产激情一区二区三区蜜月| 老司机精品视频在线| 日韩精品一区二区三区视频| 亚洲综合一区二区三区| 欧美性大战久久久久久久蜜臀| 亚洲成av人片一区二区| 色先锋资源久久综合| 国产精品大尺度| 日韩高清在线不卡| 欧美综合亚洲图片综合区| 日韩国产欧美三级| 884aa四虎影成人精品一区| 蜜臀av一区二区在线免费观看 | 91色九色蝌蚪| 亚洲自拍都市欧美小说| 欧美在线看片a免费观看| 亚洲午夜久久久| 精品va天堂亚洲国产| 成人久久18免费网站麻豆 | 日韩免费电影网站| 99精品欧美一区二区三区小说| 亚洲va欧美va天堂v国产综合| 欧美肥妇毛茸茸| 91在线免费看| 国产综合色视频| 午夜精品久久久久久久久久久| 精品国产精品网麻豆系列| 一本久久综合亚洲鲁鲁五月天| 亚洲综合免费观看高清完整版 | 日韩免费视频一区| 在线综合+亚洲+欧美中文字幕| 成人精品视频一区二区三区| 美女脱光内衣内裤视频久久网站 | 欧美一级淫片007| jiyouzz国产精品久久| 国产在线视频精品一区| 视频一区二区三区入口| 亚洲精品乱码久久久久久久久 | 天使萌一区二区三区免费观看| 亚洲女爱视频在线| 91精品国产综合久久蜜臀| 欧美视频精品在线观看| 国产综合成人久久大片91| 看国产成人h片视频| 日本最新不卡在线| 美女性感视频久久| 毛片不卡一区二区| 毛片一区二区三区| 国产专区欧美精品| 91在线精品一区二区| 91国产精品成人| 色婷婷av一区二区三区gif| 国产伦精品一区二区三区视频青涩| 天天亚洲美女在线视频| 三级欧美韩日大片在线看| 精品综合久久久久久8888| 国产91丝袜在线观看| 91美女蜜桃在线| 日韩欧美一级二级三级久久久| 91老司机福利 在线| 91麻豆精品国产91久久久资源速度| 久久久久亚洲蜜桃| 亚洲成人三级小说| 国产91精品精华液一区二区三区| 欧美日韩精品二区第二页| 久久久久久亚洲综合| 五月天激情综合| 成人激情图片网| 欧美一级艳片视频免费观看| 精品国产123| 一区av在线播放| 日韩av网站在线观看| 99精品国产热久久91蜜凸| 欧美乱妇23p| 亚洲图片另类小说| 久久国产婷婷国产香蕉| 色综合天天性综合| 欧美α欧美αv大片| 亚洲国产成人porn| 成人a区在线观看| 欧美精品在线观看一区二区| 26uuu国产日韩综合| 亚洲午夜精品一区二区三区他趣| 欧美a一区二区| 欧美三级中文字幕| 亚洲日本韩国一区| 国产成人精品一区二区三区四区 | 91小视频免费看| 久久久久久亚洲综合| 成人av影视在线观看| 国产农村妇女毛片精品久久麻豆| 国产精品小仙女| 亚洲欧洲综合另类| 欧美在线看片a免费观看| 图片区小说区国产精品视频 | 91精品国产综合久久精品图片| 亚洲最大色网站| 欧洲人成人精品| 粉嫩av一区二区三区在线播放| 亚洲欧洲日韩av| 911精品产国品一二三产区| 国内外成人在线| 亚洲欧美经典视频| 91麻豆精品国产无毒不卡在线观看| 久99久精品视频免费观看| 日韩欧美国产电影| 91蜜桃传媒精品久久久一区二区| 亚洲第一电影网| 国产精品久久网站| 欧美日韩一级二级| 成人久久久精品乱码一区二区三区 | 日韩一区二区在线观看视频| 精品亚洲免费视频| 亚洲综合999| 欧美一级片在线看| 97成人超碰视| 国产综合久久久久影院| 一区二区三区四区蜜桃| 日韩美女视频在线| 91国偷自产一区二区三区观看 | 看电视剧不卡顿的网站| 日本不卡视频一二三区| 亚洲一区成人在线| 中文字幕一区三区| 国产精品久久久久久福利一牛影视 | 国产亚洲综合av| 欧美日韩亚洲综合| 欧美午夜不卡视频| 欧美三级电影在线看| av资源网一区| 一本到三区不卡视频| 成人性生交大片免费看中文| 日韩精品一卡二卡三卡四卡无卡 | 香蕉加勒比综合久久| 亚洲福利电影网| 亚洲国产精品影院| 一区二区三区欧美激情| 亚洲人成伊人成综合网小说| 日韩毛片高清在线播放| 亚洲一区二区精品视频| 亚洲精品国产高清久久伦理二区| 亚洲精品水蜜桃| 日韩制服丝袜先锋影音| 精品一区二区三区蜜桃| 99久久久久久99| 精品久久久久久久久久久久久久久久久 |