I realise there isn't necessarily a ground rule in programming when it comes to what is more efficient, you write your code based on what you're currently trying to do. I've been doing a lot of studying of AI recently and my mind keeps wondering back to examples of AI like the original Halo and Doom games and found they both used finite state machines.

Why is this? What exactly is wrong with using integers and booleans if there is anything wrong with this? Before I moved over to Godot I quite successfully did some pretty solid AI ( At least I thought ) just using a mixture of booleans and integers to dictate the states my AI was in and it seemed to work fine. I just want to know now I'm getting to work with GDScript that I'm not potentially shooting myself in the foot down the line using the method I've picked.

  • A state machine is just a way of tying together a number of changes to the existing structure of your code. It's the equivalent of using objects instead of lots of separate functions and variables. When you change state, you know that x, y, and z will always be appropriate to what's happening now. Using state machines will probably help you as your code becomes more complex, but you might or might not ever need them.

    I like that you can use scenes as state machines in godot. It really doesn't change much, but it seems easier to grasp.

A state machine is just a way of tying together a number of changes to the existing structure of your code. It's the equivalent of using objects instead of lots of separate functions and variables. When you change state, you know that x, y, and z will always be appropriate to what's happening now. Using state machines will probably help you as your code becomes more complex, but you might or might not ever need them.

I like that you can use scenes as state machines in godot. It really doesn't change much, but it seems easier to grasp.

Yes, FSM is just an architecture, like OOP. Using a bunch of booleans only works for very simple games (maybe like space invaders) not full world FPS games with AI characters making complex strategies. There are also more advanced structures, like goal based planning, which was used on F.E.A.R. and probably best best AI for an FPS to date. But that would never work using booleans.