Book Image

Learning Game AI Programming with Lua

By : David Young
Book Image

Learning Game AI Programming with Lua

By: David Young

Overview of this book

Table of Contents (16 chapters)
Learning Game AI Programming with Lua
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with AI Sandbox
Index

Events


So far, each of our agents run within their own virtual machine and communicating between them is not easy. To alleviate this, we can create a data structure called an event, which can be passed between agents or the sandbox itself.

Attributes

Creating an event is as simple as creating a table within Lua with a few restrictions. As events are serialized by the sandbox and passed to each virtual machine, only simple table attributes can be added to the event.

Each supported attribute is listed as follows:

Event attribute type

Description

boolean

A true or false Lua value

number

Any Lua number internally represented as a float value

object

A code object, the sandbox, sandbox object, or an agent

string

Any Lua string value

vector

Any vector created from Vector.new

Note

Events might not have nested tables within them; any unsupported attribute type will be discarded during the serialization. Currently, this is a limitation of event serialization of the C++ side of the...