Posts

Showing posts from November, 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