Interactive Player Agent

In an attempt to redesign the computer controlled player in Volley Brawl, we came across an interesting read on this topic. This article describes our progress on the first lesson of nucl.ai that we used to restructure our “artificial intelligence” system.

Categorizing Tasks:

According to nucl.ai, modern game AI tasks can be separated by 3 different tasks:

Sense (Input)

Think (Processing)

Act (Output)

These tasks are executed on different layers, like:

Physics & Collision

Navigation

Tactic

Behaviour

So we took a look at some of the basic tasks that already have been implemented (or planned to be) in Volley Brawl, and pinned them down in the table below:

Task

Physics

Navigation

Tactic

Behaviour

Ball trajectory path simulation

Sense

Ball bounce events

Sense

Predict where the ball is gonna hit the ground

Think

Game field consciousness

Sense

Enemy player consciousness (movement, position, abilities)

Sense

Generate good points of the ball path

Think

Select the best point of the ball path to hit how

Act

Move and jump towards the best point

Act

Player locomotion

Act

Aim: find possible targets

Think

Aim: select of possible targets/areas

Think

Aim: refine the best point

Act

Aim: predict possible ball trajectories

Think

Find the best way to the best point

Think

Blast and crouch blast

Act

Try to play defense, set, smash or block

Think

After filling out this table, we might have considered to drop the Behaviour layer at all. We just leave it in here, maybe we need it later, nobody knows.

Setting up the backbone

Following the principle “divide et impera” for code separation, Unity offers to slice your functionality into scripts and also empty game objects. We make use of both. Game Objects should be the rougher structure and scripts a bit finer. So we tried this: using one game object per layer and adding different scripts with the prefix Sense/Think/Act for the tasks on that layer.

This is what we got in the hierarchy when we put the functionalities from above into scripts:

Task

Game Object (Layer)

Script

Ball trajectory path simulation

Physics

SenseBallTrajectory.cs

Ball bounce events

Physics

SenseBallTrajectory.cs

Predict where the ball is gonna hit the ground

Physics

ThinkBallTouch.cs

Player locomotion

Physics

ActPlayerLocomotion.cs

Blast and crouch blast

Physics

ActBlast.cs

Game field consciousness

Navigation

SenseGameField.cs

Aim: find possible targets

Navigation

ThinkFindTargets.cs

Find the best way to a target point

Navigation

ThinkNavigateTarget.cs

Move and jump towards the best point

Navigation

ActMoveTowardsPoint.cs

Aim: refine the best point

Navigation

ActPrepareBlast.cs

Enemy player consciousness (movement, position, abilities)

Tactic

SenseEnemyAction.cs

Generate good points of the ball path

Tactic

ThinkSelectBestPoint.cs

Aim: select possible targets

Tactic

ThinkSelectTarget.cs

Try to play defense, set, smash or block

Tactic

ThinkDefineNextBallTactic.cs

Select the best point of the ball path to hit how

Tactic

ActSelectBestPoint.cs

Conclusion

While doing game development, we’ve rarely planned implementations in a similar way before. But it feels good to write these things down. Maybe this is not the way nucl.ai has thought of the structure when making their tutorials, but it seems to follow some kind of logic.

For sure, we will come up with further changes during the implementation of these scripts. Also, we’ll have to think of good ways to connect the scripts in order to avoid too much chaos and cross-referencing. After all, some structure is better than no structure. We’ll soon find out if it works out for us and are hoping this will push our computer enemy logic another great step forward.

Feel free to watch the next development steps of Volley Brawl yourself,