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

Creating agent senses


With basic agent communication out of the way, we can give our agents the ability to determine visibility with other agents.

Initializing senses

Initializing our agent's senses will follow a functional paradigm that is very similar to what we've used previously. Passing our userData table inside our initialization function will provide any custom per agent data we'll need going forward:

AgentSenses.lua:

function AgentSenses_InitializeSenses(userData)
end

Updating senses

Updating agent senses is nearly identical to initialization, except that we pass in the sandbox and a deltaTimeInMillis time difference, so we throttle the update rate of individual senses:

AgentSenses.lua:

function AgentSenses_UpdateSenses(
    sandbox, userData, deltaTimeInMillis)
end