版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
A*路径搜索
A*PathfindingWearegoingtodiscussthefundamentalsoftheA*pathfindingalgorithm.基本A*路径搜索算法TheA*Algorithmprovidesaneffectivesolutiontotheproblemofpathfinding.A*路径搜索
A*PathfindingWearego1定义搜索区域
DefiningthesearchareaThefirststepinpathfindingistodefinethesearcharea.首先定义搜索区域。Thegameworldneedstoberepresentedbypointsthatboththegamecharactersandobjectscanoccupy.Weneedtoreducethenodestoamanageablenumber,whichiswhatwemeanwhenwesayweneedtosimplifythesearcharea.减少搜索区域的节点数量,简化搜索区域。
定义搜索区域
Definingthesearchare2定义搜索区域
Definingthesearcharea定义搜索区域
Definingthesearchare3基于方块的搜索区域
Tiledsearcharea基于方块的搜索区域
Tiledsearcharea4StartingthesearchWewillusetheA*algorithmtofindtheshortestpathbetweenanytwonodeswhileavoidingtheobstacles.避开障碍在任意两点之间用A*算法获得最短路径。OpenList-Weneedawaytokeeptrackofwhichtilesneedtobesearched.可以作为后备检测的点的集合;ClosedList-thetilesthatalreadywerechecked.已经检测完成的点的集合。StartingthesearchWewilluse5A*伪代码
A*pseudocodeAddthestartingnodetotheopenlistWhiletheopenlistisnotempty{currentnode=nodefromopenlistwiththelowestcostifcurrentnode=goalnodethenpathcompleteelsemovecurrentnodetotheclosedlistexamineeachnodeadjacenttothecurrentnodeforeachadjacentnodeifitisn’tontheopenlistandisn’tontheclosedlistanditisn’tanobstaclethenmoveittoopenlistandcalculatecost}A*伪代码
A*pseudocodeAddthest6A*伪代码
A*pseudocode将开始点加到OpenList表中;重复一下过程,直到OpenList表空为止:{当前点=OpenList表中代价值最小的点;如果当前点为目标点,则搜索完成;否则将当前点移到ClosedList表中;对与当前点相连的每一点,重复执行:如果该点不在OpenList、ClosedList,并且不是障碍点则将该点移到OpenList表中,计算该点的代价值;}A*伪代码
A*pseudocode将开始点加到Open7CreateatiledsearchareaSpider-startingpointHumancharacter-destinationSolidblacksquares-wallobstaclesCreateatiledsearchareaSpid8AdjacenttilestoconsiderWeproceedtocheckeachoftheeightadjacenttilesandthenaddeachvalidtiletotheopenlist.对与蜘蛛相邻的八个点检查,不在任何表中和不是障碍的点加入OpenList表中。AdjacenttilestoconsiderWep9将开始点移到ClosedList表中
MovingthestartingtiletotheclosedlistStartpoint开始点将开始点移到ClosedList表中
Movingthe10LinkingtotheparentsLinktoparentsLinkingtotheparentsLinkto11赋予数值
ScoringWewillusepathscoringtodeterminethebestpathfromthestartingtiletothedestinationtile.(1)Welookatthecosttomovefromthestartingtiletoanygiventile.(2)Welookatthecosttomovefromthegiventiletothedestinationtile.(3)Wetakethesumofthecostofeachtilethatleadsbacktotheinitiallocation.赋予数值
ScoringWewillusepaths12CalculatingthepathscoreScore=Costfromstart+HeuristicWewillcheckthetileswiththelowestcost.Alowercostwillequatetoashorterpath.StartpointgivenpointdestinationCostfromstartheuristicCalculatingthepathscoreScor13InitialtilepathscoresInitialtilepathscores14初始化每一点的数值
InitialtilepathscoresThesvalueisthecostofgettingtherefromthestartingtile.s=从开始点到当前点的累计代价值Thehvalueistheheuristicwhichisanestimateofthenumberofstepsfromthegiventiletothedestinationtile.h=从当前点到目标点的步数值Thecvalueisthesumofsandh.c=s+h初始化每一点的数值
Initialtilepathsc15Examiningtile(5,6)Examiningtile(5,6)16Examiningtile(5,5)Examiningtile(5,5)17Examiningtile(5,4)Examiningtile(5,4)18Examiningallthetiles
withacostof5Examiningallthetiles
with19Examiningalltiles
withacostof6Examiningalltiles
withaco20Examiningtile(3,4)Examiningtile(3,4)21Examiningtiles(2,5)and(3,5)Examiningtiles(2,5)and(3,522Examiningtiles(1,6)(2,6)(3,6)Examiningtiles(1,6)(2,6)(3,623最终路径
ThecompletedpathS=6543210最终路径
ThecompletedpathS=24FindingadeadendFindingadeadend25exerciseexercise26区域代价值
TerrainCostTheshortestpathisn’talwaysthefastestpath.最短路径不一定是最快路径。Alongwalkalongaroadmightbefasterthanashorterwalkthroughaswamp.如有沼泽地的情况。区域代价值
TerrainCostTheshortest27对区域代价赋予数值
ScoringwithterraincostTotalcostfromstart=costfromstart+terraincostScore=totalcostfromstart+heuristic每一点总代价值=从开始点到当前点的累计代价值+区域代价值+启发式数值。对区域代价赋予数值
Scoringwithterrain28区域的种类
TypesofterrainOpenterrain平坦区域Cost=1Grassland草地Cost=3Swampland沼泽地Cost=5区域的种类
TypesofterrainOpenter29AddingdifferentterrainelementsAddingdifferentterraineleme30OriginalpathoverterrainelementsOriginalpathoverterrainele31Calculatingthelowest-costpathCalculatingthelowest-costpa32Thelowest-costpathThelowest-costpath33InfluenceMappingOtherelementscaninfluencepathcostwhencalculatingapathwithA*.其他因素也能影响路径代价。Nodesthatpassthroughthelineofsightofanyenemymightpresentahighercost.如在敌人的视线范围内,区域代价比较高。InfluenceMappingOtherelement34InfluenceMappingInfluenceMappingisawaytovarythecostoftheA*nodesdependingonwhatishappeninginthegame.依赖游戏的不同,给节点不同的代价值。InfluenceMappingInfluenceMap35敌人炮火影响的区域代价
Influencedbytheenemyfiringzone敌人炮火影响的区域代价
Influencedbythe36记录事件计算代价
RecordinggameincidentsWecanrecordindividualgameincidentsinaninfluencemap.Weareusing
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年内镜下胃病变诊疗试题及答案(消化内科版)
- 滑膜炎痤疮脓疱疹骨肥厚骨炎综合征护理查房
- 钢材供应合同
- 2026年河北省事业单位公开遴选笔试试题及答案解析
- 《新能源汽车故障诊断与排除》课件-3-2 旋变信号故障的诊断与排除
- 2026二年级上《表内乘法一》思维拓展训练
- 2026年戏剧基础课程
- 赠与协议模板
- 2026六年级道德与法治下册 心理健康成长
- 2026年特殊钢管行业分析报告及未来发展趋势报告
- 国家事业单位招聘2025中国宋庆龄青少年科技文化交流中心招聘人员笔试历年参考题库典型考点附带答案详解
- 安徽省合肥市2026届高三下学期第二次教学质量检测政治卷及答案
- 共推生态墨脱建设方案
- 上海杉达学院《金融学基础》2025-2026学年期末试卷
- 2025年重庆市渝北八中教育集团渝北校区小升初数学试卷(含解析)
- 2026安徽省交控建设管理有限公司校园招聘5人笔试参考题库附带答案详解
- 危险品司机考核制度
- GB/T 46940-2025中医药中医临床术语系统分类框架
- 生产型企业全套财务制度
- 护工预防跌倒培训课件
- 北森测评题库2024全真题(含答案与解析)
评论
0/150
提交评论