版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 20万立方米可燃冰储罐技改项目可行性研究报告
- 2026年中国肉类加工行业竞争格局分析及投资战略咨询报告
- 2026年广州农商银行招聘试题及答案
- 圆盘锯安全技术培训课件
- 氯甲烷回收岗位压缩机安全操作规程培训
- 锅炉与压力容器安全技术培训
- 破碎岗位安全操作规程培训
- 农用机车故障应急处理技术培训
- 空分冷箱珠光砂爆炸事故原因分析与预防培训
- 运焦主控工岗位操作规程培训课件
- 2026年护理管理基础考试练习试题(附答案)
- 2025年液压支架工职业技能竞赛参考试题库500题(含答案)
- 2026年癌症早筛早诊早治宣教课件
- 高标准农田建设项目初步设计技术规程(NYT 5490-2026 )
- (2026年秋)外研版七年级英语上册教学计划
- T∕CCEAS008-2026 建设工程造价咨询成果文件质量标准
- 2026-2030中国液体硅酸钠市场销量预测及未来发展策略分析研究报告
- 产业基金投后管理专项招聘笔试参考题库 含答案
- 四级养老护理员测试试题库及答案
- GB/T 37977.61-2026静电学第6-1部分:医疗、商业和公共场所的静电控制医疗卫生
- 高考考前必背核心要点(核心知识)-2026年高考生物二轮复习
评论
0/150
提交评论