Changeset 10045 in orxonox.OLD for branches/ai
- Timestamp:
- Dec 12, 2006, 10:43:36 PM (18 years ago)
- Location:
- branches/ai/src
- Files:
-
- 3 added
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/ai/ai_engine.cc
r10041 r10045 55 55 56 56 57 void AIEngine:: process()57 void AIEngine::tick(float dtS) 58 58 { 59 this->dtS=dtS; 59 60 int teamCount=teams.size(); 60 61 for(int i=0; i < teamCount; i++ ) 61 62 { 62 //std::cout << "Processing Team " << i << "...\n"; 63 //std::cout << "hello"; 64 //std::cout << "DT " << dtS << "...\n"; 63 65 teams.at(i)->process(); 64 66 } -
branches/ai/src/ai/ai_engine.h
r10041 r10045 13 13 static AIEngine* getInstance() { if( singletonRef == NULL) singletonRef = new AIEngine(); return singletonRef; } 14 14 15 void process();15 void tick(float dtS); 16 16 AITeam* getTeam(int); 17 17 int newTeam(); 18 float dtS; 18 19 private: 19 20 AIEngine(); -
branches/ai/src/ai/ai_module.cc
r10029 r10045 12 12 13 13 ### File Specific: 14 main-programmer: Patrick Boenzli14 main-programmer: Thomas Fahrni 15 15 co-programmer: 16 16 */ 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ WORLD_ENTITY17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI 18 18 19 19 #include "ai_module.h" 20 #include "ai_engine.h" 21 #include "debug.h" 20 22 21 23 22 AIModule::AIModule(){23 }24 24 25 AIModule::~AIModule(){ 25 AIModule::AIModule() 26 { 26 27 } 27 28 28 29 29 void AIModule::process() 30 {} 30 AIModule::~AIModule() 31 { 32 } 31 33 32 34 35 36 void AIModule::process() 37 { 38 std::cout << "Processing Module...\n"; 39 } 40 41 42 43 void AIModule::setDifficulty(int newDifficulty) 44 { 45 difficulty=newDifficulty; 46 } 47 48 49 50 void AIModule::setOwner(AITeamMember* newOwner) 51 { 52 owner=newOwner; 53 } 54 -
branches/ai/src/ai/ai_module.h
r10029 r10045 3 3 #define _AI_MODULE_H 4 4 5 class AITeamMember; 5 6 6 7 class AIModule{ … … 9 10 ~AIModule(); 10 11 void process(); 12 void setDifficulty(int newDifficulty); 13 void setOwner(AITeamMember* newOwner); 11 14 private: 12 15 int difficulty; 16 AITeamMember* owner; 13 17 }; 14 18 -
branches/ai/src/ai/ai_team.cc
r10041 r10045 12 12 13 13 ### File Specific: 14 main-programmer: Patrick Boenzli14 main-programmer: Thomas Fahrni 15 15 co-programmer: 16 16 */ -
branches/ai/src/ai/ai_team_member.cc
r10041 r10045 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI 17 17 #include "ai_team_member.h" 18 #include "movement_module.h" 18 19 #include "ai_engine.h" 20 #include "debug.h" 21 19 22 20 23 AITeamMember::AITeamMember() … … 31 34 for(int i=0; i < moduleCount; i++ ) 32 35 { 33 std::cout << "Processing AIModule " << i << "...\n";36 std::cout << "Processing AIModule " << i << " (" << moduleCount << ")\n"; 34 37 modules.at(i)->process(); 35 38 } … … 41 44 void AITeamMember::addToTeam(int aiTeamNumber) 42 45 { 43 // funktionniert nur so pseudomässig...46 //macht nicht so ganz das was es eigntlich machen sollte.. 44 47 AIEngine* aiEngine=AIEngine::getInstance(); 45 48 int teamNumber=aiEngine->newTeam(); 46 49 aiEngine->getTeam(teamNumber)->addMember(this); 50 MovementModule* nMod=new MovementModule; 51 nMod->process(); 52 modules.push_back(nMod); 53 modules.at(0)->process(); 47 54 } 48 55 … … 50 57 51 58 52 void AITeamMember::addModule(AIModule* newModule){ 59 void AITeamMember::addModule(AIModule* newModule) 60 { 61 std::cout << "AIModule added\n"; 53 62 modules.push_back(newModule); 63 newModule->setOwner(this); 54 64 } -
branches/ai/src/ai/ai_team_member.h
r10041 r10045 6 6 #include "ai_module.h" 7 7 8 //class AIModule; 8 9 9 10 class AITeamMember : public WorldEntity{ -
branches/ai/src/ai/movement_module.cc
r10041 r10045 1 2 3 1 /* 4 2 orxonox - the future of 3D-vertical-scrollers … … 12 10 13 11 ### File Specific: 14 main-programmer: Patrick Boenzli12 main-programmer: Thomas Fahrni 15 13 co-programmer: 16 14 */ 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ WORLD_ENTITY15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI 18 16 19 17 #include "movement_module.h" 18 #include "ai_engine.h" 19 #include "state.h" 20 #include "debug.h" 21 22 //class AIEngine; 20 23 21 24 MovementModule::MovementModule(){ 25 //std::cout << "MovementModule created...\n"; 22 26 } 23 27 … … 28 32 void MovementModule::process() 29 33 { 34 //float dt=AIEngine::getInstance()->dtS; 35 std::cout << "///////////////////Processing Movement Module/////////////////////\n"; 30 36 31 37 //How does the Module know the AITeamMember it belongs to?? 32 33 /*Vector absPosition = this->getAbsCoor(); 38 //partialy solved... 39 /* 40 Vector absPosition = owner->getAbsCoor(); 34 41 35 42 PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z); 36 43 37 Player* pl = State::getPlayer();38 Vector playerAbsPos = pl->getPlayable()->getAbsCoor();44 //Player* pl = State::getPlayer(); 45 /*Vector playerAbsPos = pl->getPlayable()->getAbsCoor(); 39 46 40 PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z);47 //PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z); 41 48 42 49 … … 48 55 float speed = 10.0f; 49 56 50 this->shiftCoor( distanceVector * speed * dt);*/57 owner->shiftCoor( distanceVector * speed * dt);*/ 51 58 } 52 59 -
branches/ai/src/ai/movement_module.h
r10029 r10045 11 11 virtual void process(); 12 12 private: 13 //AITeamMember* owner; 13 14 }; 14 15 -
branches/ai/src/ai/shooting_module.cc
r10029 r10045 12 12 13 13 ### File Specific: 14 main-programmer: Patrick Boenzli14 main-programmer: Thomas Fahrni 15 15 co-programmer: 16 16 */ 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI 18 #include "debug.h" 19 #include "shooting_module.h" 18 20 19 #include "shooting_module.h"20 21 21 22 ShootingModule::ShootingModule() … … 28 29 29 30 void ShootingModule::process() 30 {} 31 { 32 //std::cout << "Processing Shooting Module...\n"; 33 return; 34 } 31 35 32 36 -
branches/ai/src/story_entities/game_world.cc
r10040 r10045 505 505 void GameWorld::checkAI() 506 506 { 507 AIEngine::getInstance()->process(); 507 AIEngine::getInstance()->tick(this->dtS); 508 //AIEngine::getInstance()->tick(); 508 509 } 509 510 -
branches/ai/src/world_entities/npcs/npc_test.cc
r10041 r10045 37 37 38 38 39 NPC2::NPC2(const TiXmlElement* root) 40 : NPC(NULL) 39 NPC2::NPC2(const TiXmlElement* root) : NPC(NULL) 41 40 { 42 41 this->registerObject(this, NPC2::_objectList); 43 42 43 if (root != NULL)this->loadParams(root); 44 44 45 if (root != NULL)this->loadParams(root);46 47 45 addToTeam(0); 48 46 } … … 56 54 { 57 55 NPC::loadParams(root); 58 59 56 } 60 61 62 57 63 58 … … 65 60 void NPC2::tick(float dt) 66 61 { 67 68 69 // animating the md2 model (uninteressant) 62 // animating the md2 model 70 63 if( likely(this->getModel(0) != NULL)) 71 64 ((MD2Model*)this->getModel(0))->tick(dt); 72 73 return;74 //this things will now be managed by the AI modules..../////75 76 PRINTF(0)("====================\n");77 PRINTF(0)("NPC2::tick(%f)\n", dt);78 79 // information gathering80 81 Vector absPosition = this->getAbsCoor();82 83 PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z);84 85 Player* pl = State::getPlayer();86 Vector playerAbsPos = pl->getPlayable()->getAbsCoor();87 88 PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z);89 90 91 // intelligent reaction92 93 Vector distanceVector = playerAbsPos - absPosition;94 distanceVector.normalize();95 96 float speed = 10.0f;97 98 this->shiftCoor( distanceVector * speed * dt);99 100 101 102 65 } 103 66 -
branches/ai/src/world_entities/npcs/npc_test.h
r9947 r10045 14 14 NPC2 (const TiXmlElement* root); 15 15 virtual ~NPC2 (); 16 17 16 virtual void loadParams(const TiXmlElement* root); 18 19 20 17 virtual void tick(float dt); 21 18
Note: See TracChangeset
for help on using the changeset viewer.