Potential Fields

I am going to write about potential fields for AI in game programming to give everyone an understanding of it. Basically, you have a starting point (The place your AI Agent is at), and a goal, say, the location of the player. You start by creating a 2D array split into tiles. Then, you assign the location of the goal as 0. You then loop through the other locations, and make the value of them equal to the distance from the goal. Then, you loop through, and if a tile has an object on it, such as a wall, you make that tile have a value that is very high, higher than any other values in the array.

Now, each frame, you have your agent evaluate all its bordering tiles, and move to the one with the lowest value.

Wow, it’s that easy!

Note: To anyone who may have done this before, if I misunderstood or explained it wrong, leave me a comment or email me at brandonmanrulesATgmail.com. I didn’t put it in the email format just in case of spammers. replace AT with @.

Also, if anyone would want to do a link exchange for sites or blogs, that’d be great. I could make a post with your blog/site and you could make a post with mine.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: