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

Soldier tactics


In order to manage multiple influence maps, we can create common initialize and update functions that wrap the update interval of different influence maps as well as the initial setup. As the SoldierTactics initialize function will be responsible for the influence map's configuration and construction, we can move the previous initialization code from Sandbox.lua:

SoldierTactics.lua:

SoldierTactics = {};
SoldierTactics.InfluenceMap = {};

function SoldierTactics_InitializeTactics(sandbox)
    -- Override the default influence map configuration.
    local influenceMapConfig = {
        CellHeight = 1,
        CellWidth = 2,
        BoundaryMinOffset = Vector.new(0.18, 0, 0.35) };

    -- Create the sandbox influence map.
    Sandbox.CreateInfluenceMap(
        sandbox, "default", influenceMapConfig);

    -- Initialize each layer of the influence map that has
    -- an initialization function.
    for key, value in pairs(SoldierTactics.InfluenceMap) do
        value.initializeFunction...