Skip to Content
Lua游戏AI开发指南
book

Lua游戏AI开发指南

by Posts & Telecom Press, David Young
May 2024
Beginner to intermediate
327 pages
4h 38m
Chinese
Packt Publishing
Content preview from Lua游戏AI开发指南

第5章 导航

本章主题:

  • 生成导航网格;
  • 根据导航网格寻路;
  • 获取路径信息;
  • 根据导航网格移动战士;
  • 多重导航网格。

到目前为止,我们的注意力都集中在智能体上;现在我们来看看智能体所处的环境。我们将利用导航网格(navigation mesh,也称navmesh)来让智能体四处移动。导航网格是智能体可移动区域的一种多边形表示法。

不像其他由Lua实现的系统,导航网格和寻路将使用开源的Recast和Detour库。Recast库和工具负责由沙箱的关卡几何体生成导航网格,Detour则负责基于该网格进行寻路。

沙箱中的智能体调用Detour的服务来获取路径,然后遵循获取的路径移动。这样的数据分离可以让我们重用沙箱中的导航网格和多重导航网格,从而避免Detour或Recast和智能体直接交互。

导航网格的生成会用到沙箱中所有的固定几何体。生成导航网格的C++端代码负责将沙箱的表达传入Recast库。任何质量为零的SandboxObject对象(也就是固定对象)将用于导航网格的生成。

提示.tif 

平面不会用于导航网格的生成,所以地面要用网格或盒子来表示。

在图5-1中可以看到一个导航网格。

图片 794

图5-1 导航网格

生成导航网格时需要了解将使用这个网格的那类智能体的一些基本信息。除非在生成时另外提供配置数据,否则沙箱会默认地自动填充导航网格的配置。可以通过一个Lua表来为Recast提供覆盖数据。下面的代码片段展示当不提供覆盖数据时, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty
Python计算机视觉和自然语言处理

Python计算机视觉和自然语言处理

Posts & Telecom Press, Álvaro Morena Alberolaï, Gonzalo Molina Gallegoï, Unai Garay Maestreï
面向MapReduce的Hadoop优化

面向MapReduce的Hadoop优化

Posts & Telecom Press, Khaled Tannir

Publisher Resources

ISBN: 9781836205555