I MADE AN AI, HOLY forget :O
So, you might be going, "Ben, that looks loving stupid and probably fake you lying cunt. How the forget is this thing an AI?" Well, I didn't study AI systems at all, so I've just been working completely from scratch on a concept I've had in my head. I'm going to study AI algorithms soon, once I feel like I've reached a point where I need help.
VacBot, the cute little yellow cube, is based on this task-based system I've been working on. Aside from the fact he's extremely simple (he can only move forward and left), he also doesn't yet implement all the functionality I want for my AI system, but right now the way he works:
1) On the first update, he gives himself a task to complete ("Move Forward", assigning tasks will later be completed by another system).
2) Every task returns a bool on if it's complete or not (for example, Move Forward will only be complete if he's reached the end in this instance), and Task Manager uses the return value to say if we need to re-add the task to the task list so it can be processed again.
3) Every time we do a Move Forward task, a simple raycast is done in front to determine if there's an obstacle. If one is detected, the Move Forward task returns false and instead manually adds the "Clear Obstruction" task to the list.
4) Clear Obstruction performs a move operation to the left and then does three raycasts to determine we're not touching anything. I'm using only three because this example means he's only ever going to be going forward.
5) When Clear Obstruction finally stops repeating, the system will auto-assign Move Forward to the task list, and the cycle continues until it reaches the goal.
This thing is AI because it's dynamic. I can add as many obstacles as I want at any point, and he'll (almost) correctly handle that. There's a LOT of work to go from here, but I'm super happy I got the basic roots of task-based AI down (using delegates, since Unity/C# don't support function pointers).
EDIT: Should be noted; the task-list is a stack. The idea is that higher priority tasks are added at the top and completed before lower-priority tasks. In the end I'll likely change this, but the behaviour is working well for now. I'm also using single-parameter delegates for my tasks, although I will likely change this to be zero-parameter, instead using class variables where possible. I'm still working out the semantics as I go.