資源簡介
matlab實現的A星算法,有個性界面,直接運行就可以
代碼片段和文件信息
function?astardemo
%ASTARDEMO?Demonstration?of?ASTAR?algorithm
%
%???Copyright?Bob?L.?Sturm?Ph.?D.?Assistant?Professor
%???Department?of?Architecture?Design?and?Media?Technology
%?????formerly?Medialogy
%???Aalborg?University?i?Ballerup
%?????formerly?Aalborg?University?Copenhagen
%???$Revision:?0.1?$??$Date:?2011?Jan.?15?18h24:24$
n?=?20;???%?field?size?n?x?n?tiles??20*20的界面
wallpercent?=?0.45;??%?this?percent?of?field?is?walls???45%的界面作為阻礙物(墻)
%?create?the?n?x?n?FIELD?with?wallpercent?walls?containing?movement?costs?
%?a?starting?position?STARTPOSIND?a?goal?position?GOALPOSIND?the?costs?
%?A?star?will?compute?movement?cost?for?each?tile?COSTCHART?
%?and?a?matrix?in?which?to?store?the?pointers?FIELDPOINTERS
[field?startposind?goalposind?costchart?fieldpointers]?=?...
??initializeField(nwallpercent);???%初始化界面
%?initialize?the?OPEN?and?CLOSED?sets?and?their?costs
setOpen?=?[startposind];?setOpenCosts?=?[0];?setOpenHeuristics?=?[Inf];
setClosed?=?[];?
- 上一篇:sobel算子的matlab實現
- 下一篇:matlab繪制B樣條曲面代碼
評論
共有 條評論