Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Python AI help  (Read 918 times)

Eagle_eye

  • Bay Watcher
    • View Profile
Python AI help
« on: July 01, 2011, 12:53:24 pm »

so, I've got a very simple AI for a game I'm working on, and it works fine, but I have no clue how to apply it to an indefinite number of followers.  Could someone help me?

Spoiler (click to show/hide)
Logged

thobal

  • Bay Watcher
    • View Profile
Re: Python AI help
« Reply #1 on: July 01, 2011, 01:55:59 pm »

so, I've got a very simple AI for a game I'm working on, and it works fine, but I have no clue how to apply it to an indefinite number of followers.  Could someone help me?

Spoiler (click to show/hide)

Dont know much about the python, but you could store all the friend positions in one big arrrrr.... You said indefinite number, didnt you?

Me, I just make larger numbers of storage than I plan on using, so I never run into that problem. Course, means I'm not properly learning how to use objects(the whole point of c++), but alas, the game comes first in my mind.
This is how I would do it....
Code: [Select]

int friendActive[MAX_FRIENDS];
int friendx[MAX_FRIENDS];
int friendy[MAX_FRIENDS];

for (int i = 0; i < MAX_FRIENDs; i++)
{
   if (friendActive == true)
     {
        if (distanceToPlayer(i) > 10)
          friendFollowPlayer(i);
      }
}

I'm sure you can figure out what I mean with the functions. Also, I'm presuming arrays work the same in python as they do in c++.

Spoiler (click to show/hide)
Logged
Signature goes here.

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: Python AI help
« Reply #2 on: July 01, 2011, 02:02:41 pm »

Just make the nth follower follow the (n-1)th follower.
Logged