Monday, October 29, 2012

How to Make a Basic AI - Seek & Wander


If anyone remembers in Super Mario 64, the goombas were different then their 2D counter parts. Instead of simply walking in a straight line, they actually did some somewhat more dynamic AI. They walked around and when you got close, they suddenly turned toward you and ran at you. This is a very basic AI that can work in a 3D game and today I'd like to show how it can be done.

First off let's break down what kind of behaviours the goomba is using. It uses two simple AI behaviours...

  • Seek
  • Wander
The seek behaviour means to head towards a designated target, simple enough. The behaviour is a little more complicated but it eventually involves the same thing. It seeks towards a target, but what it does is calculate a new target in front of itself whenever it's called to make it appear like its just walking around aimlessly.

Physics System


So we know what these behaviours are and they sound pretty simple. Before you just go ahead and make them we need to make sure we have a physics system of some sort. So let's say we have our "Goomba object", well if we want to accurately calculate forces for our AI, we need to make sure he adheres to some form of physics.  This physics system is not too complicated, in fact all it needs to consist of for us at this point is the following...

  • Force
  • Mass
  • Acceleration
  • Velocity (Speed)
  • Position
You would give your goomba this physics system and give it an update function that applies these forces every frame. With the proper system, simply applying some force, will automatically do all the calculations to make the goomba move. So Force = Mass*acceleration, velocity += acceleration, position += velocity or something of the sort. So this means in our AI behaviours we would be calculating the forced required to go to our target.

Basic AI Systems - Pattern and Dynamic AI

A major factor in how believable the game world is, comes from the AI system. When you think about it, almost every game has AI in one form or another. Even a simple game such as Super Mario Bros. has AI,  very basic AI that follows the same pattern. Nowaways we have highly advanced AI, like the ones demonstrated in the Halo series, renowned for their AI. There are varying types of AI, they can be set patterns or they can be dynamic and changing based on the state of the game. The type of AI used is dependent on the type of game being made.

For my post about making a Basic AI Behaviour, click here

Pattern AI


At it's core, a patterned AI doesn't care about what the player is doing, it's not going to react specifically to you if you happen to be jumping, attacking, or dodging. The most they might react is if you happen to be near, it will activate their AI. This is the kind of AI that was featured a lot in games in the 90s and earlier.

The most basic versions of these come in the form of goombas in Super Mario Bros. Their AI pattern is to just walk ahead and if they run into an obstacle turn around. These enemies in particular don't care at all where you are.
Super Mario Bros - World 1-1 ~ The Goomba AI literally just walks forward

Another rather basic AI is the AI in turn based RPGs, notably Pokemon (the old games). They pretty much have no AI. Where pokemon will have a list of four moves, in most battles though they will simply use them at random, with no thought to strategy. Later games started to implement actual patterns in battles to make some good strategies but they were still mostly patterned.

Pokemon Red - The AI used to just randomly use whatever attacks where in their movelist

Saturday, October 27, 2012

Dialogue in Games

How does dialogue enhance the experience of a game for us? What are it's advantages and it's disadvantages? What are the different ways we can go about bringing dialogue to life and bringing story to the players? As a follow up to my previous blog I want to talk about the difference between dialogue with audio, dialogue without and even games that feature no dialogue at all to convey the story.

Story has always been an important part in some games. A lot of games still have story of some sort even if they have no cutscenes or dialogue. Some games simply feature a "story" button featured in the main menu or something of the sort (though that's usually for flash games or lower budget quick games). For titles with larger budgets they usually have either cutscenes with dialogue & voice acting, cutscenes with only text dialogue, or the rare no dialogue and no text ones.


Action Only


These aren't too common and it's very important for these kinds of cutscenes to convey all the emotion and the messages they need with only character motions. It becomes very hard to pull this off for certain kinds of games, such as RPGs which usually have the largest of backstories. However there have been some very notable successes that have proven that you don't always need talking and text to convey what's going on in a scene.

The best example I have experienced of this is the Lego series games, such as Lego Star Wars, Lego Batman, Lego Indiana Jones, etc. In these games, the Lego characters do not talk at all but they have to re-enact scenes from the movies or settings they are in as though they were mimes. They are able to provide and make the emotions obviously in certain scenes such as worry, happiness, laughter, while still trying to stick to the character they are playing. They also have to use a lot of exaggerated gestures to convey more emotion as well.

Tuesday, October 23, 2012

Fragmentation - My memory has got some holes!

When I am talking about memory I do not mean the memory of our conscious self.  I instead mean memory that our computer uses. Our computer contains different kinds of memory, some of them faster to use and some of them slower. Fragmentation is like the title says, making our memory have holes in them. I will explain the whole process of fragmentation and how it does this but before we do that let's talk a bit about what kind of memory our computer has at it's disposal.

Memory


Our memory is responsible for allowing our computer to do all sorts of complex calculations at rates faster than a human possibly could. The more memory we have, the more things we can do at once and the faster we can do it. This applies for all of the programs that our computer has to use when it's being run, from a calculator, to a game. 

We generally have two types of memory, cache memory and RAM (Random Access Memory).



Cache Memory is the faster of the two and is located closest to the CPU in our computer. The CPU is what is doing our calculations, therefore the closer we are to the CPU, the faster our calculations. The problem with cache memory is that we have a lot less of it then we do of RAM. This means we want to perform as much calculation in cache memory as we can before resorting to RAM in order to be as fast and efficient as possible. We also have several layers of cache memory, the closest one labelled "L1" while the others being L2, L3, etc. L1 is the fastest layer while the others get progressively slower.


Random Access Memory is the slower of the two and located farther away from the CPU. However you can have much more of this kind of memory, and can frequently be seen in large 1-8 Gigabyte sticks now, with multiple of them on one computer.


Thursday, October 18, 2012

Sound is important! ~ Audio in Games

We often take for granted the sound we hear in games. As our professor Bill Kaprolos taught us, sound is often a neglected part in games. Not just by designers at times but also by players as well. How often is it that people will play a game without the sound or replace the game's music with their own. Designers adding in sound in the last few months and thinking of it as an after thought. Not everyone does these but it's not uncommon for it to happen. For this post I'm going to take a look into how sound, from music, to dialogue, to sound effects and ambiance affect the game. I believe that a truly great game will have great sound to make it a truly complete experience.

Sound Effects


These are the bread and butter of pretty much every game now. These define the sounds your enemies and players will make in the world, the environmental reactions to your actions. This ranges from things such as character footsteps, sword slashes, gunshots, explosions and anything that is resulted from an action or visual change in the environment. It can be a scripted sequence like a bomb going off and setting off that explosion, or your character holding a gun and you, the player making the gun shoot by pressing the trigger.

The reason these are so important is because they are something you will hear a lot during your game, pretty much all the time. It means that they cannot be annoying, tedious or repetitive. They need to be designed in such a way that they make the experience for the player even better. They need to be satisfying and make sense with what's happening on screen.


Monday, October 15, 2012

Humans Opponents vs AI Opponents

Human opponents and AI opponents, there has always been a debate between which provides a better experience for players. Many stronger players have agreed that humans are much better and that there is no question about it, while others have tried to argue that AI opponents can be compable. All of this is usually a comparison in multiplayer games where the option to play with bots or human opponents is provided. In this blog post I look to compare the advantages and disadvantages of both in a multiplayer environment as well as take a look at how they provide a different experience for singleplayer versus multiplayer in a variety of different genres.

Human Opponents

Skill Levels

Your entire play experience changes depending on the skill of your opponents. Since there are so many players with different skill levels and different strategies it means that your experience can change with every match you play. This is the most important factor in having human opponents versus AI opponents because it means humans can provide you some uniquely different experiences that you could never get from AI.

Soul Calibur V - My Online Matches against human opponents, much more dynamic and interesting than AI.


Saturday, October 13, 2012

Repositories - Back up ALL the files!

Repository? What is that and why is this related to game engines? Well it's useful for game engines, more specifically programming in general and has a variety of other uses too. A repository is sort of like a back up system for your code (or other files). If you have a repository for your code and you make a really terrible mistake later on, you have the ability to revert to an older version and restore code! It has a lot of other things too but let's seperate this blog post neatly into some sections first.


Backing Up


Repositories have the ability to back up your files and revert to older versions. You would set up a folder of your choice as a repository and from there the program will let you do a variety of things (program of your choice, I use mercurial and tortoise HG, but more on that later). Essentially I can choose which files I would like to include to back up, so even if there are a ton of files in the folder I chose, I can select each one that I want and exclude the ones I don't want. There is even a file called .hgignore that allows you to ignore certain types of files so that they will never appear when choosing to select what to back up.

From there (for mercurial) all you have to do is add a comment that says something about what you're doing so, something like "Just created this program that adds numbers" or "[ADD] Added the ability to multiply to program". And then you just click commit. This will add a new "revision" which can be reverted back to in the future. You can add new revisions whenever you want to add a new file or change a file.

It's also possible to branch off as well, which means you're making another version that might be significantly different. From there you can multiple branches, each changing different things and even merge them later. So you could edit one file A, and one file B in a different revision. And later on do a merge that allows you to have both the changes. There can be conflicts though so you will have to use some provided tools to resolve those.