SlideShare ist ein Scribd-Unternehmen logo
1 von 38
게임 인공지능
                                                    GameAI




                  Raven : 개관
                  By Changhoon Park
                  http://wawworld.me
                                       Last Update : 2011. 08. 28

11년 10월 10일 월요일
2

                  Raven   게임
                          개관
                          AI


                               By Changhoon Park
                                     http://wawworld.me

11년 10월 10일 월요일
3

                  Raven   게임
                          개관
                          AI


                               By Changhoon Park
                                     http://wawworld.me

11년 10월 10일 월요일
class Raven_Game
          {
          private:
             Raven_Map* m_pMap;
             std::list<Raven_Bot*> m_Bots;

             //the user may select a bot to control manually. This member holds a pointer to that bot
             Raven_Bot* m_pSelectedBot;

             //this list contains any active projectiles (slugs, rockets, shotgun pellets, etc.)
             std::list<Raven_Projectile*> m_Projectiles;

             /* EXTRANEOUS DETAIL OMITTED FOR CLARITY */




             4

                    Raven   게임     Raven_Game
                            개관     맵
                            AI     무기
                                   탄환
                                   트리거
                                                                                                   By Changhoon Park
                                                                                                         http://wawworld.me

11년 10월 10일 월요일
public:
            void Render();
            void Update();

               bool LoadMap(const std::string& FileName);

               bool isPathObstructed(Vector2D A, Vector2D B, double BoundingRadius = 0)const;

               std::vector<Raven_Bot*> GetAllBotsInFOV(const Raven_Bot* pBot)const;

               bool isSecondVisibleToFirst(const Raven_Bot* pFirst,
                                           const Raven_Bot* pSecond)const;

               /* EXTRANEOUS DETAIL OMITTED FOR CLARITY */
          };




               5

                    Raven   게임   Raven_Game
                            개관   맵
                            AI   무기
                                 탄환
                                 트리거
                                                                                      By Changhoon Park
                                                                                            http://wawworld.me

11년 10월 10일 월요일
class Raven_Map
          {
          public:
             typedef NavGraphNode<GraphEdge, Trigger<Raven_Bot>*> GraphNode;
             typedef SparseGraph<GraphNode> NavGraph;
             typedef TriggerSystem<Trigger<Raven_Bot> > Trigger_System;

          private:
             std::vector<Wall2D*> m_Walls;
             Trigger_System m_TriggerSystem;
             std::vector<Vector2D> m_SpawnPoints;
             NavGraph* m_pNavGraph;




             6

                  Raven   게임   Raven_Game   자각
                          개관   맵            목표선택
                          AI   무기           무기 다루기
                               탄환           AI 갱신
                               트리거
                                                                               By Changhoon Park
                                                                                     http://wawworld.me

11년 10월 10일 월요일
public:
            Raven_Map();
            ~Raven_Map();
            void Render();

               bool LoadMap(const std::string& FileName);
               void AddSoundTrigger(Raven_Bot* pSoundSource, double range);
               double CalculateCostToTravelBetweenNodes(unsigned int nd1,
                                                          unsigned int nd2)const;
               void UpdateTriggerSystem(std::list<Raven_Bot*>& bots);

               /* EXTRANEOUS DETAIL OMITTED */
          };




               7


                   그래프 탐색 알고리즘     무정보 그래프 탐색      에지완화
                                   비용 기반 그래프 탐색    Dijkstra 알고리즘
                                                   A*

                                                                                    By Changhoon Park
                                                                                          http://wawworld.me

11년 10월 10일 월요일
8


                  그래프 탐색 알고리즘   무정보 그래프 탐색     에지완화
                                비용 기반 그래프 탐색   Dijkstra 알고리즘
                                               A*

                                                               By Changhoon Park
                                                                     http://wawworld.me

11년 10월 10일 월요일
class Raven_Weapon
          {
          public:
             Raven_Weapon(unsigned int TypeOfGun
                        unsigned int DefaultNumRounds,
                        unsigned int MaxRoundsCarried,
                        double RateOfFire,
                        double IdealRange,
                        double ProjectileSpeed,
                        Raven_Bot* OwnerOfGun);

              virtual ~Raven_Weapon(){}

             bool AimAt(Vector2D target)const;
             virtual void ShootAt(Vector2D target) = 0;




             9


                  그래프 탐색 알고리즘        무정보 그래프 탐색           에지완화
                                     비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                          A*

                                                                          By Changhoon Park
                                                                                http://wawworld.me

11년 10월 10일 월요일
//this method returns a value representing the desirability of using the
               //weapon. This is used by the AI to select the most suitable weapon for
               //a bot's current situation. This value is calculated using fuzzy logic.
               //(Fuzzy logic is covered in Chapter 10)
               virtual double GetDesirability(double DistToTarget)=0;

               //returns the maximum speed of the projectile this weapon fires
               double GetProjectileSpeed()const;

               int NumRoundsRemaining()const;
               void DecrementNumRounds();
               void IncrementRounds(int num);

               //returns an enumerated value representing the gun type
               unsigned int GetTypeOfGun()const;
          };




            10


                    그래프 탐색 알고리즘        무정보 그래프 탐색         에지완화
                                       비용 기반 그래프 탐색       Dijkstra 알고리즘
                                                          A*

                                                                                          By Changhoon Park
                                                                                                http://wawworld.me

11년 10월 10일 월요일
11


                  그래프 탐색 알고리즘   무정보 그래프 탐색     에지완화
                                비용 기반 그래프 탐색   Dijkstra 알고리즘
                                               A*

                                                               By Changhoon Park
                                                                     http://wawworld.me

11년 10월 10일 월요일
12


                  그래프 탐색 알고리즘   무정보 그래프 탐색     에지완화
                                비용 기반 그래프 탐색   Dijkstra 알고리즘
                                               A*

                                                               By Changhoon Park
                                                                     http://wawworld.me

11년 10월 10일 월요일
class TriggerRegion
          {
          public:
             virtual ~TriggerRegion(){}
             virtual bool isTouching(Vector2D EntityPos, double EntityRadius)const = 0;
          };




            13


                  그래프 탐색 알고리즘    무정보 그래프 탐색      에지완화
                                 비용 기반 그래프 탐색    Dijkstra 알고리즘
                                                 A*

                                                                                    By Changhoon Park
                                                                                          http://wawworld.me

11년 10월 10일 월요일
class TriggerRegion_Circle : public TriggerRegion
          {
          private:
             Vector2D m_vPos;       //the center of the region
             double m_dRadius;      //the radius of the region

          public:
             TriggerRegion_Circle(Vector2D pos, double radius)
                                   :m_dRadius(radius), m_vPos(pos){}
             bool isTouching(Vector2D pos, double EntityRadius)const
             {
                  //distances calculated in squared-distance space
                  return Vec2DDistanceSq(m_vPos, pos) <
                          (EntityRadius + m_dRadius)*(EntityRadius + m_dRadius);
             }
          };




            14


                  그래프 탐색 알고리즘      무정보 그래프 탐색         에지완화
                                   비용 기반 그래프 탐색       Dijkstra 알고리즘
                                                      A*

                                                                                   By Changhoon Park
                                                                                         http://wawworld.me

11년 10월 10일 월요일
template <class entity_type>
          class Trigger : public BaseGameEntity
          {
          private:
             //Every trigger owns a trigger region. If an entity comes within this region the trigger is activated
             TriggerRegion* m_pRegionOfInfluence;

             //if this is true the trigger will be removed from the game on the next update
             bool m_bRemoveFromGame;

             bool m_bActive;
             // some types of triggers are twinned with a graph node. This enables the pathfinding component
             // of an AI to search a navgraph for a specific type of trigger.
             int m_iGraphNodeIndex;




            15


                   그래프 탐색 알고리즘          무정보 그래프 탐색             에지완화
                                        비용 기반 그래프 탐색           Dijkstra 알고리즘
                                                               A*

                                                                                                              By Changhoon Park
                                                                                                                     http://wawworld.me

11년 10월 10일 월요일
protected:
             void SetGraphNodeIndex(int idx){m_iGraphNodeIndex = idx;}
             void SetToBeRemovedFromGame(){m_bRemoveFromGame = true;}
             void SetInactive(){m_bActive = false;}
             void SetActive(){m_bActive = true;}

             //returns true if the entity given by a position and bounding radius is
             //overlapping the trigger region
             bool isTouchingTrigger(Vector2D EntityPos, double EntityRadius)const;

             //child classes use one of these methods to add a trigger region
             void AddCircularTriggerRegion(Vector2D center, double radius);
             void AddRectangularTriggerRegion(Vector2D TopLeft, Vector2D BottomRight);




            16


                   그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                       비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                            A*

                                                                                       By Changhoon Park
                                                                                             http://wawworld.me

11년 10월 10일 월요일
public:
            Trigger(unsigned int id);
            virtual ~Trigger();

               // when this is called the trigger determines if the entity is within the trigger's region of influence.
               // If it is then the trigger will be triggered and the appropriate action will be taken.
               virtual void Try(entity_type*) = 0;

               //called each update step of the game. This method updates any internal
                //state the trigger may have
               virtual void Update() = 0;

               int GraphNodeIndex()const{return m_iGraphNodeIndex;}
                bool isToBeRemoved()const{return m_bRemoveFromGame;}
                bool isActive(){return m_bActive;}
          };




               17


                      그래프 탐색 알고리즘          무정보 그래프 탐색            에지완화
                                           비용 기반 그래프 탐색          Dijkstra 알고리즘
                                                                 A*

                                                                                                              By Changhoon Park
                                                                                                                      http://wawworld.me

11년 10월 10일 월요일
template <class entity_type>
          class Trigger_Respawning : public Trigger<entity_type>
          {
          protected:
             // When a bot comes within this trigger's area of influence it is triggered but then
             // becomes inactive for a specified amount of time. These values control
             // the amount of time required to pass before the trigger becomes active once more.
             int m_iNumUpdatesBetweenRespawns;
             int m_iNumUpdatesRemainingUntilRespawn;

             void Deactivate()
             {
                  SetInactive();
                  m_iNumUpdatesRemainingUntilRespawn = m_iNumUpdatesBetweenRespawns;
             }




            18


                   그래프 탐색 알고리즘        무정보 그래프 탐색          에지완화
                                      비용 기반 그래프 탐색        Dijkstra 알고리즘
                                                          A*

                                                                                                    By Changhoon Park
                                                                                                          http://wawworld.me

11년 10월 10일 월요일
public:
            Trigger_Respawning(int id);
            virtual ~Trigger_Respawning();

               virtual void Try(entity_type*) = 0;     //to be implemented by child classes

               virtual void Update()   //this is called each game-tick to update the trigger's internal state
               {
                    if ( (--m_iNumUpdatesRemainingUntilRespawn <= 0) && !isActive())
                    {
                          SetActive();
                    }
               }
               void SetRespawnDelay(unsigned int numTicks);
          };




               19


                    그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                        비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                             A*

                                                                                                        By Changhoon Park
                                                                                                                http://wawworld.me

11년 10월 10일 월요일
class Trigger_WeaponGiver : public Trigger_Respawning<Raven_Bot>
          {
          private:
               /* EXTRANEOUS DETAIL OMITTED */
          public:
               //this type of trigger is created when reading a map file
               Trigger_WeaponGiver(std::ifstream& datafile);

               //if triggered, this trigger will call the PickupWeapon method of the
               //bot. PickupWeapon will instantiate a weapon of the appropriate type.
               void Try(Raven_Bot*);

               //draws a symbol representing the weapon type at the trigger’s location
               void Render();
          };




               20


                     그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                         비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                              A*

                                                                                         By Changhoon Park
                                                                                               http://wawworld.me

11년 10월 10일 월요일
void Trigger_WeaponGiver::Try(Raven_Bot* pBot)
          {
             if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius()))
             {
                    pBot->PickupWeapon( EntityType() );
                    Deactivate();
             }
          }



          void Trigger_HealthGiver::Try(Raven_Bot* pBot)
          {
             if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius()))
             {
                    pBot->IncreaseHealth(m_iHealthGiven);
                    Deactivate();
             }
          }




            21


                   그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                       비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                            A*

                                                                                  By Changhoon Park
                                                                                        http://wawworld.me

11년 10월 10일 월요일
template <class entity_type>
          class Trigger_LimitedLifetime : public Trigger<entity_type>
          {
          protected:
              int m_iLifetime;    //the lifetime of this trigger in update steps

          public:
             Trigger_LimitedLifetime(int lifetime);
             virtual ~Trigger_LimitedLifetime(){}
             //children of this class should always make sure this is called from within their own update method
             virtual void Update()
             {
                    //if the lifetime counter expires set this trigger to be removed from the game
                    if (--m_iLifetime <= 0) {
                           SetToBeRemovedFromGame();
                    }
             }
             virtual void Try(entity_type*) = 0;         //to be implemented by child classes
          };




            22


                    그래프 탐색 알고리즘            무정보 그래프 탐색              에지완화
                                           비용 기반 그래프 탐색            Dijkstra 알고리즘
                                                                   A*

                                                                                                               By Changhoon Park
                                                                                                                     http://wawworld.me

11년 10월 10일 월요일
class Trigger_SoundNotify : public Trigger_LimitedLifetime<Raven_Bot>
          {
          private:
              //a pointer to the bot that has made this sound
              Raven_Bot* m_pSoundSource;

          public:
             Trigger_SoundNotify(Raven_Bot* source, double range);
             void Trigger_SoundNotify::Try(Raven_Bot* pBot)
             {
                   //is this bot within range of this sound
                   if (isTouchingTrigger(pBot->Pos(), pBot->BRadius()))
                   {
                          Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY,
                                                        SENDER_ID_IRRELEVANT, pBot->ID(),
                                                        Msg_GunshotSound,
                                                        m_pSoundSource);
                   }
             }
          };




            23


                    그래프 탐색 알고리즘           무정보 그래프 탐색            에지완화
                                          비용 기반 그래프 탐색          Dijkstra 알고리즘
                                                                A*

                                                                                            By Changhoon Park
                                                                                                  http://wawworld.me

11년 10월 10일 월요일
template <class trigger_type>
          class TriggerSystem
          {
          public:
             typedef std::list<trigger_type*> TriggerList;
          private:
             //a container of all the triggers

             TriggerList m_Triggers;
             //this method iterates through all the triggers present in the system and
             //calls their Update method in order that their internal state can be
             //updated if necessary. It also removes any triggers from the system that
             //have their m_bRemoveFromGame field set to true.




            24


                   그래프 탐색 알고리즘            무정보 그래프 탐색         에지완화
                                          비용 기반 그래프 탐색       Dijkstra 알고리즘
                                                             A*

                                                                                         By Changhoon Park
                                                                                               http://wawworld.me

11년 10월 10일 월요일
void UpdateTriggers()
             {
                   TriggerList::iterator curTrg = m_Triggers.begin();
                   while (curTrg != m_Triggers.end())
                   {
                        //remove trigger if dead
                        if ((*curTrg)->isToBeRemoved())
                        {
                               delete *curTrg;
                               curTrg = m_Triggers.erase(curTrg);
                        }
                        else
                        {
                               //update this trigger
                               (*curTrg)->Update();
                               ++curTrg;
                        }
                   }
             }




            25


                   그래프 탐색 알고리즘           무정보 그래프 탐색              에지완화
                                         비용 기반 그래프 탐색            Dijkstra 알고리즘
                                                                 A*

                                                                                 By Changhoon Park
                                                                                       http://wawworld.me

11년 10월 10일 월요일
//this method iterates through the container of entities passed as a parameter and passes each one to
          // the Try method of each trigger provided the entity is alive and is ready for a trigger update.

          template <class ContainerOfEntities>
          void TryTriggers(ContainerOfEntities& entities)
          {
              ContainerOfEntities::iterator curEnt = entities.begin();      //test each entity against the triggers
              for (curEnt; curEnt != entities.end(); ++curEnt)
              {
                     //an entity must be ready for its next trigger update and it must be
                     //alive before it is tested against each trigger.
                     if ((*curEnt)->isReadyForTriggerUpdate() && (*curEnt)->isAlive())
                     {
                            TriggerList::const_iterator curTrg;
                            for (curTrg = m_Triggers.begin(); curTrg != m_Triggers.end(); ++curTrg) {
                                  (*curTrg)->Try(*curEnt);
                            }
                     }
              }
          }




            26


                     그래프 탐색 알고리즘             무정보 그래프 탐색               에지완화
                                             비용 기반 그래프 탐색             Dijkstra 알고리즘
                                                                      A*

                                                                                                                      By Changhoon Park
                                                                                                                            http://wawworld.me

11년 10월 10일 월요일
public:
             ~TriggerSystem() {
                   Clear();
             }
             void Clear(); //this deletes any current triggers and empties the trigger list

                // This method should be called each update step of the game. It will first update the internal state of t
               // he triggers and then try each entity against each active trigger to test if any should be triggered.
               template <class ContainerOfEntities>
               void Update(ContainerOfEntities& entities) {
                     UpdateTriggers();
                     TryTriggers(entities);
               }
                // this is used to register triggers with the TriggerSystem (the TriggerSystem /will take care of tidying
               // up memory used by a trigger)
               void Register(trigger_type* trigger);
               //some triggers are required to be rendered (like giver-triggers for example)
               void Render();
               const TriggerList& GetTriggers()const{return m_Triggers;}
          };




               27


                       그래프 탐색 알고리즘              무정보 그래프 탐색                  에지완화
                                                비용 기반 그래프 탐색                Dijkstra 알고리즘
                                                                            A*

                                                                                                                             By Changhoon Park
                                                                                                                                   http://wawworld.me

11년 10월 10일 월요일
28


                  그래프 탐색 알고리즘   무정보 그래프 탐색     에지완화
                                비용 기반 그래프 탐색   Dijkstra 알고리즘
                                               A*

                                                               By Changhoon Park
                                                                     http://wawworld.me

11년 10월 10일 월요일
29


                  그래프 탐색 알고리즘   무정보 그래프 탐색     에지완화
                                비용 기반 그래프 탐색   Dijkstra 알고리즘
                                               A*

                                                               By Changhoon Park
                                                                     http://wawworld.me

11년 10월 10일 월요일
struct MemoryRecord
          {
          =
             double dTimeLastSensed;

               double dTimeBecameVisible;

               double dTimeLastVisible;

               Vector2D vLastSensedPosition;

               bool bWithinFOV;

               bool bShootable;
          };




               30


                    그래프 탐색 알고리즘      무정보 그래프 탐색     에지완화
                                     비용 기반 그래프 탐색   Dijkstra 알고리즘
                                                    A*

                                                                    By Changhoon Park
                                                                          http://wawworld.me

11년 10월 10일 월요일
public:
             Raven_SensoryMemory(Raven_Bot* owner, double MemorySpan);

               //this method is used to update the memory map whenever an opponent makes a noise
               void UpdateWithSoundSource(Raven_Bot* pNoiseMaker);

               //this method iterates through all the opponents in the game world and updates the records of those that are in the owner's FOV
               void UpdateVision();
               bool isOpponentShootable(Raven_Bot* pOpponent)const;
               bool isOpponentWithinFOV(Raven_Bot* pOpponent)const;
               Vector2D GetLastRecordedPositionOfOpponent(Raven_Bot* pOpponent)const;
               double GetTimeOpponentHasBeenVisible(Raven_Bot* pOpponent)const;
               double GetTimeSinceLastSensed(Raven_Bot* pOpponent)const;
               double GetTimeOpponentHasBeenOutOfView(Raven_Bot* pOpponent)const;

               //this method returns a list of all the opponents that have had their /records updated within the last m_dMemorySpan seconds.
               std::list<Raven_Bot*> GetListOfRecentlySensedOpponents()const;
          };




               31


                      그래프 탐색 알고리즘               무정보 그래프 탐색                 에지완화
                                                비용 기반 그래프 탐색               Dijkstra 알고리즘
                                                                           A*

                                                                                                                                    By Changhoon Park
                                                                                                                                               http://wawworld.me

11년 10월 10일 월요일
class Raven_TargetingSystem
          {
          private:
             //the owner of this system
             Raven_Bot* m_pOwner;

             //the current target (this will be null if there is no target assigned)
             Raven_Bot* m_pCurrentTarget;

          public:
            Raven_TargetingSystem(Raven_Bot* owner);
            void Update();

             //returns true if there is a currently assigned target
             bool isTargetPresent()const;




            32


                    그래프 탐색 알고리즘           무정보 그래프 탐색             에지완화
                                          비용 기반 그래프 탐색           Dijkstra 알고리즘
                                                                 A*

                                                                                       By Changhoon Park
                                                                                             http://wawworld.me

11년 10월 10일 월요일
bool isTargetWithinFOV()const;

               bool isTargetShootable()const;

               Vector2D GetLastRecordedPosition()const;

               double GetTimeTargetHasBeenVisible()const;

               double GetTimeTargetHasBeenOutOfView()const;

               Raven_Bot* GetTarget()const;

               void ClearTarget();
          };




               33


                    그래프 탐색 알고리즘      무정보 그래프 탐색     에지완화
                                     비용 기반 그래프 탐색   Dijkstra 알고리즘
                                                    A*

                                                                    By Changhoon Park
                                                                          http://wawworld.me

11년 10월 10일 월요일
class Regulator
          {
          private:
             //the time period between updates
             double m_dUpdatePeriod;
             //the next time the regulator allows code flow
             DWORD m_dwNextUpdateTime;
          public:
             Regulator(double NumUpdatesPerSecondRqd);
             //returns true if the current time exceeds m_dwNextUpdateTime
             bool isReady();
          };




            34


                  그래프 탐색 알고리즘   무정보 그래프 탐색      에지완화
                                비용 기반 그래프 탐색    Dijkstra 알고리즘
                                                A*

                                                                             By Changhoon Park
                                                                                   http://wawworld.me

11년 10월 10일 월요일
void Raven_Bot::Update()
          {

             m_pBrain->Process();
             UpdateMovement(); //Calculate the steering force and update the bot's velocity and position
             if (!isPossessed()) //if the bot is under AI control

             {
                  //update the sensory memory with any visual stimulus
                  if (m_pVisionUpdateRegulator->isReady()) {
                       m_pSensoryMem->UpdateVision();
                  }
                  //examine all the opponents in the bot's sensory memory and select one to be the current target
                  if (m_pTargetSelectionRegulator->isReady()) {
                       m_pTargSys->Update();
                  }




            35


                  그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                      비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                           A*

                                                                                                       By Changhoon Park
                                                                                                               http://wawworld.me

11년 10월 10일 월요일
//appraise and arbitrate between all possible high-level goals
                   if (m_pGoalArbitrationRegulator->isReady())
                   {
                        m_pBrain->Arbitrate();
                   }
                   //select the appropriate weapon to use from the weapons currently in the inventory
                   if (m_pWeaponSelectionRegulator->isReady())
                   {
                        m_pWeaponSys->SelectWeapon();
                   }
                   //this method aims the bot's current weapon at the current target
                   //and takes a shot if a shot is possible
                   m_pWeaponSys->TakeAimAndShoot();
              }
          }




              36


                   그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                       비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                            A*

                                                                                                    By Changhoon Park
                                                                                                          http://wawworld.me

11년 10월 10일 월요일
37


                  그래프 탐색 알고리즘   무정보 그래프 탐색     에지완화
                                비용 기반 그래프 탐색   Dijkstra 알고리즘
                                               A*

                                                               By Changhoon Park
                                                                     http://wawworld.me

11년 10월 10일 월요일
void Trigger_WeaponGiver::Try(Raven_Bot* pBot)
          {
             if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius()))
             {
                    pBot->PickupWeapon( EntityType() );
                    Deactivate();
             }
          }



          void Trigger_HealthGiver::Try(Raven_Bot* pBot)
          {
             if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius()))
             {
                    pBot->IncreaseHealth(m_iHealthGiven);
                    Deactivate();
             }
          }




            38


                   그래프 탐색 알고리즘         무정보 그래프 탐색           에지완화
                                       비용 기반 그래프 탐색         Dijkstra 알고리즘
                                                            A*

                                                                                  By Changhoon Park
                                                                                        http://wawworld.me

11년 10월 10일 월요일

Weitere ähnliche Inhalte

Andere mochten auch

06_게임엔진구성
06_게임엔진구성06_게임엔진구성
06_게임엔진구성noerror
 
동국대 앱창작터 2일차:Cocos2d-X 기본기능
동국대 앱창작터 2일차:Cocos2d-X 기본기능동국대 앱창작터 2일차:Cocos2d-X 기본기능
동국대 앱창작터 2일차:Cocos2d-X 기본기능Changhwan Yi
 
만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장
만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장
만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장ukjinkwoun
 
16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM
16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM
16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PMVentureSquare
 
16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장
16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장
16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장VentureSquare
 
아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...
아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...
아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...Amazon Web Services Korea
 
[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈
[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈
[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈Amazon Web Services Korea
 
AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈
AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈
AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈Amazon Web Services Korea
 
[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨
[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨
[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨Amazon Web Services Korea
 
AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015
AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015
AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015Amazon Web Services Korea
 
고대특강 게임 프로그래머의 소양
고대특강   게임 프로그래머의 소양고대특강   게임 프로그래머의 소양
고대특강 게임 프로그래머의 소양Jubok Kim
 
[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례
[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례
[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례Amazon Web Services Korea
 
AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015
AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015
AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015Amazon Web Services Korea
 
AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015
AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015
AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015Amazon Web Services Korea
 
모바일 앱(App) 디자인과 모바일 시장변화의 이해
모바일 앱(App) 디자인과 모바일 시장변화의 이해모바일 앱(App) 디자인과 모바일 시장변화의 이해
모바일 앱(App) 디자인과 모바일 시장변화의 이해SeungBeom Ha
 
iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기iFunFactory Inc.
 
아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)
아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)
아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)Amazon Web Services Korea
 
AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈
AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈
AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈Amazon Web Services Korea
 
클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다
클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다
클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다Dae Kim
 
게임 프로그래밍 기초 공부법
게임 프로그래밍 기초 공부법게임 프로그래밍 기초 공부법
게임 프로그래밍 기초 공부법Chris Ohk
 

Andere mochten auch (20)

06_게임엔진구성
06_게임엔진구성06_게임엔진구성
06_게임엔진구성
 
동국대 앱창작터 2일차:Cocos2d-X 기본기능
동국대 앱창작터 2일차:Cocos2d-X 기본기능동국대 앱창작터 2일차:Cocos2d-X 기본기능
동국대 앱창작터 2일차:Cocos2d-X 기본기능
 
만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장
만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장
만들면서 배우는 Cocos2d x 멀티 플랫폼 게임 프로그래밍 10-11장
 
16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM
16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM
16회 오픈업/Unity3d vs cocos2dx_윤경옥테크PM
 
16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장
16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장
16회 오픈업/우리 게임은 어디에 출시할까?_MS오성미부장
 
아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...
아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...
아마존의 관리형 게임 플랫폼 활용하기: GameLift (Deep Dive) :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS ...
 
[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈
[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈
[Gaming on AWS] AWS와 함께 한 쿠키런 서버 Re-architecting 사례 - 데브시스터즈
 
AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈
AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈
AWS에 대해 가장 궁금했던 열 가지 (정우근) - AWS 웨비나 시리즈
 
[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨
[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨
[Gaming on AWS] AWS에서 실시간 멀티플레이 게임 구현하기 - 넥슨
 
AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015
AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015
AWS로 사용자 천만명 서비스 만들기 - 윤석찬 (AWS 테크에반젤리스트) :: AWS 웨비나 시리즈 2015
 
고대특강 게임 프로그래머의 소양
고대특강   게임 프로그래머의 소양고대특강   게임 프로그래머의 소양
고대특강 게임 프로그래머의 소양
 
[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례
[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례
[Gaming on AWS] 넥슨 - AWS를 활용한 모바일 게임 서버 개발: 퍼즐 주주의 사례
 
AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015
AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015
AWS 비용 최적화 기법 (윤석찬) - AWS 웨비나 시리즈 2015
 
AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015
AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015
AWS 모바일 서비스로 성공하는 모바일 앱 만들기 (윤석찬) - AWS Webiniar 2015
 
모바일 앱(App) 디자인과 모바일 시장변화의 이해
모바일 앱(App) 디자인과 모바일 시장변화의 이해모바일 앱(App) 디자인과 모바일 시장변화의 이해
모바일 앱(App) 디자인과 모바일 시장변화의 이해
 
iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기
 
아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)
아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)
아마존웹서비스와 함께하는 클라우드 비용 최적화 전략 - 윤석찬 (AWS 코리아 테크에반젤리스트)
 
AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈
AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈
AWS 클라우드 이해하기-사례 중심 (정민정) - AWS 웨비나 시리즈
 
클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다
클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다
클라우드 기반 Unity 게임 서버 구축, 60분이면 충분하다
 
게임 프로그래밍 기초 공부법
게임 프로그래밍 기초 공부법게임 프로그래밍 기초 공부법
게임 프로그래밍 기초 공부법
 

Mehr von Hoseo University

Mehr von Hoseo University (13)

Game ai.fsm.02
Game ai.fsm.02Game ai.fsm.02
Game ai.fsm.02
 
Game ai.fsm.01
Game ai.fsm.01Game ai.fsm.01
Game ai.fsm.01
 
Game math.points and lines
Game math.points and linesGame math.points and lines
Game math.points and lines
 
Esl podcast 743 – writing a story
Esl podcast 743 – writing a storyEsl podcast 743 – writing a story
Esl podcast 743 – writing a story
 
Property
PropertyProperty
Property
 
목적이 부여된 에이전트 행동
목적이 부여된 에이전트 행동목적이 부여된 에이전트 행동
목적이 부여된 에이전트 행동
 
실질적인 길 계획하기
실질적인 길 계획하기실질적인 길 계획하기
실질적인 길 계획하기
 
FoundationKit
FoundationKitFoundationKit
FoundationKit
 
프로젝트 구성
프로젝트 구성프로젝트 구성
프로젝트 구성
 
구성(Composition)
구성(Composition)구성(Composition)
구성(Composition)
 
Objective-C에서의 OOP
Objective-C에서의 OOPObjective-C에서의 OOP
Objective-C에서의 OOP
 
Dt2210.01.syllabus
Dt2210.01.syllabusDt2210.01.syllabus
Dt2210.01.syllabus
 
Dt3160.01
Dt3160.01Dt3160.01
Dt3160.01
 

Raven

  • 1. 게임 인공지능 GameAI Raven : 개관 By Changhoon Park http://wawworld.me Last Update : 2011. 08. 28 11년 10월 10일 월요일
  • 2. 2 Raven 게임 개관 AI By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 3. 3 Raven 게임 개관 AI By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 4. class Raven_Game { private: Raven_Map* m_pMap; std::list<Raven_Bot*> m_Bots; //the user may select a bot to control manually. This member holds a pointer to that bot Raven_Bot* m_pSelectedBot; //this list contains any active projectiles (slugs, rockets, shotgun pellets, etc.) std::list<Raven_Projectile*> m_Projectiles; /* EXTRANEOUS DETAIL OMITTED FOR CLARITY */ 4 Raven 게임 Raven_Game 개관 맵 AI 무기 탄환 트리거 By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 5. public: void Render(); void Update(); bool LoadMap(const std::string& FileName); bool isPathObstructed(Vector2D A, Vector2D B, double BoundingRadius = 0)const; std::vector<Raven_Bot*> GetAllBotsInFOV(const Raven_Bot* pBot)const; bool isSecondVisibleToFirst(const Raven_Bot* pFirst, const Raven_Bot* pSecond)const; /* EXTRANEOUS DETAIL OMITTED FOR CLARITY */ }; 5 Raven 게임 Raven_Game 개관 맵 AI 무기 탄환 트리거 By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 6. class Raven_Map { public: typedef NavGraphNode<GraphEdge, Trigger<Raven_Bot>*> GraphNode; typedef SparseGraph<GraphNode> NavGraph; typedef TriggerSystem<Trigger<Raven_Bot> > Trigger_System; private: std::vector<Wall2D*> m_Walls; Trigger_System m_TriggerSystem; std::vector<Vector2D> m_SpawnPoints; NavGraph* m_pNavGraph; 6 Raven 게임 Raven_Game 자각 개관 맵 목표선택 AI 무기 무기 다루기 탄환 AI 갱신 트리거 By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 7. public: Raven_Map(); ~Raven_Map(); void Render(); bool LoadMap(const std::string& FileName); void AddSoundTrigger(Raven_Bot* pSoundSource, double range); double CalculateCostToTravelBetweenNodes(unsigned int nd1, unsigned int nd2)const; void UpdateTriggerSystem(std::list<Raven_Bot*>& bots); /* EXTRANEOUS DETAIL OMITTED */ }; 7 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 8. 8 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 9. class Raven_Weapon { public: Raven_Weapon(unsigned int TypeOfGun unsigned int DefaultNumRounds, unsigned int MaxRoundsCarried, double RateOfFire, double IdealRange, double ProjectileSpeed, Raven_Bot* OwnerOfGun); virtual ~Raven_Weapon(){} bool AimAt(Vector2D target)const; virtual void ShootAt(Vector2D target) = 0; 9 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 10. //this method returns a value representing the desirability of using the //weapon. This is used by the AI to select the most suitable weapon for //a bot's current situation. This value is calculated using fuzzy logic. //(Fuzzy logic is covered in Chapter 10) virtual double GetDesirability(double DistToTarget)=0; //returns the maximum speed of the projectile this weapon fires double GetProjectileSpeed()const; int NumRoundsRemaining()const; void DecrementNumRounds(); void IncrementRounds(int num); //returns an enumerated value representing the gun type unsigned int GetTypeOfGun()const; }; 10 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 11. 11 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 12. 12 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 13. class TriggerRegion { public: virtual ~TriggerRegion(){} virtual bool isTouching(Vector2D EntityPos, double EntityRadius)const = 0; }; 13 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 14. class TriggerRegion_Circle : public TriggerRegion { private: Vector2D m_vPos; //the center of the region double m_dRadius; //the radius of the region public: TriggerRegion_Circle(Vector2D pos, double radius) :m_dRadius(radius), m_vPos(pos){} bool isTouching(Vector2D pos, double EntityRadius)const { //distances calculated in squared-distance space return Vec2DDistanceSq(m_vPos, pos) < (EntityRadius + m_dRadius)*(EntityRadius + m_dRadius); } }; 14 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 15. template <class entity_type> class Trigger : public BaseGameEntity { private: //Every trigger owns a trigger region. If an entity comes within this region the trigger is activated TriggerRegion* m_pRegionOfInfluence; //if this is true the trigger will be removed from the game on the next update bool m_bRemoveFromGame; bool m_bActive; // some types of triggers are twinned with a graph node. This enables the pathfinding component // of an AI to search a navgraph for a specific type of trigger. int m_iGraphNodeIndex; 15 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 16. protected: void SetGraphNodeIndex(int idx){m_iGraphNodeIndex = idx;} void SetToBeRemovedFromGame(){m_bRemoveFromGame = true;} void SetInactive(){m_bActive = false;} void SetActive(){m_bActive = true;} //returns true if the entity given by a position and bounding radius is //overlapping the trigger region bool isTouchingTrigger(Vector2D EntityPos, double EntityRadius)const; //child classes use one of these methods to add a trigger region void AddCircularTriggerRegion(Vector2D center, double radius); void AddRectangularTriggerRegion(Vector2D TopLeft, Vector2D BottomRight); 16 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 17. public: Trigger(unsigned int id); virtual ~Trigger(); // when this is called the trigger determines if the entity is within the trigger's region of influence. // If it is then the trigger will be triggered and the appropriate action will be taken. virtual void Try(entity_type*) = 0; //called each update step of the game. This method updates any internal //state the trigger may have virtual void Update() = 0; int GraphNodeIndex()const{return m_iGraphNodeIndex;} bool isToBeRemoved()const{return m_bRemoveFromGame;} bool isActive(){return m_bActive;} }; 17 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 18. template <class entity_type> class Trigger_Respawning : public Trigger<entity_type> { protected: // When a bot comes within this trigger's area of influence it is triggered but then // becomes inactive for a specified amount of time. These values control // the amount of time required to pass before the trigger becomes active once more. int m_iNumUpdatesBetweenRespawns; int m_iNumUpdatesRemainingUntilRespawn; void Deactivate() { SetInactive(); m_iNumUpdatesRemainingUntilRespawn = m_iNumUpdatesBetweenRespawns; } 18 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 19. public: Trigger_Respawning(int id); virtual ~Trigger_Respawning(); virtual void Try(entity_type*) = 0; //to be implemented by child classes virtual void Update() //this is called each game-tick to update the trigger's internal state { if ( (--m_iNumUpdatesRemainingUntilRespawn <= 0) && !isActive()) { SetActive(); } } void SetRespawnDelay(unsigned int numTicks); }; 19 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 20. class Trigger_WeaponGiver : public Trigger_Respawning<Raven_Bot> { private: /* EXTRANEOUS DETAIL OMITTED */ public: //this type of trigger is created when reading a map file Trigger_WeaponGiver(std::ifstream& datafile); //if triggered, this trigger will call the PickupWeapon method of the //bot. PickupWeapon will instantiate a weapon of the appropriate type. void Try(Raven_Bot*); //draws a symbol representing the weapon type at the trigger’s location void Render(); }; 20 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 21. void Trigger_WeaponGiver::Try(Raven_Bot* pBot) { if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius())) { pBot->PickupWeapon( EntityType() ); Deactivate(); } } void Trigger_HealthGiver::Try(Raven_Bot* pBot) { if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius())) { pBot->IncreaseHealth(m_iHealthGiven); Deactivate(); } } 21 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 22. template <class entity_type> class Trigger_LimitedLifetime : public Trigger<entity_type> { protected: int m_iLifetime; //the lifetime of this trigger in update steps public: Trigger_LimitedLifetime(int lifetime); virtual ~Trigger_LimitedLifetime(){} //children of this class should always make sure this is called from within their own update method virtual void Update() { //if the lifetime counter expires set this trigger to be removed from the game if (--m_iLifetime <= 0) { SetToBeRemovedFromGame(); } } virtual void Try(entity_type*) = 0; //to be implemented by child classes }; 22 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 23. class Trigger_SoundNotify : public Trigger_LimitedLifetime<Raven_Bot> { private: //a pointer to the bot that has made this sound Raven_Bot* m_pSoundSource; public: Trigger_SoundNotify(Raven_Bot* source, double range); void Trigger_SoundNotify::Try(Raven_Bot* pBot) { //is this bot within range of this sound if (isTouchingTrigger(pBot->Pos(), pBot->BRadius())) { Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY, SENDER_ID_IRRELEVANT, pBot->ID(), Msg_GunshotSound, m_pSoundSource); } } }; 23 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 24. template <class trigger_type> class TriggerSystem { public: typedef std::list<trigger_type*> TriggerList; private: //a container of all the triggers TriggerList m_Triggers; //this method iterates through all the triggers present in the system and //calls their Update method in order that their internal state can be //updated if necessary. It also removes any triggers from the system that //have their m_bRemoveFromGame field set to true. 24 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 25. void UpdateTriggers() { TriggerList::iterator curTrg = m_Triggers.begin(); while (curTrg != m_Triggers.end()) { //remove trigger if dead if ((*curTrg)->isToBeRemoved()) { delete *curTrg; curTrg = m_Triggers.erase(curTrg); } else { //update this trigger (*curTrg)->Update(); ++curTrg; } } } 25 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 26. //this method iterates through the container of entities passed as a parameter and passes each one to // the Try method of each trigger provided the entity is alive and is ready for a trigger update. template <class ContainerOfEntities> void TryTriggers(ContainerOfEntities& entities) { ContainerOfEntities::iterator curEnt = entities.begin(); //test each entity against the triggers for (curEnt; curEnt != entities.end(); ++curEnt) { //an entity must be ready for its next trigger update and it must be //alive before it is tested against each trigger. if ((*curEnt)->isReadyForTriggerUpdate() && (*curEnt)->isAlive()) { TriggerList::const_iterator curTrg; for (curTrg = m_Triggers.begin(); curTrg != m_Triggers.end(); ++curTrg) { (*curTrg)->Try(*curEnt); } } } } 26 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 27. public: ~TriggerSystem() { Clear(); } void Clear(); //this deletes any current triggers and empties the trigger list // This method should be called each update step of the game. It will first update the internal state of t // he triggers and then try each entity against each active trigger to test if any should be triggered. template <class ContainerOfEntities> void Update(ContainerOfEntities& entities) { UpdateTriggers(); TryTriggers(entities); } // this is used to register triggers with the TriggerSystem (the TriggerSystem /will take care of tidying // up memory used by a trigger) void Register(trigger_type* trigger); //some triggers are required to be rendered (like giver-triggers for example) void Render(); const TriggerList& GetTriggers()const{return m_Triggers;} }; 27 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 28. 28 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 29. 29 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 30. struct MemoryRecord { = double dTimeLastSensed; double dTimeBecameVisible; double dTimeLastVisible; Vector2D vLastSensedPosition; bool bWithinFOV; bool bShootable; }; 30 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 31. public: Raven_SensoryMemory(Raven_Bot* owner, double MemorySpan); //this method is used to update the memory map whenever an opponent makes a noise void UpdateWithSoundSource(Raven_Bot* pNoiseMaker); //this method iterates through all the opponents in the game world and updates the records of those that are in the owner's FOV void UpdateVision(); bool isOpponentShootable(Raven_Bot* pOpponent)const; bool isOpponentWithinFOV(Raven_Bot* pOpponent)const; Vector2D GetLastRecordedPositionOfOpponent(Raven_Bot* pOpponent)const; double GetTimeOpponentHasBeenVisible(Raven_Bot* pOpponent)const; double GetTimeSinceLastSensed(Raven_Bot* pOpponent)const; double GetTimeOpponentHasBeenOutOfView(Raven_Bot* pOpponent)const; //this method returns a list of all the opponents that have had their /records updated within the last m_dMemorySpan seconds. std::list<Raven_Bot*> GetListOfRecentlySensedOpponents()const; }; 31 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 32. class Raven_TargetingSystem { private: //the owner of this system Raven_Bot* m_pOwner; //the current target (this will be null if there is no target assigned) Raven_Bot* m_pCurrentTarget; public: Raven_TargetingSystem(Raven_Bot* owner); void Update(); //returns true if there is a currently assigned target bool isTargetPresent()const; 32 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 33. bool isTargetWithinFOV()const; bool isTargetShootable()const; Vector2D GetLastRecordedPosition()const; double GetTimeTargetHasBeenVisible()const; double GetTimeTargetHasBeenOutOfView()const; Raven_Bot* GetTarget()const; void ClearTarget(); }; 33 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 34. class Regulator { private: //the time period between updates double m_dUpdatePeriod; //the next time the regulator allows code flow DWORD m_dwNextUpdateTime; public: Regulator(double NumUpdatesPerSecondRqd); //returns true if the current time exceeds m_dwNextUpdateTime bool isReady(); }; 34 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 35. void Raven_Bot::Update() { m_pBrain->Process(); UpdateMovement(); //Calculate the steering force and update the bot's velocity and position if (!isPossessed()) //if the bot is under AI control { //update the sensory memory with any visual stimulus if (m_pVisionUpdateRegulator->isReady()) { m_pSensoryMem->UpdateVision(); } //examine all the opponents in the bot's sensory memory and select one to be the current target if (m_pTargetSelectionRegulator->isReady()) { m_pTargSys->Update(); } 35 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 36. //appraise and arbitrate between all possible high-level goals if (m_pGoalArbitrationRegulator->isReady()) { m_pBrain->Arbitrate(); } //select the appropriate weapon to use from the weapons currently in the inventory if (m_pWeaponSelectionRegulator->isReady()) { m_pWeaponSys->SelectWeapon(); } //this method aims the bot's current weapon at the current target //and takes a shot if a shot is possible m_pWeaponSys->TakeAimAndShoot(); } } 36 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 37. 37 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일
  • 38. void Trigger_WeaponGiver::Try(Raven_Bot* pBot) { if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius())) { pBot->PickupWeapon( EntityType() ); Deactivate(); } } void Trigger_HealthGiver::Try(Raven_Bot* pBot) { if (isActive() && isTouchingTrigger(pBot->Pos(), pBot->BRadius())) { pBot->IncreaseHealth(m_iHealthGiven); Deactivate(); } } 38 그래프 탐색 알고리즘 무정보 그래프 탐색 에지완화 비용 기반 그래프 탐색 Dijkstra 알고리즘 A* By Changhoon Park http://wawworld.me 11년 10월 10일 월요일