Make character walks by themselfs, AI

9dc050376a89ce1c18d68b9afac10205
0
Facadas 101 Feb 08, 2008 at 15:46

Hello everyone. Need some help with one thing. I have a character that i control, and i’ve created a grid where i mark the places where the character wont pass.
Now comes the part where i hope u can help me, i want to put the character walking by himself, so he walks only by the non marked parts of the grid, like as if he had some sort of artificial inteligence.

Hope someone can help me.

Tks a lot

PS: If i’m posting in the right topic, tell me in which to do

9 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Feb 08, 2008 at 16:51

There are lots of algorithms for moving around in a world with obstacles. Google for ‘path finding’ and you should find a lot of good stuff.

25173620a178828c4af639e495d588be
0
onyxthedog 101 Feb 08, 2008 at 16:59

There are a couple approaches you could take, one would be path finding algorithms. With a path finding algorithm you usually have to specify where you want them to go.

Another is a genetic algorithm which is based on darwinism. Basically it decides which random solution is most fit and the more fit it is the more chance it has of being chosen to “mate” with another.

A very common one would be neural networks which is a representation of a brain basically.

One less complicated approach would be to get it to walk around randomly in the grid but to avoid the unapproachable squares.

Here is a combination of them that I think might work better. It picks a random square that is accessible and uses a path finding algorithm to find the best route to the square.

9dc050376a89ce1c18d68b9afac10205
0
Facadas 101 Feb 08, 2008 at 18:03

u both talk about algorithm. I can use that in virtools??

Tks for the replies..

25173620a178828c4af639e495d588be
0
onyxthedog 101 Feb 08, 2008 at 21:40

I personally am not familiar with Virtools, but if it has a scripting language with basic structures( e.g. Arrays is the main thing that you need along with either a class or struct) then you should be able to use the algorithms but I will go read some on Virtools to see what it is exactly.

9dc050376a89ce1c18d68b9afac10205
0
Facadas 101 Feb 08, 2008 at 22:34

tks for the help, when u have more info…
By the way, which program do u use to animate the character? that with the algorithms

Once again, tank you..

25173620a178828c4af639e495d588be
0
onyxthedog 101 Feb 09, 2008 at 02:01

From what I have found out it is very much like Macromedia Flash. If I am not mistaken then it probably has something similiar to Action Script, which there are games made with all the time using a variation of the different algorithms. But be fore warned AI is not something that you just decide to do at any given moment, it takes a lot of reasearch!

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Feb 09, 2008 at 02:55

By the way, which program do u use to animate the character? that with the algorithms

An algorithm is just some code that does something. You might do something like:

state = going_south
going_south
{
if (next south grid is not blocked) keep going south
else
{choose random direction
state = direction (chosen by random)
}
}

That’s just pseudo code, but you get the idea. The simplest way to do that is to have a little grid map and have the character keep track of where he is on the grid so you can check the next position. To get a little fancier, you check an area block with the character in the center for enemies and have him turn toward the nearest enemy.

9dc050376a89ce1c18d68b9afac10205
0
Facadas 101 Feb 12, 2008 at 12:01

My problem is that virtools works with building block (BBs), not with algorithms (as far as i know).
I already created a grid map and checked diferent areas blocks, now i just have to put the caracter walking by himself in the non checked areas. I’ve read that i have to use the Virtools AI Pack, the problem now is that i cant find the Pack in my Pc, and i dont know if it cames along with virtools 4.0 or if i have to download it for somewhere…

tks to everyone

25173620a178828c4af639e495d588be
0
onyxthedog 101 Feb 13, 2008 at 03:59

@Facadas

My problem is that virtools works with building block (BBs), not with algorithms (as far as i know).
I already created a grid map and checked diferent areas blocks, now i just have to put the caracter walking by himself in the non checked areas. I’ve read that i have to use the Virtools AI Pack, the problem now is that i cant find the Pack in my Pc, and i dont know if it cames along with virtools 4.0 or if i have to download it for somewhere… tks to everyone

First things first, does it have a scripting language or the ability to integrate a language? If so that is all you need.

Here is some sample C++ that is kind of pseudo but kind of more realistic at the same time.

//Half Pseudo thingy
#include <iostream>
#include <stdlib>
#include <ctime>
using namespace std;

int main ()
{
      enum Direction {SOUTH, WEST, NORTH, EAST};
      int grid [10, 10], x = 0, y = 0, way;
      Direction direction;  //bad practice but you get the point
      
      srand (time(NULL));

     do {
      
        way = rand () % 4 + 1; //ensures I only get 1 through 4
     
       switch (way)
      {
           case 1:
            direction = SOUTH;
            if ( y - 1 != block)
               y -= 1;
            break;

          case 2:
           direction = WEST;
           if ( x - 1 != block)
              x -= 1;
           break;
 
         case 3:
           direction = NORTH;
           if (y + 1 != block)
              y += 1;
           break;

       case 4:
         direction = EAST;
         if (x + 1 != block)
            x += 1;
         break; 
     }


  while (state != pause || state != stop)

Like I said it is semi-pseudo but is also mainly real, but should be considered an excerpt because I didn’t declare a few variables. But I didn’t want to write an entire program.