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

第7章 知识表达

本章主题:

  • 创建知识源;
  • 创建黑板架构;
  • 使用黑板来支持决策求值器和动作。

到目前为止,我们的战士已经可以从许多不同地方的不同来源获取输入了。比如,使用条件求值器来计算最佳攻击对象是一种很简陋的做法,它没有利用战士拥有的关于沙箱的知识。现在,我们将把知识统一存放在一个中心数据结构中,它可供整个代理系统使用。

对现在的战士智能体来说,主要有两个知识来源:userData数据结构和逻辑求值器的动态计算结果。虽然这两种技术都可行,但两者很快会变得不可扩展,因为没有一个中心系统来控制它们的更新、修改和被访问的频率。

我们可以把这些需要复杂计算的知识源封装到一个它们自己的数据结构中。一旦对这些数据源进行了抽象,我们就可以管理它们的更新频率、缓存计算结果并统一访问接口。

知识源有一些主要特征:计算结果缓存、计算置信度和更新频率。缓存计算只不过是KnowledgeSource实例内部存储的求值器函数的计算结果。置信度数值处于0到1之间,知识数据结构使用它决定在某个时间最好应该使用哪一条知识数据。更新频率用来决定在一次计算被调用时,知识源是否需要重新调用求值器函数来更新计算结果。当同一个知识源用在一个逻辑结构的多个地方时,这个值通常可以用来避免求值器的重复计算。

KnowledgeSource.lua:   KnowledgeSource = {};   function KnowledgeSource.new(evaluator, updateFrequency)     local source = {};     -- The KnowledgeSource's data members.     source.confidence_ ...
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, Dipanjan Sarkar, Raghav Bali, Tamoghna Ghosh
R深度学习权威指南

R深度学习权威指南

Posts & Telecom Press, Joshua F. Wiley
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9781836205555