Tuesday, January 31, 2012

The AI Involved In My Game


My game has a huge list of animals, which means that adding a good AI (Artificial Intellingence) system might be a good use of my time. What exactly is AI? AI is a way to make computers "smart". Computers are uniform, and always return the same result if given the same parameters. Animals are not exactly uniform like that squirrel in the photo.



To make the animals "random", but still base their decision on input from a player, you could use input like the system time for the "random" part of the AI, and the player input for the controlled part. For instance, an animal wouldn't just fall into a hole without it being camouflaged, so now there is another addition to my game. You could have blocks that are camouflaged for pitfalls.

Also, in a similar game, the wolves always drown under a block if you aren't careful. There is another reason for AI. If dwarves that mined for you didn't know how to branch mine, they wouldn't be a very good use of your gold when you tamed them with it. And with monkeys, if they didn't know how to farm, it wouldn't be a very good use of your bananas.

With all these reasons, let's start to think about concept. You need to use numbers, numbers, and more numbers to get a smart decision. Computers don't recognize the block id as "solid" or "non-solid". They just see it as "a number". I need to create code that recognizes the id's and determines a path to take. After all, I don't want the pigs in my game to be suicidal by jumping off a cliff!

So how do I tell the animals where to go? You could classify each of the blocks as "dangerous", "neutral", "liquid", etc. Based on these decisions, an animal could go towards the blocks that are attractive to that animal, and away from the ones that are dangerous. But what about carnivores? how does it decide which mob to target on an infinite map? You could separate the mobs into areas, and only inform the carnivore of the mobs in the area.

I hope this gives you an idea of my game's AI!

Doc

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.