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开发指南

第2章 创建并移动智能体

本章主题:

  • 构建第一个沙箱可执行程序;
  • 创建第一个沙箱Lua脚本;
  • 理解智能体的属性和作用;
  • 基本的牛顿运动;
  • 智能体转向力;
  • 创建探索、追逐、路径跟随和群组智能体。

到目前为止,我们已经了解了AI沙箱的创建和一些底层的系统结构,现在我们将从头创建一个新的沙箱示例程序。从本章开始一直到本书结束,我们会逐渐地向这个示例中添加新的Lua沙箱API,包括更多的AI功能、动画、图形和游戏性。

由于沙箱程序处理了图形和物理方面的繁重工作,核心的AI逻辑将全部由Lua语言实现,但它仍依赖一些由C++管理的数据结构。

首先,为了创建一个新的沙箱可执行程序,我们需要在Premake构建脚本中声明一个新的Visual Studio示例项目。打开SandboxDemos.lua脚本文件,在SandboxDemos表中添加一个新项。你可以将项目命名为my_sandbox或者任何你喜欢的名字。项目的名字就是构建出来的可执行程序的名字。

SandboxDemos.lua:

   SandboxDemos = { 
       "chapter_1_introduction",
       ...
       "my_sandbox"
   };

提示.tif 

沙箱示例程序的所有复杂配置都位于premake.lua文件的CreateDemoProject函数中。Remake.lua文件只是简单地遍历SandboxDemos表的每一项以创建项目并设置它的源代码文件、项目依赖项、库的头文件等。

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