Game Development Community

Immersive AI Engine by Gavin Bunney discussion

by Fyodor -bank- Osokin · in Torque Game Engine · 02/27/2007 (4:46 am) · 191 replies

Let's discuss the iAI engine here, not spamming the .blog is good :)

The first question - is it based on standard AIPlayer.cc from SDK?
May be it's written in documents, but I haven't read all of them yet..
#101
11/23/2007 (4:45 am)
IAIPath is the best attempt to get pathfinding into TGE :)
I've the idea to add a node weight using a grey scale bitmap to set the weight.
Where black is unwalkable and white is best walkable.
What do you think about it ?
#102
11/23/2007 (8:05 am)
Is there a way to implement only the pathfinding? The rest is far too complex for my needs.
#103
11/23/2007 (8:47 am)
Yes you can dan.

Apply the engine changed described above and
add only the path stuff files to your project:

immersiveAI/seek/path/iAIPath.cc / .h
        immersiveAI/seek/path/iAIPathGrid.cc  / .h
        immersiveAI/seek/path/iAIPathNode.cc  / .h
        immersiveAI/seek/path/iAIPathFind.cc  / .h
        immersiveAI/seek/path/iAIPathMap.cc / .h


Try it out in console like this:

Init (can take a while - depends on how big your mission area is):
$iAIPathMap = new iAIPathMap();MissionCleanup.add($iAIPathMap);
            echo ($iAIPathMap.Initialize());
            $iAIPathMap.toggleDisplay();
            $monster=new AIPlayer() {datablock = "MonsterGargoyle"; position="0 0 0";};

Set path:
$path=new iAIPath(){showpath=1;renderSpline=1;};
            $path.createPath($monster.getposition(),"100 100 0");

Walk to each node:
$monster.setMoveDestination($path.nextPosition());


Cleanup path:
$path.delete();


You can also play around with the gridsize setting the parameter $Server::gridSize before you init the nodes.
#104
11/23/2007 (9:54 am)
Good info Thomas, and great idea about the weight bitmap! Please keep us informed if do it...
#105
11/26/2007 (8:25 am)
I implemented the bitmap as nodeweight today. It was easier than i thought :)

I'am using a usual true color png 512x512.
Black = best walkable and white = unwalkable.

Before the Initialize i call a setMapBitMap and load the texture. At createTerrainGrid
i use the nodePos.x/y to read the pixel of the bitmap and build a weight out of (red+green+blue)/3.
If the weight is 255 the node is not connected to any neighbour.

This weight is set as mMoveModifier on the node which i changed from F32 to U8 and set the IAIPATHGLOBAL_MOVE_MODIFIER_UNTRAVERSAL to 255.

It's a little bit tricky to create and paint the weight bitmap but it works very well :)
#106
11/26/2007 (8:03 pm)
Very good dev time indeed Thomas! I saw you invert the walkable/unwalkable colors choice :D

Are you planning on release some code or more explicit how-to? I ask you before do any code writing ;)
#107
11/27/2007 (3:06 pm)
@Novack

I tweaked some things before to get the slope work so it's maybe not clean ;)

But I made a archive with the complete path source:

thunderous.de/torque/path.zip

User: tge
pwd : very!secret1
#108
11/27/2007 (3:11 pm)
Great!! Thank you very much pal!
#109
11/27/2007 (5:26 pm)
Thomas
Quick question:
I'm new to programming AI
Do I put all of the files in the (seek folder)?
Where do I put every thing I'm a little confused.
Do I need to change anything before I compile it?
This code is for TGEA right.

Thank you for you help.
#110
11/27/2007 (6:23 pm)
To adapt this to TGEA there's quite a bit you need to change. The (terribly laggy) opengl draw calls can all be changed to GFX calls pretty easilly, though you'll need to patch together your own method for building the nodes on the atlas terrain if you plan to use it. I'm using a very heavily modified version on legacy terrain in TGEA, so its been done.
#111
11/29/2007 (6:03 am)
@Greg Davis: Are you still working on your port of scripts to C++?

I was attempting to do this long ago with Mark Holocombs work on his ctf demo code, as I noticed a huge cpu load going on when bots would be near each other. I tried a precompiled path tweak and still it would bog down the system in the think script loops. Any real bot ai thinks should be placed in a highly optimized c++ routine. (In the olden days of computers, you would even take it down to machine code or assembly)

I was hoping you would document how you put the above posted code into your project, as I have been following this from the start of this thread and made most of the changes, except yours so far with no problems. This is one of the reasons I havent released my game called Frosty's Revenge, as I wanted to have bots running around the map to fight with with you in a ctf or an Assualt (A Salt), and Defend (Revenge)
matches. Work has slowed this project to a halt unfortunatly. You can see the plan here: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=11469
#112
11/29/2007 (10:00 pm)
@Rick : Yes, I have recently finished my exams, just catching up on some work and then straight back into the c++ upgrade.

I am attempting to do a direct upgrade of the script to c++, that should keeping the implementation documentation down to a minimum. Merely following this thread should do. Ben Sparks has allowed me an upload location where I will upload the code as soon as it is done.

@DALO : Will you be sharing your code for the interior pathing ?
#113
11/30/2007 (6:53 am)
@Greg: sounds great! If and when I get the ctf and assualt portion, I may be able to try and share the code on how to make it happen with immersive ai. Right now I am trying other types of ai to satisfy this need in my game.
#114
11/30/2007 (11:33 pm)
@Greg, yeah I'll share my code, I have a lot of cleaning up to do, and a couple more tests. I'll post it as soon as I can.
#115
12/03/2007 (11:01 am)
@Thomas Huehn: I tried your code and got a clean compile, but I am not certain as to how to get it to work correctly. I was succesful in getting the bitmap I created in the manner you described to load with setMapBitMap right before the call to initialize immersiveai in the startup in game.cs

What else would be needed?

At present ImmersiveAi is just using its stock path build, and not using the bitmap, (Which is set to true color 512X512 using pure white and pure black for paths).
#116
12/08/2007 (9:13 am)
@rick did you enable the toggleDisplay(). You should see the sticks in different grayscales.
#117
12/10/2007 (1:33 pm)
Yes, and it appears not in greyscale but in color. It also appears as if it is using the old method, instead of calling up your new additions. Maybe if you show how you called the new additions in you game cs file, it would help.
#118
12/11/2007 (12:28 pm)
My test init function is:

function CreatePathMap() {
 $iAIPathMap = new iAIPathMap();
 $iAIPathMap.setMapBitMap("game/data/missions/path/pathtest.png");
 echo($iAIPathMap.Initialize());
}

The sticks color should be in show the weight where black is best walkable and white in unwalkable.
#119
12/12/2007 (10:41 am)
Thanks! its working now.

I have tried manually spawing a crature with these posted commands:

$monster=new AIPlayer() {datablock = "MonsterGargoyle"; position="0 0 0";};

            $path=new iAIPath(){showpath=1;renderSpline=1;};
            $path.createPath($monster.getposition(),"100 100 0");

This crashed torque.

Of course I changed my datablock to my named creature and have spawned them using the old
ctf code posted long ago for ctf bots. I can even reactivate my ctf and get them to spawn without
any conflicts to immersive ai before using the new greyscale bitmap code.

Silly me! I just saw that it was spawning the model under the terrain, and it was falling. So
it would crash the engine trying to resolve how to start a path from a falling model.

You first have to figure out where your model resides in world space. You can do this by getting your world editor up and running, and then select your player model, (after walking to the area you wish to spawn, and create a path), then write down the coordinates in the properties tab.

After this, everything worked fine. Thanks again for posting your code Thomas!
#120
12/18/2007 (10:39 am)
I have used Thomas's pathfinding-only version of the source and script code. Seems to work until I run a createPath. I get the following error and my AI player runs to what I believe is the center of the mission area.

Immersive AI :: Seek :: Unable to find a valid path from 188.324005, 124.325996, 237.151001 to 208.319000, 179.054993, 224.957001