Game Development Community

troubles with the new AIPlayer

by Paul Scott · in Torque Game Engine · 10/09/2002 (4:10 pm) · 33 replies

I'm working with the new AIPlayer, and I've run into a few problems that are slightly over my head at this point.

the new AIPlayer is based off of Player. There is a *large* amount of old code that depends on any ai being a game connection, like the old ai was. What is the general opinion on this? Is it better to redo the architecture of the player move generation, spawning, vehicle mounting etc, or is is better to use the old style ai's, based on GameConnection?

Calculating an ai's move can be rather expensive, and frankly does not need to happen every frame. The function getAIMove() currently generates a Move every update. I tried just returning from getAIMove, the bots did not move at all.
I tried saving the xyz,yaw,pitch,roll values from the previous move. The bots sortof danced as they ran, really bizzare to watch.

There's gotta be a way to keep the old vectors, correctly. Anyone know how?
Page«First 1 2 Next»
#21
11/07/2002 (1:38 pm)
no you cant that is what im saying ..
the setMoveSpeed is minimum one ..
the bot when set to one outruns you.
#22
11/07/2002 (1:41 pm)
I use a value between 0 and 1. It works for me. You can make the bots move super slow.

Here's a section of my AIPlayer.cs file
switch (%randw)
    {
      case 1:
      %obj.setMoveSpeed(0.3);
      AIPlayer::AIchangeammo(%this, %obj);
      case 2:
      %obj.setMoveSpeed(0.5);
      AIPlayer::AIchangeammo(%this, %obj);
      botMoveSurround(%obj);
      case 3:
      %obj.setMoveSpeed(0.7);
      //AIPlayer::AIchangeammo(%this, %obj);
      %obj.setImageTrigger(1,true);
      AIPlayer::botMoveTarget(%obj);
      case 4:
      %obj.setMoveSpeed(0.8);
      //%obj.use("CloakKit");
      botMoveSurround(%obj);
      case 5:
      %obj.setMoveSpeed(0.9);
      %obj.use("CloakKit");
    }
#23
11/07/2002 (1:42 pm)
doh .. I misread that

I misunderstood the AIPlayer::setMoveSpeed for a minute there.
heh Edit:
looked like min 1 but no its Max 1
#24
11/07/2002 (1:45 pm)
I did notice that at speed 1 they seem a little faster then the player tho :) Not sure why that is.
#25
11/07/2002 (1:48 pm)
where did Stefan go?

did you fix that trouble Stefan?
#26
11/07/2002 (2:27 pm)
hehe, no, I didnt solve it... :( I simply didn't have the nerves to stick with this any longer... that's really frustrating if the simplest things won't work...
I'll give it another try with that client-side call now... thx for your help so far, guys!
#27
11/07/2002 (2:45 pm)
nope... nada...
doesnt work with the function in default.bind.cs, either... I've updated to today's HEAD, also... no change... it spawns and sits there doing nothing...
// aiPlayer.cs
function AIPlayer::spawnPlayer(%name)
{
   // An example function which creates a new AIPlayer object
   // using the the example player datablock.
   %player = new AIPlayer() {
      dataBlock = LightMaleHumanArmor;
      aiPlayer = true;
   };
   MissionCleanup.add(%player);

   // Player setup
   %player.setTransform(pickBotSpawnPoint("RedTeamDropPoints"));
   %player.setMoveSpeed(0.6);
   %player.setEnergyLevel(60);
   //%player.setShapeName(%this.name);
   %player.setShapeName(%name);
   %player.setMoveDestination( "-71.1713 98.3312 136.451" );
   error("%player.getMoveDestination():" SPC %player.getMoveDestination());
   
   return %player;
}   

//default.bind.cs
function addBot5(%val) {
   if(%val)
   {
   AIPlayer::spawnPlayer("badass");
   }
}

//server/scripts/game.cs
function pickBotSpawnPoint(%groupName)
{
   %group = nameToID(%groupName);

   if (%group != -1) {
      %count = %group.getCount();
      if (%count != 0) {
         %index = getRandom(%count-1);
         %spawn = %group.getObject(%index);
         return %spawn.getTransform();
      }
      else
         error("No spawn points found in " @ %groupName);
   }
   else
      error("Missing spawn points group " @ %groupName);

   // Could be no spawn points, in which case we'll stick the
   // player at the center of the world.
   return "0 0 300 1 0 0 0";
}
the c++ code is the current HEAD, no changes made...
#28
11/07/2002 (2:57 pm)
Ok ..
ill go grab the head and see if anything is different

Edit:
hmm ..
in New Head all I added was:

%player.setMoveDestination( "-71.1713 98.3312 136.451" );
to this function:
AIPlayer::spawnPlayer()

and typed it into console

AIPlayer::spawnPlayer();
like so and voila off and running.
#29
11/07/2002 (3:13 pm)
thx badguy... leave a message here if you find anything... :D going to bed now....
thanks for your help, guys!
EDIT:
very strange then.... I didnt change any of the AI stuff... and I cant see how anything else in my codebase could have any effect on it...
I'll try the plain HEAD now ... but anyhow, it somehow HAD to work in our own codebase (based on some HEAD after 1.1.2. ...) :-/
#30
11/07/2002 (3:14 pm)
read above. :)
#31
11/07/2002 (11:07 pm)
*slaps himself*
Doh! Another day, another trial...
I really should have looked at my player.cc earlier ...
for some reason, I had an older version of it.... :/
and there was one little change made to support the new AIPlayer class....
Sorry for being stupid, guys... :P
#32
11/08/2002 (4:58 am)
What's the change Stefan? My bots have the exact same problem yours do, and I've tried everything in this thread.
#33
11/08/2002 (5:28 am)
Erik,check if you got the following in player.cc:
void Player::processTick(const Move* move)
{
   PROFILE_START(Player_ProcessTick);
   // If we're not being controlled by a client, let the
   // AI sub-module get a chance at producing a move.
   Move aiMove;
   if (!move && getAIMove(&aiMove))
      move = &aiMove;
   ...
}
and

bool Player::getAIMove(Move* move)
{
   return false;
}   

also, in player.h
   virtual bool    getAIMove(Move*);
that was it for me, after I've included it, my bots were running around like crazy! :D
Page«First 1 2 Next»