Game
Vitality
7 years ago

NPC Task System - AI system architecture


The last few weeks have been spent focusing on NPC AI. Here’s a picture showing off an NPC performing a set of tasks (involving navigation, and the task action):

5d0ab3d2253e1.gif

With the pathfinding system implemented, the next step was to create a scalable NPC-AI system that achieved the following things:

  • Easy-to-program high-level NPCs. This means that if we wanted to add a new type of NPC, getting it to perform actions would be very simple, and the custom NPC types shouldn’t need any complex code in themselves, that should be hidden away.

  • A queue system that allows us to give NPCs progressive tasks that it will carry out in order.

  • Easy addition of new tasks the NPC can perform, and new states the NPC can be in. (An example of a task might be “break block”, “place block”, “eat food”)

  • A robust navigation module that tasks and states can utilise so that the tasks themselves do not have to worry about how to get to where they need to be.

  • A failure system that handles different types of task failure when an NPC is unable to complete a task for whatever reason.

  • Finally, a modular/layered task priority system that allows quest controllers, or world event controllers to take over an NPCs behaviour.

This new system has required quite a vast amount of work, and is currently still a work-in-progress. Currently, we have implemented a number of task behaviours, though there are more to add.

One particularly nice thing is that each task has a range of properties, including a “quick” completion check. This means that in the case of placing and breaking blocks, multiple NPCs could all be given the same tasks, and if one of those tasks has been completed by another NPC, it can detect its completion and move onto a new task.

This means that getting NPCs to all build a house together requires no extra programming work than just telling one NPC to do it! This is going to be really neat for building and mining tasks that are carried out progressively by NPCs!



0 comments

Loading...

Next up

Into the Mines! - Medieval Mineshaft Generation

NPC Shops

Who brought the marshmallows? 🔥🔥🔥

Windmills!

The Ol' Tavern - Medieval Age Town gen

Medieval Town - Generation progress

World Map

Improved lightning and thunderstorms! Longer video (with sound) here: https://www.youtube.com/watch?v=DHSL9U4Jy-E

The end of an era... 🦖☄️💥🔥

Really happy with the results of new lighting system! :D