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

Decaying auditory events


Now, we can update our AgentSenses update loop to prune both the bulletImpacts as well as bulletShots entries that are being stored on the blackboard. Pruning out old events prevents Lua from consuming large amounts of data, as both of these event types occur frequently:

AgentSenses.lua:

function AgentSenses_UpdateSenses(
    sandbox, userData, deltaTimeInMillis)

    PruneBlackboardEvents(
        userData.blackboard,
        "bulletImpacts",
        deltaTimeInMillis);
    
    PruneBlackboardEvents(
        userData.blackboard,
        "bulletShots",
        deltaTimeInMillis);
    
    ...

end