This recent days there have been no post since our main writer (Miguel) was on vacations, but now we are back and stronger than ever!! and even more so since there is so little time to finish this TFM and also present the project to the Playstation Awards!!
Today we are gonna tell you a little about Artificial Intelligence (AI). Since this game is a turn based tactic game, the AI is one off the most important parts even more for you will almost always be playing against machines (we aren’t going to rule out the possibility off you playing against another person in local or through the Internet) and if the AI is not “Smart” enough there will be no challenge making the game boring and repetitive, making the game to easy.
A complex AI takes quite a lot of developing hours, and it can make the machine fail at any time, but luckily, there are a lot of ways to create complex and complete behaviors without the need to complicate the code to much by making a “State Machine”.
A “State Machine” is a set of “instructions” or “paths” with which we can guide the AI, with transitions into other states so the AI can know what to do in certain cases and what to do in other time, for an simple example we here have a small diagram that shows the beginning of the guards “State Machine” AI:
Has you can see we have 5 states: Guarding, Attacking, Healing, Hunting and Hiding. In each of this states the AI will make decisions based on the logic that we code in it.
Each of the arrows between the states represent the “Triggers” or conditions that have to be met so the AI (The Guard) can go into that state, except for the Initial or starting state arrow which is represented by a simple arrow that goes into the “Guarding” bubble, indicating this is the starting behavior for the AI, so if the Guard is in the State “Guarding” the Trigger “See an Enemy” and the enemy is within certain reach, this will make him switch into the State “Attack”.
But all of this can become quite more complex if in every one of this states we add another “State Machine” to tell the NPC what to do when he is in that specific state, like say the AI is in the “Attack” state, the AI can choose what to do depending on the internal State Machine of the “Attack” state, making the NPC take cover, use a skill or simply get close to the enemy and deal one last punishing blow before dying, meaning that if we are not careful enough when making this type of “State Machines”, the AI can get so complex that no one would be able to understand how it works.
So has you can see the “State Machine” initial design should be made simple and should not be coded, just make a simple sketch in a book or in PC (Xmind is a good tool for PC), just make sure not to make a super large “State Machine”, try not to make it larger than 5 options, and try to keep the “Triggers” simple, even more since at the time wen you start coding it, it will become quite complex even though at the time of sketching it looks simple, just remember in programming a good motto is “Divide and Conquer”.
And thats all for today, we hope that you liked the post and we hope to make a incredible AI so you can have a lot of fun with our game. And has you know by now you can always leave a comment or get in touch with us by Twitter @ProjectDinamita, Facebook a Dynamite Project or through here 🙂