New AI for Mobs
#8
(03-05-2013, 07:43 PM)xoft Wrote: Hmm, maybe even better would be to implement the higher level as separate classes, one for each "state". That way, one wouldn't have to implement the same state multiple times in each monster subclass. Then we can simply create an instance of a behavior class and assign it as the mob's current behavior.

So something like:
Code:
class cBehavior
{
  /// Makes the behavior "happen" for the entity. Called every tick for each pawn that has this behavior selected
  virtual void Apply(cPawn & a_Pawn) = 0;
} ;
class cBehaviorFollowPlayer : public cBehavior ... ;
class cBehaviorRunAwayFrom : public cBehavior ... ;

class cMonster
{
  cBehavior & m_CurrentBehavior;
} ;

That's good idea. I was planning something similar. Having classes for the lower level that represent one single action (with many of them taking multiple ticks to complete), and then organizing them in behaviors (the higher state) to accomplish more complex tasks. For example:


Code:
class cAction
{
  /// Executes a single action for the given pawn
  virtual void DoAction   (cPawn & a_Pawn) = 0;
  virtual void StopAction (cPawn & a_Pawn) = 0;
  virtual void GetType    (cPawn & a_Pawn) = 0;
} ;
class cMoveToCoordinate : public cAction ... ;
class cAttack   : public cAction ... ;
class cExplode  : public cAction ... ;
class cTeleport : public cAction ... ;

class cBehavior
{
    std::deque<cAction &> m_Actionqueue;
    //This function will contain the logic to perform a specific behavior and it will schedule the actions needed
    //in order to accomplish the task
    virtual void PerfromBehavior(cPawn & a_Pawn) = 0;
}
class cBehaviorFollowPlayer : public cBehavior ... ;
class cBehaviorRunAwayFrom : public cBehavior ... ;



(03-05-2013, 07:43 PM)xoft Wrote: One more thing that feels like it should be in, the behaviors may need some form of stacking. For example, if a creeper is following a player and at the same time running away from a cat, it would be wise to implement this as two separate behaviors and apply *both* to the creeper. So instead of having cBehavior & m_CurrentBehavior, let's have std::list<cBehavior &> m_CurrentBehaviors;

What will be the end result? will the creeper follow the player or it will run away from the cat? Or during each tick, the creeper evaluates and decides which behavior needs to do?
Reply
Thanks given by:


Messages In This Thread
New AI for Mobs - by keyboard - 03-04-2013, 03:30 PM
RE: New AI for Mobs - by xoft - 03-04-2013, 10:32 PM
RE: New AI for Mobs - by keyboard - 03-05-2013, 03:18 PM
RE: New AI for Mobs - by xoft - 03-05-2013, 07:43 PM
RE: New AI for Mobs - by NiLSPACE - 03-06-2013, 02:11 AM
RE: New AI for Mobs - by xoft - 03-06-2013, 02:57 AM
RE: New AI for Mobs - by NiLSPACE - 03-06-2013, 05:25 AM
RE: New AI for Mobs - by keyboard - 03-07-2013, 04:35 PM
RE: New AI for Mobs - by xoft - 03-07-2013, 05:22 PM
RE: New AI for Mobs - by keyboard - 03-08-2013, 01:00 AM
RE: New AI for Mobs - by xoft - 03-08-2013, 02:17 AM
RE: New AI for Mobs - by FakeTruth - 03-08-2013, 03:22 AM
RE: New AI for Mobs - by keyboard - 03-08-2013, 12:53 PM
RE: New AI for Mobs - by xoft - 03-09-2013, 04:57 AM
RE: New AI for Mobs - by FakeTruth - 03-09-2013, 05:13 AM
RE: New AI for Mobs - by keyboard - 03-09-2013, 04:41 PM
RE: New AI for Mobs - by xoft - 03-09-2013, 06:04 PM
RE: New AI for Mobs - by keyboard - 03-10-2013, 06:09 AM
RE: New AI for Mobs - by keyboard - 03-25-2013, 01:43 PM
RE: New AI for Mobs - by ravey - 08-13-2013, 01:02 AM
RE: New AI for Mobs - by NiLSPACE - 08-31-2013, 11:20 PM
RE: New AI for Mobs - by xoft - 09-01-2013, 01:04 AM
RE: New AI for Mobs - by SamJBarney - 11-04-2013, 03:38 AM
RE: New AI for Mobs - by xoft - 11-04-2013, 05:23 AM
RE: New AI for Mobs - by SamJBarney - 11-04-2013, 12:05 PM
RE: New AI for Mobs - by xoft - 11-04-2013, 07:44 PM
RE: New AI for Mobs - by SamJBarney - 11-05-2013, 02:47 AM
RE: New AI for Mobs - by SamJBarney - 11-06-2013, 07:35 AM
RE: New AI for Mobs - by xoft - 11-06-2013, 08:02 AM
RE: New AI for Mobs - by SamJBarney - 11-11-2013, 02:39 PM
RE: New AI for Mobs - by xoft - 11-11-2013, 03:53 PM
RE: New AI for Mobs - by SamJBarney - 11-13-2013, 11:23 AM
RE: New AI for Mobs - by tonibm19 - 11-13-2013, 04:09 PM
RE: New AI for Mobs - by NiLSPACE - 11-13-2013, 05:10 PM
RE: New AI for Mobs - by tonibm19 - 11-13-2013, 11:23 PM
RE: New AI for Mobs - by SamJBarney - 11-14-2013, 07:45 AM
RE: New AI for Mobs - by bearbin - 11-14-2013, 05:31 PM
RE: New AI for Mobs - by tonibm19 - 11-15-2013, 01:15 AM
RE: New AI for Mobs - by SamJBarney - 12-03-2013, 12:43 PM
RE: New AI for Mobs - by xoft - 12-03-2013, 04:54 PM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 12:17 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 02:06 AM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 02:11 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 02:48 AM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 03:05 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 04:33 AM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 05:17 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 06:50 AM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 07:04 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 07:25 AM
RE: New AI for Mobs - by xoft - 12-04-2013, 04:31 PM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 07:29 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 08:27 AM
RE: New AI for Mobs - by SamJBarney - 12-04-2013, 06:30 PM
RE: New AI for Mobs - by NiLSPACE - 12-04-2013, 10:07 PM
RE: New AI for Mobs - by SamJBarney - 12-05-2013, 02:42 AM
RE: New AI for Mobs - by SamJBarney - 12-06-2013, 03:06 AM
RE: New AI for Mobs - by NiLSPACE - 12-06-2013, 07:23 AM
RE: New AI for Mobs - by tigerw - 12-06-2013, 10:05 AM
RE: New AI for Mobs - by SamJBarney - 12-06-2013, 03:39 PM
RE: New AI for Mobs - by tonibm19 - 12-06-2013, 07:41 PM
RE: New AI for Mobs - by NiLSPACE - 12-06-2013, 11:41 PM
RE: New AI for Mobs - by SamJBarney - 12-07-2013, 02:46 AM
RE: New AI for Mobs - by tigerw - 12-07-2013, 04:08 AM
RE: New AI for Mobs - by bearbin - 12-07-2013, 04:38 AM
RE: New AI for Mobs - by tigerw - 12-07-2013, 05:05 AM
RE: New AI for Mobs - by SamJBarney - 12-07-2013, 05:42 AM
RE: New AI for Mobs - by xoft - 12-07-2013, 06:18 AM
RE: New AI for Mobs - by SamJBarney - 12-07-2013, 09:04 AM
RE: New AI for Mobs - by SamJBarney - 12-07-2013, 03:09 PM
RE: New AI for Mobs - by SamJBarney - 12-07-2013, 04:23 PM
RE: New AI for Mobs - by xoft - 12-08-2013, 02:11 AM
RE: New AI for Mobs - by SamJBarney - 12-08-2013, 05:14 AM
RE: New AI for Mobs - by xoft - 12-08-2013, 07:41 AM
RE: New AI for Mobs - by SamJBarney - 12-08-2013, 09:04 AM
RE: New AI for Mobs - by tigerw - 12-08-2013, 11:15 PM
RE: New AI for Mobs - by xoft - 12-09-2013, 03:42 AM
RE: New AI for Mobs - by SamJBarney - 12-09-2013, 05:20 AM
RE: New AI for Mobs - by xoft - 12-09-2013, 05:37 AM
RE: New AI for Mobs - by SamJBarney - 12-09-2013, 07:37 AM
RE: New AI for Mobs - by SamJBarney - 12-10-2013, 02:48 AM
RE: New AI for Mobs - by xoft - 12-10-2013, 06:28 AM
RE: New AI for Mobs - by SamJBarney - 12-10-2013, 06:38 AM
RE: New AI for Mobs - by xoft - 12-10-2013, 07:02 AM
RE: New AI for Mobs - by tigerw - 12-10-2013, 07:02 AM
RE: New AI for Mobs - by SamJBarney - 12-10-2013, 07:19 AM
RE: New AI for Mobs - by tigerw - 12-10-2013, 07:39 AM
RE: New AI for Mobs - by SamJBarney - 12-10-2013, 07:42 AM
RE: New AI for Mobs - by tigerw - 12-10-2013, 08:28 AM
RE: New AI for Mobs - by SamJBarney - 12-10-2013, 09:12 AM
RE: New AI for Mobs - by tigerw - 12-17-2013, 03:04 AM
RE: New AI for Mobs - by SamJBarney - 12-17-2013, 04:16 AM
RE: New AI for Mobs - by SamJBarney - 12-18-2013, 07:28 AM
RE: New AI for Mobs - by NiLSPACE - 12-18-2013, 07:33 AM
RE: New AI for Mobs - by SamJBarney - 12-18-2013, 07:42 AM
RE: New AI for Mobs - by xoft - 12-18-2013, 04:48 PM
RE: New AI for Mobs - by SamJBarney - 12-19-2013, 02:38 AM
RE: New AI for Mobs - by xoft - 12-19-2013, 04:37 AM
RE: New AI for Mobs - by SamJBarney - 12-19-2013, 05:45 AM
RE: New AI for Mobs - by xoft - 12-19-2013, 05:59 AM
RE: New AI for Mobs - by tigerw - 12-19-2013, 07:59 AM
RE: New AI for Mobs - by SamJBarney - 12-19-2013, 06:39 AM
RE: New AI for Mobs - by SamJBarney - 12-19-2013, 08:03 AM
RE: New AI for Mobs - by tonibm19 - 12-19-2013, 04:07 PM
RE: New AI for Mobs - by xoft - 12-19-2013, 09:40 PM
RE: New AI for Mobs - by FakeTruth - 12-20-2013, 03:36 AM
RE: New AI for Mobs - by xoft - 12-20-2013, 07:45 AM
RE: New AI for Mobs - by FakeTruth - 12-21-2013, 02:14 AM
RE: New AI for Mobs - by xoft - 12-21-2013, 02:28 AM
RE: New AI for Mobs - by SamJBarney - 12-21-2013, 02:14 PM
RE: New AI for Mobs - by Taugeshtu - 12-22-2013, 11:36 AM
RE: New AI for Mobs - by tonibm19 - 12-22-2013, 06:50 PM
RE: New AI for Mobs - by NiLSPACE - 12-22-2013, 08:36 PM
RE: New AI for Mobs - by xoft - 12-22-2013, 09:03 PM
RE: New AI for Mobs - by SamJBarney - 12-23-2013, 05:23 AM
RE: New AI for Mobs - by xoft - 12-23-2013, 06:07 AM
RE: New AI for Mobs - by SamJBarney - 12-23-2013, 06:07 AM
RE: New AI for Mobs - by xoft - 12-23-2013, 06:21 AM
RE: New AI for Mobs - by SamJBarney - 12-23-2013, 06:23 AM
RE: New AI for Mobs - by xoft - 12-23-2013, 06:45 AM
RE: New AI for Mobs - by SamJBarney - 12-23-2013, 06:48 AM
RE: New AI for Mobs - by xoft - 12-23-2013, 06:52 AM
RE: New AI for Mobs - by FakeTruth - 12-23-2013, 07:27 AM
RE: New AI for Mobs - by SamJBarney - 12-23-2013, 09:01 AM
RE: New AI for Mobs - by tonibm19 - 12-23-2013, 06:05 PM
RE: New AI for Mobs - by Taugeshtu - 12-23-2013, 06:58 PM
RE: New AI for Mobs - by tonibm19 - 12-23-2013, 07:01 PM
RE: New AI for Mobs - by tigerw - 12-23-2013, 10:24 PM
RE: New AI for Mobs - by Taugeshtu - 12-24-2013, 02:44 AM
RE: New AI for Mobs - by SamJBarney - 12-24-2013, 06:07 AM
RE: New AI for Mobs - by xoft - 12-24-2013, 07:18 AM
RE: New AI for Mobs - by SamJBarney - 12-24-2013, 07:36 AM
RE: New AI for Mobs - by xoft - 12-24-2013, 07:41 AM
RE: New AI for Mobs - by SamJBarney - 12-24-2013, 07:43 AM
RE: New AI for Mobs - by xoft - 12-24-2013, 07:54 AM
RE: New AI for Mobs - by SamJBarney - 12-24-2013, 07:58 AM
RE: New AI for Mobs - by xoft - 12-26-2013, 08:47 PM
RE: New AI for Mobs - by bearbin - 12-27-2013, 12:46 AM
RE: New AI for Mobs - by xoft - 12-27-2013, 02:02 AM
RE: New AI for Mobs - by NiLSPACE - 12-27-2013, 02:05 AM
RE: New AI for Mobs - by xoft - 12-27-2013, 02:07 AM
RE: New AI for Mobs - by SamJBarney - 12-27-2013, 03:39 AM
RE: New AI for Mobs - by xoft - 12-27-2013, 03:58 AM
RE: New AI for Mobs - by SamJBarney - 12-27-2013, 04:04 AM
RE: New AI for Mobs - by xoft - 12-27-2013, 07:55 AM
RE: New AI for Mobs - by SamJBarney - 12-27-2013, 08:29 AM
RE: New AI for Mobs - by Taugeshtu - 12-27-2013, 10:14 AM
RE: New AI for Mobs - by SamJBarney - 12-27-2013, 10:21 AM
RE: New AI for Mobs - by Taugeshtu - 12-27-2013, 09:18 PM
RE: New AI for Mobs - by xoft - 12-27-2013, 11:01 PM
RE: New AI for Mobs - by SamJBarney - 12-28-2013, 04:12 AM
RE: New AI for Mobs - by xoft - 12-28-2013, 07:30 PM
RE: New AI for Mobs - by SamJBarney - 12-28-2013, 08:58 PM
RE: New AI for Mobs - by xoft - 12-28-2013, 10:01 PM
RE: New AI for Mobs - by SamJBarney - 12-29-2013, 03:28 AM
RE: New AI for Mobs - by xoft - 12-29-2013, 04:43 AM
RE: New AI for Mobs - by SamJBarney - 12-29-2013, 05:23 AM
RE: New AI for Mobs - by xoft - 12-29-2013, 05:47 AM
RE: New AI for Mobs - by SamJBarney - 12-29-2013, 06:09 AM
RE: New AI for Mobs - by xoft - 12-29-2013, 06:25 AM
RE: New AI for Mobs - by SamJBarney - 12-29-2013, 06:43 AM
RE: New AI for Mobs - by SamJBarney - 12-29-2013, 01:32 PM
RE: New AI for Mobs - by SamJBarney - 01-14-2014, 07:14 AM
RE: New AI for Mobs - by NiLSPACE - 01-26-2014, 08:08 AM
RE: New AI for Mobs - by NiLSPACE - 01-28-2014, 02:13 AM
RE: New AI for Mobs - by tonibm19 - 01-28-2014, 02:26 AM
RE: New AI for Mobs - by NiLSPACE - 01-28-2014, 02:30 AM
RE: New AI for Mobs - by tigerw - 01-28-2014, 04:13 AM
RE: New AI for Mobs - by xoft - 01-28-2014, 06:10 AM
RE: New AI for Mobs - by SamJBarney - 01-29-2014, 02:32 AM
RE: New AI for Mobs - by xoft - 01-29-2014, 02:37 AM
RE: New AI for Mobs - by SamJBarney - 01-29-2014, 08:34 AM
RE: New AI for Mobs - by NiLSPACE - 01-30-2014, 09:44 PM
RE: New AI for Mobs - by tonibm19 - 01-31-2014, 03:17 AM
RE: New AI for Mobs - by NiLSPACE - 01-31-2014, 03:18 AM
RE: New AI for Mobs - by tonibm19 - 01-31-2014, 03:19 AM
RE: New AI for Mobs - by SamJBarney - 01-31-2014, 04:25 AM
RE: New AI for Mobs - by NiLSPACE - 01-31-2014, 04:28 AM
RE: New AI for Mobs - by tigerw - 01-31-2014, 05:09 AM
RE: New AI for Mobs - by xoft - 01-31-2014, 05:55 AM
RE: New AI for Mobs - by tonibm19 - 01-31-2014, 06:35 AM
RE: New AI for Mobs - by Taugeshtu - 01-31-2014, 07:42 AM
RE: New AI for Mobs - by SamJBarney - 01-31-2014, 08:09 AM
RE: New AI for Mobs - by NiLSPACE - 02-01-2014, 07:54 AM
RE: New AI for Mobs - by tonibm19 - 01-31-2014, 04:07 PM
RE: New AI for Mobs - by xoft - 01-31-2014, 05:18 PM
RE: New AI for Mobs - by SamJBarney - 02-01-2014, 01:07 AM
RE: New AI for Mobs - by tonibm19 - 02-01-2014, 02:20 AM
RE: New AI for Mobs - by NiLSPACE - 02-01-2014, 03:25 AM
RE: New AI for Mobs - by xoft - 02-01-2014, 07:52 AM
RE: New AI for Mobs - by SamJBarney - 02-07-2014, 07:04 AM
RE: New AI for Mobs - by xoft - 02-07-2014, 07:22 AM
RE: New AI for Mobs - by SamJBarney - 02-07-2014, 07:38 AM
RE: New AI for Mobs - by xoft - 02-07-2014, 07:55 AM
RE: New AI for Mobs - by SamJBarney - 02-07-2014, 08:34 AM
RE: New AI for Mobs - by SamJBarney - 02-07-2014, 10:01 AM
RE: New AI for Mobs - by SamJBarney - 02-18-2014, 03:01 AM
RE: New AI for Mobs - by tonibm19 - 02-18-2014, 03:37 AM
RE: New AI for Mobs - by NiLSPACE - 02-18-2014, 04:49 AM
RE: New AI for Mobs - by SamJBarney - 02-18-2014, 05:00 AM
RE: New AI for Mobs - by SamJBarney - 08-22-2014, 02:27 AM
RE: New AI for Mobs - by NiLSPACE - 08-22-2014, 02:40 AM
RE: New AI for Mobs - by xoft - 08-22-2014, 03:06 AM
RE: New AI for Mobs - by xoft - 08-22-2014, 03:09 AM
RE: New AI for Mobs - by SamJBarney - 08-22-2014, 03:43 AM
RE: New AI for Mobs - by NiLSPACE - 08-22-2014, 03:55 AM
RE: New AI for Mobs - by xoft - 08-22-2014, 04:03 AM
RE: New AI for Mobs - by SamJBarney - 08-22-2014, 04:37 AM
RE: New AI for Mobs - by xoft - 08-22-2014, 04:51 AM
RE: New AI for Mobs - by SamJBarney - 08-22-2014, 05:04 AM
RE: New AI for Mobs - by xoft - 08-22-2014, 05:17 AM
RE: New AI for Mobs - by tigerw - 08-22-2014, 08:38 AM



Users browsing this thread: 14 Guest(s)