Programming Game AI by Example. Ch7. Raven

2,033
-1

Published on

Programming Game AI by Example
Chapter 7: Raven - An Overview

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,033
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Programming Game AI by Example. Ch7. Raven

  1. 1. CH7. Raven : 개관게임인공지능 프로그램하기<br />아꿈사(AnDStudy.com)<br />박일(http://parkpd.egloos.com/)<br />
  2. 2. 개관<br />
  3. 3.
  4. 4.
  5. 5. 탄환 & 공격<br />
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10. TEST_FIXTURE(FixtureBot3, UpdateVision)<br />{<br /> // 등뒤에 있기<br />m_pBot1->SetPos(Vector2D(0, 0));<br /> m_pBot1->RotateFacingTowardPosition(Vector2D(1, 0));<br /> // fov 가 a 도라고 하면 실제로는 -a/2 ~ a/2 사이에 보여야 한다.<br /> m_pBot1->SetFieldOfView(DegsToRads(180.0));<br /> // m_pBot1~m_pBot2, m_pBot1~m_pBot3 중에서 가까운 녀석이 타겟이 된다.<br /> m_pBot3->SetPos(Vector2D(-3, 0));<br /> m_pBot2->SetPos(Vector2D(-1, 0)); // 뒤에서는 안 보이고<br />CHECK(!isSecondInFOVOfFirst(<br /> m_pBot1->Pos(), m_pBot1->Facing(), m_pBot2->Pos(), m_pBot1->FieldOfView()));<br /> m_pBot2->SetPos(Vector2D(2, 0)); // 앞에서는 보인다<br />CHECK(isSecondInFOVOfFirst(<br /> m_pBot1->Pos(), m_pBot1->Facing(), m_pBot2->Pos(), m_pBot1->FieldOfView()));<br /> m_pBot1->m_pSensoryMem->UpdateVision();<br /> // 앞에 있는 bot2 는 보고, bot3 는 못본다. 각도만 신경쓰고, 거리는 신경 안쓴다.<br /> MemoryRecord& info2 = m_pBot1->GetSensoryMem()->m_MemoryMap[m_pBot2];<br /> CHECK(info2.bWithinFOV);<br /> MemoryRecord& info3 = m_pBot1->GetSensoryMem()->m_MemoryMap[m_pBot3];<br /> CHECK(!info3.bWithinFOV);<br /> // 벽에 가려지지만 않으면 모두 sense 를 할 수 있다.<br /> std::list<Raven_Bot*> SensedBots = <br /> m_pBot1->GetSensoryMem()->GetListOfRecentlySensedOpponents();<br /> CHECK_EQUAL(2, SensedBots.size());<br /> // Update -> UpdateMovement 에서 위치 못하도록 못 움직이게 만든다.<br /> m_pBot1->SetMaxSpeed(0.0);<br /> m_pBot1->Update(); // TakeAimAndShoot<br /> Raven_TargetingSystem* pTargetSys1 = m_pBot1->GetTargetSys();<br /> CHECK(0 < pTargetSys1->GetTimeTargetHasBeenVisible());<br /> Raven_Bot* pTarget = m_pBot1->GetTargetBot();<br /> CHECK(pTarget);<br /> CHECK_EQUAL(pTarget->ID(), m_pBot2->ID());<br /> CHECK_EQUAL(1, m_World.GetNumProjectiles()); // 총알 하나 발사<br />}<br />
  11. 11. TEST_FIXTURE(FixtureBot2, Bot1ShootBoltToBot2){ CHECK_EQUAL(100, m_pBot1->Health()); m_pBot1->SetPos(Vector2D(0, 0)); m_pBot2->SetPos(Vector2D(2, 0)); Bolt* pBolt = m_World.AddBolt(m_pBot1, Vector2D(4, 0)); CHECK(IsSimilarVector2D(Vector2D(0, 0), pBolt->Pos(), 0.01)); CHECK(!pBolt->isDead()); m_World.Update(); CHECK(IsSimilarVector2D(Vector2D(5, 0), pBolt->Pos(), 0.01)); // 이동했다. CHECK(pBolt->isDead()); // m_pBot2 에 맞았다. CHECK_EQUAL(99, m_pBot2->Health()); // hp 가 1 줄었다.}<br />
  12. 12. TEST_FIXTURE(FixtureBot3, ShootAt)<br />{<br /> // Bot1 이 Bot2 를 향해 Blaster 발포<br />m_pBot2->SetPos(Vector2D(2, 0));<br /> Raven_WeaponSystem* pWeaponSys1 = m_pBot1->GetWeaponSys();<br /> pWeaponSys1->ShootAt(m_pBot2->Pos());<br /> CHECK_EQUAL(1, m_pMap->m_TriggerSystem.GetTriggerCount());<br /> m_pMap->UpdateTriggerSystem(m_Bots);<br /> std::list<Raven_Bot*> SensedBots = <br /> m_pBot2->GetSensoryMem()->GetListOfRecentlySensedOpponents();<br /> CHECK_EQUAL(1, SensedBots.size());<br /> Raven_TargetingSystem* pTargetSys2 = m_pBot2->GetTargetSys();<br /> pTargetSys2->Update();<br /> Raven_Bot* pTarget = m_pBot2->GetTargetBot();<br /> CHECK(pTarget == m_pBot1);<br />}<br />
  13. 13. 트리거<br />
  14. 14.
  15. 15.
  16. 16. TEST_FIXTURE(FixtureBot1, Trigger_HealthGiver)<br />{<br /> m_pBot1->SetHealth(49);<br /> stringstream input;<br /> input << BaseGameEntity::GetNextValidID();<br /> input << "0.0 0.0 100.0 50 0"; // x y r health nodeIndex<br /> Trigger_HealthGiver* pHealthGiver = <br /> m_pMap->AddHealth_Giver(input);<br /> m_pMap->UpdateTriggerSystem(m_Bots);<br /> CHECK_EQUAL(99, m_pBot1->Health());<br /> CHECK(!pHealthGiver->isActive()); // respawn 될때까지 사라진다.<br />}<br />
  17. 17. 길찾기<br />
  18. 18.
  19. 19.
  20. 20.
  21. 21. 목표 선택<br />
  22. 22.
  23. 23.
  24. 24.
  25. 25. Fuzz<br />

×