人工智能ppt课件第五次课.ppt

上传人:小飞机 文档编号:1622019 上传时间:2022-12-11 格式:PPT 页数:41 大小:3.36MB
返回 下载 相关 举报
人工智能ppt课件第五次课.ppt_第1页
第1页 / 共41页
人工智能ppt课件第五次课.ppt_第2页
第2页 / 共41页
人工智能ppt课件第五次课.ppt_第3页
第3页 / 共41页
人工智能ppt课件第五次课.ppt_第4页
第4页 / 共41页
人工智能ppt课件第五次课.ppt_第5页
第5页 / 共41页
点击查看更多>>
资源描述

《人工智能ppt课件第五次课.ppt》由会员分享,可在线阅读,更多相关《人工智能ppt课件第五次课.ppt(41页珍藏版)》请在三一办公上搜索。

1、A*路径搜索A* Pathfinding,We are going to discuss the fundamentals of the A* pathfinding algorithm. 基本A*路径搜索算法The A* Algorithm provides an effective solution to the problem of pathfinding.,定义搜索区域Defining the search area,The first step in pathfinding is to define the search area. 首先定义搜索区域。The game world n

2、eeds to be represented by points that both the game characters and objects can occupy.We need to reduce the nodes to a manageable number, which is what we mean when we say we need to simplify the search area. 减少搜索区域的节点数量,简化搜索区域。,定义搜索区域Defining the search area,基于方块的搜索区域Tiled search area,Starting the

3、search,We will use the A* algorithm to find the shortest path between any two nodes while avoiding the obstacles. 避开障碍在任意两点之间用A*算法获得最短路径。 OpenList-We need a way to keep track of which tiles need to be searched. 可以作为后备检测的点的集合; ClosedList-the tiles that already were checked. 已经检测完成的点的集合。,A*伪代码A* pseud

4、o code,Add the starting node to the open listWhile the open list is not empty current node=node from open list with the lowest cost if current node=goal node then path complete else move current node to the closed list examine each node adjacent to the current node for each adjacent node if it isnt

5、on the open list and isnt on the closed list and it isnt an obstacle then move it to open list and calculate cost ,A*伪代码A* pseudo code,将开始点加到Open List表中;重复一下过程,直到Open List表空为止: 当前点=OpenList表中代价值最小的点; 如果当前点为目标点, 则 搜索完成; 否则 将当前点移到ClosedList表中; 对与当前点相连的每一点,重复执行: 如果该点不在OpenList、ClosedList,并且不是障碍点 则 将该点移

6、到OpenList表中,计算该点的代价值;,Create a tiled search area,Spider-starting pointHuman character-destinationSolid black squares-wall obstacles,Adjacent tiles to consider,We proceed to check each of the eight adjacent tiles and then add each valid tile to the open list.对与蜘蛛相邻的八个点检查,不在任何表中和不是障碍的点加入OpenList表中。,将开

7、始点移到Closed List表中Moving the starting tile to the closed list,Start point开始点,Linking to the parents,Link to parents,赋予数值Scoring,We will use path scoring to determine the best path from the starting tile to the destination tile.(1) We look at the cost to move from the starting tile to any given tile.(

8、2)We look at the cost to move from the given tile to the destination tile.(3)We take the sum of the cost of each tile that leads back to the initial location.,Calculating the path score,Score=Cost from start+HeuristicWe will check the tiles with the lowest cost.A lower cost will equate to a shorter

9、path.,Start point,given point,destination,Cost from start,heuristic,Initial tile path scores,初始化每一点的数值Initial tile path scores,The s value is the cost of getting there from the starting tile. s=从开始点到当前点的累计代价值The h value is the heuristic which is an estimate of the number of steps from the given tile

10、 to the destination tile. h=从当前点到目标点的步数值The c value is the sum of s and h. c=s+h,Examining tile (5,6),Examining tile (5,5),Examining tile (5,4),Examining all the tiles with a cost of 5,Examining all tiles with a cost of 6,Examining tile (3,4),Examining tiles (2,5) and (3,5),Examining tiles (1,6)(2,6

11、)(3,6),最终路径The completed path,S=6543210,Finding a dead end,exercise,区域代价值Terrain Cost,The shortest path isnt always the fastest path. 最短路径不一定是最快路径。Along walk along a road might be faster than a shorter walk through a swamp. 如有沼泽地的情况。,对区域代价赋予数值Scoring with terrain cost,Total cost from start=cost from

12、 start+terrain costScore=total cost from start+heuristic 每一点总代价值=从开始点到当前点的累计代价值+区域代价值+启发式数值。,区域的种类Types of terrain,Adding different terrain elements,Original path over terrain elements,Calculating the lowest-cost path,The lowest-cost path,Influence Mapping,Other elements can influence path cost when

13、 calculating a path with A*. 其他因素也能影响路径代价。Nodes that pass through the line of sight of any enemy might present a higher cost. 如在敌人的视线范围内,区域代价比较高。,Influence Mapping,Influence Mapping is a way to vary the cost of the A* nodes depending on what is happening in the game.依赖游戏的不同,给节点不同的代价值。,敌人炮火影响的区域代价Inf

14、luenced by the enemy firing zone,记录事件计算代价Recording game incidents,We can record individual game incidents in an influence map.We are using what the character does.If the player repeatedly ambushes and kills computer-controlled characters at a given doorway, that the doorway might increase in cost. 如

15、果玩家在门口重复地伏击并杀死角色,则门口的代价增加。,Influenced by the number of kills,小结,A*算法的基本思想;对区域代价的搜索实现的算法分析;在运行过程中代价的改变。,思考题,(1)A*算法的核心思想是什么?(2) A*算法与其他(如基本路径搜索)算法有何不同?(3)在路径搜索算法中为什么A*算法是最有效的算法?(4)A*算法有何不足?遇到什么样情况不是最快的搜索算法?,本次实验内容,用A*算法实现路径搜索。如有时间,可以考虑区域代价情况的搜索。在实现过程中,对代价可采用数组方式记录代价值。感兴趣可以将根据运行状况改变代价值的思想,运用到实际的游戏或优化系统中。,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号