Platformer AI

Caleb - I recommend checking out some books. I ported Matt Bruckland’s Raven Example (Quake but viewed overhead) from his C++ examples to Lua/Corona. This showcased a Trigger system that governed Bots searching for Power-Up’s/Health, etc…; a Messaging system so all Game Entities could easily communicate and A* Pathfinding.

The thing about AI is it’s very rarely language specific - as long as you can understand the basics of the source code you should be able to port the concept to any language.

I thoroughly recommend checking out Bruckland’s “Programming Game AI By Example” - got lots of great material in there.

I’ve been rolling my own AI for my games, and Rob is accurate in that it is so specific to individual apps, that no one solution would be best. As SegaBoy references, AI theory can apply across platforms; you’ll be hard pressed to find a Lua-specific solution. 

I’ve been doing a lot of work with Runtime loops and velocity checks to let my enemy objects know when a player is close, or if they have interacted with an obstacle. AI is notorious for breaking and/or not being mature enough for many games, and as a brief Google search will tell you, it has yet to be perfected. 

Here’s a short snippet of one piece of code for one enemy in my game:

   if GameSettings.enem1IsWalking == 1 and GameSettingsEnemies.enem1HitPoints > 0 then

        if (lox > 90 or lox < -90) then

            obj:setSequence(“running”)

            obj:play()

            ffQ = obj.Speed2

        elseif (lox < 90 or lox > -90) then

            obj:setSequence(“walking”)

            obj:play()

            ffQ = obj.Speed1

        end

    end

    if loy <= 3 and loy >= -3 then

        obj:setLinearVelocity(testx1, 0)

    end

    if lox <= 3 and lox >= -3 then

        obj:setLinearVelocity(0, testy1)

    end

This piece is demonstrating how one would set the sprite sequence depending on the distance of the enemy from the player. I’m sure you could adapt it to have it return your enemy to a specific location. Hope that helps!

Ok, thanks for the tips, everyone.

I think I’ll read the book (looks good), look into the Raven samples from the book, see if I can get the remotest hang of some of the “Difficult Language” code :), and, I suppose, just try to rig something up :smiley:

Will let everyone know how it goes.

  • Caleb

There’s many books on AI out there - most of them are naturally geared around C++; however you only need a basic understanding of the syntax to begin understanding the concepts and porting to Lua.

I’d also thoroughly recommend the AI Game Programming Wisdom series - as they tend to split AI concepts into game genres.

Ok… Lucky for me I’ve at least read the “C++ For Dummies” book :wink:

I’ll look into that series also…

  • C