亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日本欧美大码aⅴ在线播放| 在线观看不卡视频| 久久99国产精品麻豆| 五月天中文字幕一区二区| 亚洲国产精品一区二区www| 亚洲国产精品一区二区尤物区| 亚洲精品国产高清久久伦理二区| 亚洲精品视频一区| 亚洲影视在线播放| 日韩电影免费在线| 青椒成人免费视频| 久久99精品国产91久久来源| 精品中文字幕一区二区小辣椒| 韩国v欧美v日本v亚洲v| 国产一区二区三区四区五区入口| 国产精品白丝av| 波多野结衣91| 91国在线观看| 欧美乱妇20p| 久久天堂av综合合色蜜桃网| 久久久久久久久久看片| 亚洲色图欧洲色图婷婷| 亚洲午夜影视影院在线观看| 日本 国产 欧美色综合| 国产在线看一区| 波多野结衣在线一区| 91国偷自产一区二区三区成为亚洲经典 | 日韩精品一二三| 久久草av在线| 波多野结衣欧美| 欧美精选一区二区| 久久亚洲精精品中文字幕早川悠里| 中文字幕av不卡| 亚洲综合免费观看高清完整版在线| 视频一区视频二区中文| 国产成人精品一区二| 色诱视频网站一区| 日韩免费在线观看| 1000部国产精品成人观看| 午夜成人免费视频| 国产乱码精品一品二品| 在线观看网站黄不卡| 精品日韩99亚洲| 亚洲欧美日韩国产一区二区三区 | 97久久超碰国产精品| 欧美日韩国产综合草草| 久久久精品日韩欧美| 亚洲一级二级在线| 国产成人av电影在线| 欧美日韩综合不卡| 国产精品久久影院| 蜜臀精品久久久久久蜜臀| 99国产精品99久久久久久| 日韩一级二级三级| 亚洲激情六月丁香| 国产成人亚洲精品狼色在线 | 日本一区二区三区免费乱视频| 亚洲国产精品久久久久秋霞影院 | 91无套直看片红桃| 精品国产乱码久久久久久老虎| 亚洲欧美日韩小说| 国产精品123| 91精品国产91热久久久做人人| 国产精品久久久久久妇女6080| 久久福利资源站| 欧美调教femdomvk| 中文字幕一区在线观看| 久久国产福利国产秒拍| 欧美日韩一卡二卡| 亚洲欧美另类综合偷拍| 高潮精品一区videoshd| 欧美va在线播放| 日韩1区2区3区| 91久久国产综合久久| 国产精品国产三级国产有无不卡| 免费成人av在线| 欧美丝袜丝交足nylons| 亚洲欧美色图小说| jvid福利写真一区二区三区| 欧美成人猛片aaaaaaa| 亚洲va欧美va人人爽午夜| 不卡一区二区中文字幕| 久久精品一区蜜桃臀影院| 久久66热re国产| 日韩一级片在线观看| 午夜伦欧美伦电影理论片| 91国产丝袜在线播放| 亚洲视频在线一区二区| 成人精品视频.| 中文久久乱码一区二区| 国产一区二区三区美女| 久久综合五月天婷婷伊人| 秋霞影院一区二区| 在线成人av影院| 香蕉乱码成人久久天堂爱免费| 色8久久精品久久久久久蜜| 亚洲精品精品亚洲| 在线视频综合导航| 一区二区三区在线观看动漫| 91视频观看视频| 亚洲视频每日更新| 91亚洲大成网污www| 一区二区免费看| 欧美性欧美巨大黑白大战| 亚洲一区精品在线| 777午夜精品免费视频| 天天影视网天天综合色在线播放| 777奇米成人网| 秋霞午夜av一区二区三区| 日韩美女一区二区三区| 精品亚洲aⅴ乱码一区二区三区| 日韩欧美三级在线| 国产精品一区二区免费不卡| 日本一区二区三区高清不卡| 成人av中文字幕| 一区二区三区不卡视频在线观看| 欧美色男人天堂| 日韩精彩视频在线观看| 精品国产免费人成电影在线观看四季| 精品一区二区综合| 国产精品久久久久久久久免费樱桃 | 国产成人综合网站| 国产精品大尺度| 一道本成人在线| 午夜激情综合网| 精品国产1区2区3区| 成人久久视频在线观看| 亚洲一区二区三区三| 日韩色视频在线观看| 国产1区2区3区精品美女| 亚洲欧美日韩久久| 正在播放一区二区| 国产成人免费在线视频| 亚洲激情欧美激情| 欧美不卡一区二区三区四区| 国产成人精品影视| 亚洲国产一二三| 亚洲精品一区二区三区蜜桃下载| thepron国产精品| 亚洲18女电影在线观看| 久久色成人在线| 色婷婷精品久久二区二区蜜臀av | 欧美中文字幕一区| 国产综合久久久久久鬼色| 亚洲欧美区自拍先锋| 欧美xxxxxxxx| 色诱亚洲精品久久久久久| 久久国产三级精品| 亚洲九九爱视频| 久久久久久久久久久久电影| 色94色欧美sute亚洲线路一久| 蜜乳av一区二区| 亚洲精品乱码久久久久久久久| 欧美xxxxxxxxx| 欧美性大战久久| 粉嫩嫩av羞羞动漫久久久| 亚瑟在线精品视频| 中文字幕精品—区二区四季| 91精品国产综合久久国产大片| eeuss国产一区二区三区| 日产国产高清一区二区三区| 国产精品国产三级国产三级人妇 | 欧美在线观看视频一区二区三区| 国产一区二区三区在线看麻豆| 亚洲123区在线观看| 中文字幕制服丝袜一区二区三区| 欧美一区二区三区婷婷月色| 91蝌蚪porny成人天涯| 国产精品亚洲一区二区三区在线 | 日本视频免费一区| 亚洲手机成人高清视频| 久久久久久久久久电影| 日韩三级免费观看| 欧洲精品视频在线观看| 岛国一区二区在线观看| 另类人妖一区二区av| 亚洲福利电影网| 亚洲欧美日韩国产成人精品影院 | 中文字幕色av一区二区三区| 欧美成人精精品一区二区频| 欧美色偷偷大香| 99久久精品国产一区| 国产激情精品久久久第一区二区| 麻豆精品在线看| 偷拍与自拍一区| 午夜av电影一区| 亚洲午夜精品久久久久久久久| 亚洲三级电影网站| 中文字幕亚洲一区二区av在线| 国产日韩欧美激情| 精品国产91乱码一区二区三区| 欧美高清视频一二三区 | 亚洲国产精品人人做人人爽| 亚洲视频 欧洲视频| 国产精品区一区二区三| 欧美国产禁国产网站cc| 国产日韩精品一区二区三区在线| 久久久久久久av麻豆果冻| 26uuu亚洲综合色| 2023国产一二三区日本精品2022|