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

第6章 决策制定

本章主题:

  • 为智能体行为创建可重用动作;
  • 构建用于决策的条件求值器;
  • 创建构成自治智能体的决策树结构;
  • 创建有限状态机来处理基于状态的智能体;
  • 为反应式智能体创建行为树。

我们的智能体已经有了动画并能在环境中移动,现在我们将给它添加高层的决策能力。这些数据结构最终将使得智能体能够自主地与周围环境以及其他智能体进行交互。

迄今为止,我们一直在使用全局数据来存储智能体的信息。由于创建决策结构需要了解智能体的信息,我们将创建一个自定义类型表的局部变量来存储一些特别的智能体数据和用于管理动画处理的智能体控制器。

  local userData =
  {
    alive, -- terminal flag 
    agent, -- Sandbox agent 
    ammo, -- current ammo
    controller, -- Agent animation controller
    enemy, -- current enemy, can be nil 
    health, -- current health
    maxHealth -- max Health
  };

更进一步,我们将封装更多的数据以便把系统代码从全局变量中分离出来。一个userData表是存储智能体尚未拥有的任意数据的理想位置,它同时还提供了一个通用的存储区域来存储用于智能体数据操作的数据结构。目前为止,列表中的数据成员就是一些将要存储的通用信息;当我们开始创建各个行为时,将访问和修改这些数据。

我们创建的任何决策逻辑和结构最终都要归结于决定智能体需要执行的动作。动作本身是一种独立的数据结构,它由3种状态组成: ...

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

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

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

Posts & Telecom Press, Álvaro Morena Alberolaï, Gonzalo Molina Gallegoï, Unai Garay Maestreï
机器学习和AI精粹

机器学习和AI精粹

诺亚·吉夫特
Java数据科学实战

Java数据科学实战

Michael R. Brzustowicz, PhD

Publisher Resources

ISBN: 9781836205555