Posts

Showing posts from 2018

Implementing Behaviour Tree Framework

Image
I spent this week implementing the basic framework for my Behaviour Tree (BT) architecture, for this first iteration I only implemented the basic nodes that will be required within the tree, such as the Selector and Sequence Composite nodes.  I will be looking into including other nodes types as the project develops if I am able to find a use for them, such as decorator nodes or random sequence / selector nodes. I also had to work towards creating a very basic blackboard system for the agent, this first iteration of the blackboard just contains a small selection of variables to help hold the information while the BT changes between the two leaf nodes currently implemented, however I will be building upon this blackboard and a global blackboard shared between all agents.  When I build upon the blackboard I will attempt to use a "Dictionary"  as in a previous blackboard I had to create during my second year of studying I used "Map"  in C++ and felt this worked in th

Learning About Delegates

While researching into Behaviour Trees (BT) in Unity I kept coming across the "delegate"  keyword so I decided to research further into the use of delegates. Delegates can be "used to pass methods as arguments to other methods"  (Docs.microsoft.com, 2018) and if you read further through the Microsoft  documentation on delegates it further clarifies the similarity to " C++ function pointers, but delegates are fully object-oriented, and unlike C++ pointers to member functions, delegates encapsulate both an object instance and a method."  (Docs.microsoft.com, 2018). As shown in the Unity scripting tutorial on delegates they are created by using the keyword "delegate void MyDelegate(int num);" (Unity, 2018)   and shows how the delegate variable can be reassigned to different methods however they must have the same return type. I also watched a couple of videos on YouTube about delegates, and although I feel like I now understand them, I'm n

Implementing Line of Sight (LoS)

Image
I started implementing Line of Sight (LoS) for my guard AI, to do this I have created a large sphere collider around each guard which will act as their viewing distance, the radius is currently set to 10, however this can be adjusted as necessary once the rest of the systems are implemented in terms of balancing. To work out the view angle I am using Vector3.Angle where the " angle returned is the unsigned angle between the two vectors" (Docs.unity3d.com, 2018)  where one vector is the direction between the player and the guard, and the other vector is the guard's forward vector. I then send out a raycast to the player, this is to check if there are any obstructions such as a wall, however I was having trouble with this as when another guard's "view collider" was in the way, they could no longer see the player, which was an undesirable effect.  To try and diagnose the problem I used Debug.DrawRay to see where the problem was, however this still drew the

Researching Different AI Techniques - Behaviour Trees (Part 3)

Image
When designing AI for video games, they must act in an intelligent way while carrying out their tasks and behaviours. Originally the way this was done was using finite-state machines (FSMs) which are an “architectural structure used to encapsulate the behaviour of discrete states” (Graham, 2017). FSMs are still widely used within the games industry but are suited towards games that have less intensive AI. This is because as an FSM grows they begin to become unmanageable as each state needs to be able to transition with all other states, and if another state is added later into production, or one is removed the state transitions would need to be adjusted across the project. Although this problem can be slightly mitigated with the use of a hierarchal finite-state machine (HFSM) Which allow you to create transitions “once to super-states rather than each state individually.” (Champandard, 1, 2007) Helping to reduce the amount of redundant transitions. Behaviour Trees (BTs) have bec

Setting Up The Scene

Image
This week I made a start on the Unity project, setting things up to begin building my AI systems.  I am using Unity3D 2018.2.15.  I have created a white box scene to begin with as described by j. Hocking which contains three rooms.  Once I had created the simple scene I proceeded to download the sample assets provided by Unity to gain access to their "Ethan" character, I will be using their provided Third Person Controller for the player and currently just the model for the AI Enemies, at a later date I will incorporate the animations for the enemies. Once I had imported the assets I needed I set up some way points around the scene to be used with the NavMesh agent.  Near the end of the project if there is time I will look into implementing my own path-finding system.  The NavMesh system has been set up for the AI to randomly select one of the three way points and move towards it, this is all handled within the same script, however the AIs movement will be determined based

Researching Different AI Techniques - Behaviour Trees (Part 2)

Image
Autonomous agents need to be reactive to situations happening in the world around them, especially in the sense of a guard artificial intelligence (AI) which will need to react to the player's actions.  Collendanchise and Ogren talk about the trade of between modularity and reactivity "in terms of the classical Goto statement that was used in early programming languages" (Collendanchise and Ogren, 2018)  The Goto statement is as a one-way control transfer  which caused the program to jump to another section of code and continue execution from there rather than the more common two-way control transfer  where code jumps down to perform the execution, then returns to where it left off such as calling a function.  Finite State Machines (FSMs) execute code similar to the one-way control transfer as each state needs a transition to and from the state, so "a new state or behavior[ sic ] to a character requires not only coding the new state itself but also adding the transit

Handing Proposal In - Start of Project

Today was deadline day for the project proposal, after some initial reading I honed my thesis to read; "Using a behaviour Tree to Control the Behaviours of Artificial Intelligence in a Stealth Environment" While I am waiting for the proposal to be accepted or rejected I will spend a small amount of time reading a few more texts on Behaviour Trees (BT) that I have found in Programming Game AI Wisdom 4.  After reading the two short chapters I will honour my timeline and begin building the Unity Project, and learn how to use the NavMesh, I will also need to look into ProBuilder which became integrated into Unity in 2018.1, I will be using (at the time of writing) Unity 2018.2.15f1. ProBuilder will help me quickly build and iterate different test scenes to test my artificial intelligence (AI) in.  Reference List [1] Unity. (n.d.). Building a NavMesh. [online] Available at: https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html [Accessed 7 Nov. 2018]. [2] Unity. (n.d

Research AI Techniques in Other Games - Alien Isolation

Alien Isolation is "one of the biggest AI driven titles of modern times" (AI and Games, 2016) that uses a technique called Psychopathic Serendipity which "indicates that the creature is guided by its own procedural intelligence rather than the canned foreknowledge of a game designer: [sic] "   (Keogh and Jayemanne, 2018) this will help the alien to always find a way to disrupt and mess with the player, even the alien cannot see them, to pull this off the alien cannot be scripted and must work off events triggered by the player, such as noise while being guided by the game.  For the creation of Alien Isolation, Creative Assembly used a Two Tier System to control the alien. A Macro AI and a Micro AI. The Macro AI is similar to a director or God-Like entity that is always watching the current situation of the game world and has a constant reference to what is happening with and the current states of the player and the alien.  This means that the Macro AI will al

Research AI Techniques in Other Games - Halo 2

After watching a brief video by AI in Games called " The Behaviour Tree AI of Halo 2 ".  In this video they explain how Bungie made the artificial intelligence (AI) in Halo use the narrative of the game to visual show the player how the AI will react to the character. Using this method the player quickly understands that; Grunts   are small creatures that act in a scared manner. Jackals  are shifty creatures and act as snipers. Elites  are big and aggressive leader type characters Using this the player can quickly understand how the AI will react to certain events in the world, usually caused by the players actions. The AI in Halo is controlled by a Behaviour Tree (BT).  Because of this the AI in Halo reacts on what is happening and will traverse the tree asking "what is happening in the world, and what should I do?" and based on the predefined conditions, the agent will perform the appropriate behaviour. Halo's AI is able to think in context depe

Starting Proposal

This week I will be making a start on my proposal, using the research I have done over the past few weeks and what I have learnt over the past two years of University to formulate the thesis for my final project. I have currently been looking into different AI techniques, such as finite-state machines (FSM), hierarchal finite-state machines (HFSM) and behaviour trees (BT).  Previously I have used a FSM and a BT during my time at University.  I liked how simple and easy it was to implement an FSM however, I would like to make a complicated artificial intelligence (AI) agent with lots of states and actions to make it seem 'smart'.  If I used an FSM or a HFSM this could become very confusing with multiple transitions to states, and as I add more states throughout the course of the project it will soon become very hard to manage it all. For this reason I have decided to research further into BTs.  I aim to create the AI for a stealth based environment to test my knowledge of th

Researching Different AI Techniques - Behaviour Trees

I started reading "Getting Started with Decision Making and Control Systems" by Alex J. Champandard In this chapter Champandard speaks about different support frameworks, such as the schedular which can manage the tasks used in the system calling them one after the other during its update step.  Champandard (2014) then goes on to give a basic scheduler example Class Scheduler { public:           bool run (Task&);           bool halt (Task&);           void update(); protected:           struct Entry           {                  Task* task;                  Status status;                  // Other data for execution            };             std::vector<Entry> m_ActiveTasks; } Champandard then explains about task observers, that can watch other tasks deriving from a virtual base class, these should contain a function that is run once a task has finished executing, this allows the observer to complete actions and tasks as re

Researching Different AI Techniques - Steering Behaviours

Steering behaviours are a way of moving an agent autonomously around the game scene.  Steering behaviours were brought about by Craig Reynolds when he demonstrated his flocking behaviour, which was based on a simple set of rules.  A definition for an autonomous agent given by (Buckland, 2005, p85) "An autonomous agent is a system situated within and a part of an environment that senses that environment and acts on it, over time, in pursuit of its own agenda and so as to effect what it senses in the future." To get a better understanding of how an autonomous agent works (Reynolds, 1999) explains that you can divide the behaviours into several layers, these layers are; Action Selection Strategy Goals Planning Steering Path determination Locomotion  Animation Articulation There are different steering behaviours that cause an agent to act in different ways.  The first behaviour I will explain is the seek behaviour. The seek steering behaviour guides the

Researching Different AI Techniques - Hierarchical Finite-State Machine

Image
While researching into Finite-State Machines (FSMs) I came across a Hierarchical Finite-State Machine (HFSM).  (Buckland, 2005) explains them as "a state itself contain a state machine.".  This means if an agent has a combat state, that state might contain an FSM that manages the states needed for combat, such as dodge and shoot. A HFSM is similar to a FSM where the logic is built up state by state, however, in an HFSM states are grouped together to create a super state.  This allows the programmer to make transitions between the super states, rather than applying them to each individual state.  This reduces redundant transitions as they are only applied once to the super state. HFSMs make use of inheritance, this allows each substate of a super state to override specific behaviours, this allows internal transitions that are not recognised by the super state.  However, HFSMs still have issues with transitions between states which can become tedious.   Reference List

Researching Different AI Techniques - Finite-State Machine

For my Final Project module I have been asked to pick a subject I have studied over the past few years of University, that I have enjoyed and would like to improve my knowledge of.  For this I have selected to research into Artificial Intelligence (AI).  The reason for this, is during my second year of University I had to complete an AI module using Torcs which is "an open-source 3D car racing simulator" (En.wikipedia.org, 2018) using one of the methods we had learnt previously, these are; Finite State Machines (FSM) Steering Behaviours  Behaviour Trees Although there were different AI techniques we had learnt, we were instructed to pick one or more of these techniques and control a car around a track, I used a Behaviour Tree to control mine.   To begin my research into AI I will be looking at Finite-State Machines (FSM) and how they can be applied to games.  A FSM as described by (Buckland, 2005) "is to decompose an object's behavior [ sic ] into easily ma