Game Development Community

Bots going nowhere (well, "0,0,0")

by Luis Anton · in Torque Game Engine · 01/28/2005 (3:28 am) · 22 replies

Hi,

I'm getting a strange random behaviour from my bots. Sometimes, when I create an AIPlayer, it decides on its own that "0,0,0" is a nice place to go. I mean, I just create it and it acts as if I used a setMoveDestination("0,0,0") command, but there's no setMoveDestination anywhere.

Is someone getting this behaviour too? I'm going to put some code in AIPlayer to check if setMoveDestination if somehow being called, but I wanted to share my problem just in case... :)
Page «Previous 1 2
#1
01/28/2005 (5:39 am)
Happens sometimes. How many bots do you have ? Are you using one AImanager for them all ?
I rather stick the think method to the bot class and having each bot have it's own think thread.
#2
01/31/2005 (1:04 am)
My bots are totally independent. We are creating something like an adventure game. Right now, the main character is in a haunted house, where he finds and talks to different creatures (ghosts, a zombie teacher...) It's an educational game :)

There are no more than 4 bots at the same time on the house. They are created when I need them on certain spot, and sometimes they follow a path to enter in view, but there's no complex AI around. Most bot-code is related to facial and body movements, according to dialogs.

If this goes on, I'll have to force some double-checking in the movement code... why does it happen?
#3
01/31/2005 (12:47 pm)
It's probably just a misset flag or edge case that isn't handled properly. Can you get the behavior to reproduce on stock Torque? If so I can mark it as something to look at.
#4
02/01/2005 (1:05 am)
I' m using Torque 1.3, without modifications, but as I said, it's quite a random error. I could not reproduce it yesterday. I placed an 'ey what's going on' print command in SetMoveDestination, so if it happens again I'll now that that function was called. I'll have a look through aiplayer.cc today, I have had no time to do it properly these days.

If I find something, I'll say it.
#5
02/01/2005 (6:35 am)
If you're doing it in stock Torque, you're probably using the AIManager class I told you that you should avoid.
Just check to which class the THINK method is hooked to. in AIPlayer.cs
#6
02/01/2005 (7:55 am)
No, I'm not using it. I even removed the creation of the object. It was created in game.cs, wasn't it? I'm not using the AIManager class, because I have no need for it. I'm not using any THINK method. My bots do not chase me, and the most complex thing they do is following some paths. I'm using, however, the TaskManager.
#7
02/12/2005 (1:28 pm)
Well, finally it happened again.

I placed a Con::printf command in aiplayer.cc, setMoveDestination, which I can see whenever a bot move somewhere.

This time, however, just after being created, one of them decided to go to '0,0,0', and no message appeared in the console from setMoveDestination. So the problem is elsewhere...

What could it be?
#8
02/12/2005 (5:29 pm)
Just a really strange hint: What .DTS file are you using with the bot ?

I had a strange issue with a .DTS shape of mine that I used the SetTransform and it went to a completely different place. Try using the provided Orc for your bot and see if it still goes to 0,0,0.
#9
02/14/2005 (3:58 am)
We have our own .dts. My problem is not using SetTransform. They appear where I tell them, but then they begin walking to "0,0,0". What was the error in your dts?

We are not using GroundTransform, that could be a possible origin of the problem.
#10
02/14/2005 (6:40 am)
Aparently there was no error in my .DTS, they just appeared elsewhere. So, my hint is just try it with the orc .dts and see if they still go to 0,0,0.
#11
02/15/2005 (12:15 pm)
Well, it's just something that seldom happens, but I can't allow it to happen. I mean, I could put the orc there, see if nothing happens for some time... but I wouldn't be sure wether the error could appear again.

I'll check the AIPlayer code to see when a bot uses its movedestination point, and put something there to control it.
#12
02/21/2005 (3:08 am)
I've news :)

When this thing happens, the aiplayer is, don't know why, in moveState = true. It should be false, because moveState is only set to true when setMoveDestination is called.

So the error seems to be related to moveState being true, without having called setMoveDestination. What else could be changing its value from false to true?

In aiplayer.cc
if (mAimObject || mAimLocationSet || mMoveState == ModeMove) {
      
      // Update the aim position if we're aiming for an object
      if (mAimObject)
         mAimLocation = mAimObject->getPosition();
      else
         if (!mAimLocationSet)
		 {
                         mAimLocation = mMoveDestination;
			Con::printf("Somehow, we are moving. Should we?");
		 }
#13
02/22/2005 (2:28 am)
For someone who bought the engine way back when, has fooled around with it, but mostly got it because it's a great resource as a coder (and it's cool ;)) -- how would you guys reccomend I set up a sandbox for me to play with AI in? What are the basic steps one would take if one was thinking about experimenting with AI in a sort of "from 30k feet" way?

I ask because I'm moderately familiar with engine architecture, but not comfortable enough with it to do much more than get my bearings and modify things cautiously (which is fine, given that I'm not trying to make any games right now). On the other hand, I'm fairly comfortable with paradigms of AI programming (pun intended) and I'd like to doink around in that area from time to time.
#14
04/28/2005 (7:51 pm)
I have the same problem

function CreateBots()
{
       AIPlayer::spawnBot(Beast0,"5 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast1,"10 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast2,"15 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast3,"20 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast4,"25 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast5,"30 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast6,"35 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast7,"40 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast8,"45 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast9,"50 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast10,"55 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast11,"60 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast12,"65 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast13,"70 -225 150 1 0 0 0", PlayerBody);
       AIPlayer::spawnBot(Beast14,"75 -225 150 1 0 0 0", PlayerBody);
}

function AIPlayer::spawnBot(%name, %location, %dataBlock)
{
       %bot = new AIPlayer() {
               dataBlock = %dataBlock;
       };

       MissionCleanup.Add(%bot);
       %spawn = %location;
       %bot.setTransform( %spawn );
       %bot.setShapeName( %name );

       return %bot;
}

i spawn about 15 bots and sometimes one of them starts running.
This is on stock 1.3
This is also useing the default orc dts.
#15
04/28/2005 (8:55 pm)
AIPlayer::AIPlayer()
{
   mMoveDestination.set( 0.0f, 0.0f, 0.0f );
   mMoveSpeed = 1.0f;
   mMoveTolerance = 0.25f;
   mMoveSlowdown = true;

   mAimObject = 0;
   mAimLocationSet = false;
   mTargetInLOS = false;
   mMoveState = ModeStop;
}

I added

mMoveState = ModeStop;

I tested it with that code about 20 times and not once did a aiplayer start running.

It is a bad thing if you do not init your variables as you never know what they may contain.
#16
04/28/2005 (9:00 pm)
Very good point Chris
#17
04/28/2005 (9:10 pm)
:)

One of the members of my team was working with the spawn script and noticed the running player.
I didnt even think anything of it yet, because i was looking through the forums for useful AI info for him, because hes not a SDK owner and the private forums have lots of good AI scripts. Its a shame that all that good scripting cannot even be seen by him.

Well then i came across this thread...... Prob fixed i hope.
#18
04/28/2005 (9:11 pm)
Yeah there is an insane ammount of knowledge hidden away on these forums
#19
04/29/2005 (1:27 am)
I finally fixed this forcing them to stop when I create them, calling %bot.stop:

%player = new AiPlayer() {
       dataBlock = %shape;
       path = "";
       state = "normal"; //normal, sad, angry, happy, scared
       td = false; //thread dir, for blinking
       currentNode = 0;
       followingPath = false;
       wandering = false;
   };
   MissionCleanup.add(%player);
   %player.setTransform(%spawnPoint);
   %player.ciclo = %player.schedule(1000, "controlState");
   %player.stop(); <<<<------------ Do NOT move, yet!

:)
#20
08/25/2005 (2:11 am)
Chris, your fix worked wonders, thanks for tracking this down.

dudes aren't sometimes running off to the holy mountain anymore. :D
Page «Previous 1 2