Wednesday, September 5, 2007

AI Pathing system

My AI path finding works like this. Bear in mind I read about A* and thought it sounded too complicated when it's all precompiled anyway.

Preparation:
Open editor and click out a bunch of separate paths around buildings - you should try and make as many paths that lead to other location as possible.

Algorithm:
1. When running AI search find closest path to destination.

2. Start COST at 0

3. While traversing nodes on current path, can any nodes on this path see a path to player OR Is node to next path obstructed? (add 1 to COST per node traversed) Store x,y as you go - the idea is to make a path using nodes of existing paths, the paths are just helpers.

4. If failed on either in 3, continue to end of path (summing COST)

5. When at end of current path, look for next path along "rough" vector toward player - tick FAILED counter - pick next path - log JUNCTION(x) ( and COST to here )

6. If FAILED counter < n, pick a new path from destination and goto 3.

7. When FAILED reaches n record COST for *this solution is stored.

8. Next solution, go to JUNCTION(x) until all paths exhausted.

9. Pick lowest cost path.Presumably, when laying the paths down you should have given the algorithm enough chances to get to the player.

So in this pick (black lines are placed by user/programmer) at each junction only nodes "roughly" heading toward the player (even though obstructed) where chosen.

What do you think? Too complex? Not efficient perhaps? Full of errors ?


September - Posts from GG and MyDreamRPG

Here's my latest GG blog which covers everything.

http://www.garagegames.com/blogs/31800/13492

So next is the hard work. AI pathing and behaviour. I was wanting to avoid it, but it has to be done sooner than later. I wrote my own AI pathing for another game, so I might adopt that. It will involve drawing paths in the editor and then the code works out the minimal cost to get somewhere, thereby choosing the best paths.

I've also been thinking about scene handling and I don't really want to hand place every building. I might try an organic, grid aligned algorithm to generate cities and job locations. Will see how this goes.

Post for August - belated

Here's August's activity... mainly blogged on GG and MyDreamRPG...

http://www.garagegames.com/blogs/31800/13335

I've spent most of this month working for 'the man' so development has been slow. I thought I should check in as the month flies on, and blog a little about my progress. It's been mainly research this month.

I've animated the male human using a cartoon-like jutty run cycle. When my pay packet comes in I'm going to invest in an animation book and continue creating unique walk and run cycles for a handful of humans.

I've discovered a free program called Make Human that uses a standard mesh with subtle morphs to create a bazillion different types of humans. So I will use this to create most of the humans and work on skinning to create different looking humans using very few different meshes, about a dozen textures for clothes and unique run cycles.

I've also been implementing the hud and an onscreen debugger, which does something strange every now and then. For some reason writing out play.gui destroys the mouse control and I can't figure out why. It's got something to do with the way the editor writes out the datablocks, but I'm still debugging that to discover the reason.

Next I want to animate the man to work on a machine, and pick something up. I will work more on the Harvester to get it to chase the player a bit better and hopefully in a few weeks have the Harvester eat humans.

Signing off for now. I'll do a bigger update next week.