About the state machine.
I’m working my way towards the state machines that should govern the behaviour of the autotanks.
The main problem that I had was that generic tutorials and explanations of state-machines always start from a graph and describe a small number of states with transitions depending on a couple of variables at most.
Not that this is bad in any way, but I would not manage to describe what I need with this kind of constraints.
Well, given the fact that in the end each state will surely be linked to at least one other state and that, provided you don’t mess up something, you will be able to find a path from any one one state to any other, following the liks, you will have the graph as a result. If you try to start with a graph and multiple conditions, it is too easy to end up tangled up.
So… let’s start with all the conditions I want to keep in mind.
The AI tank can see other tanks and the pickups (within its sensor range). It can not assess anything else from an opponent than its size. So the stack size will be passed with the scanned data.
When the AITank (I’ll have to call it ‘autotank’ from now on, cause it’s easier to type)… so when the autotank gets information that there are enemies and, let’s say, a layer in range, it has to decide what to do.
The possible options are, as it can be expected: fight one of the enemies, go for the layer or bugger off.
However, I wanted to have the autotank act differently depending on the number of enemies, for example, or the size of the whole ‘gang’. It’s not that ‘enemy in range = attack’ is a bad pattern, but it’s suitable for large mobs, not individual combatants. Also, I don’t want to have super smart autotanks, but I need then to make sense.
Here’s what I have in my mind at this point…
(to be continued…)