Project Page | Director Ai

Director Ai for Shooter and Survival Games

Published: Jan 30th, 2023 | Updated: Oct 4th, 2024


Gameplay preview of the AI Director within a simple shooter and survival game.

Introduction

Welcome to the Project Page for my Director AI system, a project I undertook as part of my bachelor's degree dissertation in Games Technology. The following sections will give an overview of the project such as it's core features and limitations, the technical challenges faced and how I overcame them, before concluding with a reflection on what I learnt and future plans for the project. Code samples can be found at the end of this page.

Background - The AI Director of Left 4 Dead

The developers of the first-person shooter game Left 4 Dead wanted to provide a challenging, engaging, and fresh experience for their players on every play. To achieve this, they developed a system they called an AI Director, a collection of systems that worked together seamlessly to govern the pacing and how the drama unfolded. It was an AI that operated behind the scenes rather than as an in-game physical entity.

Under the hood, the AI Director analysed the performance of each player and based it's decisions upon a perceived player stress metric that it continually calculated for each player. Through this, it was able to decide when it perceived was the right time was to spawn more enemies, how many of them to spawn, what type of enemy to spawn, and more. The Director also had the capability to modify the level layout to open up new paths dynamically based on certain conditions, and more. These capabilities enabled the Director to craft the best gameplay experience it could for its players.

The following video explores what an AI Director is in greater detail.

Concept

Inspired by the AI Director in the Left 4 Dead series, this project aimed to create a more versatile Director system that game developers could integrate easily into their own projects regardless of its genre. It was important therefore that the system architecture was modular and generic in nature so that rules and behaviours could be processed by a single system. This is one of the fundamental challenges this project attempts to solve.

Scope

To evaluate the versatility and effectiveness of the Director, two distinct game genres were chosen to develop Director systems for. The shooter genre was an obvious first choice, a domain where the Director has already been extensively tested and proven to work in. This first system would act as a reliable benchmark to compare the second Director system against. The second genre selected was the survival genre, a highly popular and mechanically different genre to shooter games.

Tech Stack

  • Engine/Framework/Library: Unity (2021.1.21)
  • Programming Language: C#
  • IDE: JetBrains Rider
  • Operating System: Windows

Technical Challenges

Rule System

In the early stages of development, the project faced significant challenges in creating a single rule system that could process rules across various game genres. The initial design suffered from being dependant on hard-coded rules that were tightly coupled to specific game logic and scripts in each game.

As development and research progressed, the Rule pattern was discovered. This powerful design pattern allows for the encapsulation of conditional logic into their own self-contained and reusable rule classes. This approach provided a high degree of modularity, flexibility, extensibility, and readability and addressed the core issue of having to make significant changes to the existing codebase to integrate new rules.

Key Features

  • Games
    • Top-down Shooter Game
    • Top-down Survival Game
  • Rule-based Architecture
    • Intensity Rule Engine
    • Behaviour Rule Engine
    • Intensity Rule Calculator
    • Behaviour Rule Calculator
  • Active Area Set
    • Dynamic Tilemap Processing
    • Dynamic Enemy Population
    • Dynamic Item Spawning

Strengths

  • Highly Customisable - Designers can tweak and customise the director according to their own needs and preferences.
  • Easy Deployment - The Director can quickly and easily be deployed by dropping it's prefab into the scene and setting the necessary data requirements for the inspector.
  • Flexible Rule Processing - Rules for both shooter and survival games can be processed by the system with the capability to adapt to other genre types too.
  • Dynamic Tilemap Processing - Through the Active Area Set (AAS) system, the Director is able to process a given tilemap level and determine viable enemy spawn locations.

Limitations

  • Rules Must Be Manually Added - Designers are required to access the code directly to write rules and add them to the rules list. A custom editor tool should be built that will allow a designer to easily create and add rules to the rule engine without having to access the code directly.
  • Lack of Rule Evaluation Techniques - Intensity rules are only fired based on the highest weighting output. Further techniques could be employed such as executing rules sequentially, at random, based on priority, or firing the first to match a condition.
  • 2D Environment Focus - The current implemented is limited to 2D game environments and so does not support 3D environments.

Learning Highlights

  • Design Patterns
    • Rule pattern
    • State pattern
    • Event Buses
  • System Design
    • Interfaces
    • Modular architectures
  • Data Structures
    • Dictionaries
  • Level Design
    • Tilemaps
  • Optimisation
    • State caching

Future Plans

  • Rework director state logic using a state machine
  • Utilise more methods of rule execution
  • Handle rule creation using a custom editor tool
  • Adapt the Active Area Set (AAS) to work with 3D environments
  • Integrate efficient entity reuse into the AAS system using Object Pooling
  • Develop and integrate an attractor system
  • Develop a complete game and fully-fledged and integrated Director system

Conclusion

This project was an invaluable learning experience, offering profound insights into the development of a simple yet powerful system that empowers designers to create their own rules for shooter and survival games. Additionally, this project served as a compelling proof of concept, demonstrating how such a system can be effectively integrated into other video game genres.

Demos

Code Samples

Core


Rule Engine


State Machine


Unity Inspector


Director Inspector View

ActiveAreaSet Inspector View

Other Resources

Thesis Paper | GitHub Repository | Project Showcase