Learning Game AI Programming with Lua

Learning Game AI Programming with Lua

Language: English

Pages: 352

ISBN: 1783281332

Format: PDF / Kindle (mobi) / ePub

Learning Game AI Programming with Lua

Language: English

Pages: 352

ISBN: 1783281332

Format: PDF / Kindle (mobi) / ePub


Leverage the power of Lua programming to create game AI that focuses on motion, animation, and tactics

About This Book

  • Focus on programming game AI rather than handling low-level resource management
  • Bind Lua to build a script-based game AI using a C++ backend that provides hooks for graphics, physics, and resource handling
  • A tutorial-based approach where AI functionalities are layered piece by piece to create fully functional AI

Who This Book Is For

If you are a game developer or a general programmer who wishes to focus on programming systems and techniques to build your game AI without creating low-level interfaces in a game engine, then this book is for you.

Knowledge of C++ will come in handy to debug the entirety of the AI sandbox and expand on the features present within the book, but it is not required.

What You Will Learn

  • Create an animation state machine to drive AI animations within Lua
  • Build and find paths on navigation meshes
  • Write and debug Lua scripts within a full-scale Lua IDE
  • Develop decision logic with behavior trees, state machines, and decision trees to build modular, reusable AI
  • Manage short- and long-term knowledge representation with blackboard data structures
  • Add sensory perception to give AIs the ability to see and hear
  • Develop high-level tactics with multiple AIs based on influence maps

In Detail

Game AI can be easily broken up into a number of components such as decision making, animation handling, and tactics, but the balance and interaction between each system strikes a balance between good AI and bad AI.

Beginning with an introduction to the AI sandbox, each new aspect of game AI is introduced, implemented, and then expanded upon. Going forward, you will learn to utilize open source libraries such as Ogre3D, Bullet Physics, OpenSteer, Recast, Detour, and Lua to create an AI sandbox with an entire codebase available to expand and step through.

This is done through a step-by-step approach, from learning to move basic shapes to fully animating your soldiers. By the end of the book, your AI will be able to navigate, pathfind, manage animation playback, communicate, and perceive their environment.

Data Warehousing in the Age of Big Data

BIT601 SAP Workflow: Definition and Use of Customer-Specific Workflows (Version 62)

London Review of Books (25 April 2013)

Everything Is Obvious: *Once You Know the Answer

Favorite Design Challenges

Seascapes: Maritime Histories, Littoral Cultures, and Transoceanic Exchanges

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

downward in the case of falls. This acceleration can force agents to have a speed larger than their max speed property. Mass To access and modify the mass of our agents we can use the agent's GetMass and SetMass helper functions. local mass = agent:GetMass(); agent:SetMass(mass); The max force The maximum force of our agents can be accessed and set using the GetMaxForce and SetMaxForce functions. local maxForce = agent:GetMaxForce(); agent:SetMaxForce(maxForce); The max speed To set and

within a 100 meter range from the agent, and has less than -- 180 degree difference in forward direction. local forceToCombine = Agent.ForceToCombine(agent, 100, 180, { leader } ); -- Force to stay away from other agents that are closer than -- 2 meters and have a maximum forward degree difference of -- less than 180 degrees. local forceToSeparate = Agent.ForceToSeparate(agent, 2, 180, sandboxAgents ); -- Force to stay away from getting too close to the leader if -- within 5 meters of the leader

The walkable climb height The walkable slope angle The minimum region area Building the navigation mesh Drawing the navigation mesh 155 156 157 157 158 160 161 162 163 163 [ vi ] Table of Contents Pathfinding on a navigation mesh 164 Path query 164 Query results 164 Random navigation points 165 The path information 166 Adding random pathfinding to our soldier 166 Updating agent paths 167 Drawing paths 168 Initializing the navmesh 168 Randomly running agents 170 Creating

function Sandbox_HandleEvent(sandbox, event) if (event.source == "keyboard" and event.pressed) then if ( event.key == "f1_key" ) then local drawDebug = Sandbox.GetDrawPhysicsWorld(sandbox); Sandbox.SetDrawPhysicsWorld(sandbox, not drawDebug); end end end The following screenshot shows you the physics world that we have created: [ 114 ] Chapter 4 Adding callbacks to the animation state machine So far, our animation state machine could control animations and transitions; now, we'll extend the

AnimationStateMachine.AddStateCallback; ... end Updating the ASM to call callbacks Handling callbacks within the ASM must occur in three different places. A helper HandleCallbacks function is useful in order to reduce duplicating code. The first case we need to handle is when the ASM transitions to a state that contains callbacks. This particular case has two different variations: one where a transition exists within the ASM and another when no transition exists. The last case we handle is when

Download sample

Download