Time Worked: 2.5 hours
Hello there.
I've been stuck for quite a while (probably a week or two) on improving the enemy AI. The problem was definitely that I tried to implement new behavior into the big-ass update loop with a bunch of conditionals. Basically the existing AI was just conditionals in a loop. And it was disgusting. I made a ton of progress implementing a seeking-cover feature, but it just became such a confusing sweaty mess that I realized I needed a better solution.
So I picked up my copy of Game Programming Patterns and read through the State Machine section. I drew a diagram of states that made sense to me (having 2 concurrent machines, one for attacking and one for moving), and then I began implementation. It's kind of hard because I haven't done this before, but it's a really good step in the right direction.
I already knew about state machines etc., and knew that I would need to have a better data structure / system for my AI, I just hadn't done any work on it in a while so didn't think it was time to upgrade it. But, I definitely have come to see that it's probably worth implementing a state machine if you have anything more complex than "Find Player -> Attack Player".
Anyway, this is quite the slog, a ton of code, but it's gonna be really sweet when it's done and I'll get there. I have the endurance. I just have to stick with it until I'm through - then it's time to do some artwork again!
Here's a diagram of the state machines. Just a rough draft here.

No comments:
Post a Comment