Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Controlling groups of AI


In this recipe, we'll kill two birds with one stone and implement both an interface for group AI management and look at weighted decision making.

In many ways, the architecture will be similar to the Decision making – Finite State Machine recipe. It's recommended to have a look at it before making this recipe. The big difference from the normal state machine is that instead of the states having definite outcomes, an AI Manager will look at the current needs, and assign units to different tasks.

This recipe will also make use of an AIControl class. This is also an extension of the AIControl that can be found in the Creating a reusable AI control class recipe.

As an example, we'll use resource gathering units in an RTS. In this simplified game, there are two resources, wood and food. Food is consumed continuously by the workers and is the driving force behind the decision. The AI Manager will try to keep the levels of the food storage at a set minimum level, taking into...