Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10045 in orxonox.OLD


Ignore:
Timestamp:
Dec 12, 2006, 10:43:36 PM (17 years ago)
Author:
tfahrni
Message:
 
Location:
branches/ai/src
Files:
3 added
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/ai/src/ai/ai_engine.cc

    r10041 r10045  
    5555
    5656
    57 void AIEngine::process()
     57void AIEngine::tick(float dtS)
    5858{
     59        this->dtS=dtS;
    5960        int teamCount=teams.size();
    6061        for(int i=0; i < teamCount; i++ )
    6162        {
    62         //std::cout << "Processing Team " << i <<  "...\n";
     63                //std::cout << "hello";
     64        //std::cout << "DT " << dtS <<  "...\n";
    6365        teams.at(i)->process();
    6466        }
  • branches/ai/src/ai/ai_engine.h

    r10041 r10045  
    1313   static AIEngine* getInstance() { if( singletonRef == NULL) singletonRef = new AIEngine(); return singletonRef; }
    1414
    15    void process();
     15   void tick(float dtS);
    1616   AITeam* getTeam(int);
    1717        int newTeam();
     18        float dtS;
    1819 private:
    1920        AIEngine();
  • branches/ai/src/ai/ai_module.cc

    r10029 r10045  
    1212
    1313   ### File Specific:
    14    main-programmer: Patrick Boenzli
     14   main-programmer: Thomas Fahrni
    1515   co-programmer:
    1616*/
    17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI
    1818
    1919#include "ai_module.h"
     20#include "ai_engine.h"
     21#include "debug.h"
    2022
    2123
    22 AIModule::AIModule(){
    23 }
    2424
    25 AIModule::~AIModule(){
     25AIModule::AIModule()
     26{
    2627}
    2728
    2829
    29 void AIModule::process()
    30 {}
     30AIModule::~AIModule()
     31{
     32}
    3133
    3234
     35
     36void AIModule::process()
     37{
     38std::cout << "Processing Module...\n";
     39}
     40
     41
     42
     43void AIModule::setDifficulty(int newDifficulty)
     44{
     45        difficulty=newDifficulty;
     46}
     47
     48
     49
     50void AIModule::setOwner(AITeamMember* newOwner)
     51{
     52        owner=newOwner;
     53}
     54
  • branches/ai/src/ai/ai_module.h

    r10029 r10045  
    33#define _AI_MODULE_H
    44
     5class AITeamMember;
    56
    67class AIModule{
     
    910   ~AIModule();
    1011   void process();
     12   void setDifficulty(int newDifficulty);
     13   void setOwner(AITeamMember* newOwner);
    1114 private:
    1215   int difficulty;
     16   AITeamMember* owner;
    1317};
    1418
  • branches/ai/src/ai/ai_team.cc

    r10041 r10045  
    1212
    1313   ### File Specific:
    14    main-programmer: Patrick Boenzli
     14   main-programmer: Thomas Fahrni
    1515   co-programmer:
    1616*/
  • branches/ai/src/ai/ai_team_member.cc

    r10041 r10045  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI
    1717#include "ai_team_member.h"
     18#include "movement_module.h"
    1819#include "ai_engine.h"
     20#include "debug.h"
     21
    1922
    2023AITeamMember::AITeamMember()
     
    3134        for(int i=0; i < moduleCount; i++ )
    3235        {
    33         std::cout << "Processing AIModule " << i <<  "...\n";
     36        std::cout << "Processing AIModule " << i << " (" << moduleCount << ")\n";
    3437        modules.at(i)->process();
    3538        }
     
    4144void AITeamMember::addToTeam(int aiTeamNumber)
    4245{
    43         //funktionniert nur so pseudomässig...
     46        //macht nicht so ganz das was es eigntlich machen sollte..
    4447        AIEngine* aiEngine=AIEngine::getInstance();
    4548        int teamNumber=aiEngine->newTeam();
    4649        aiEngine->getTeam(teamNumber)->addMember(this);
     50        MovementModule* nMod=new MovementModule;
     51        nMod->process();
     52        modules.push_back(nMod);
     53        modules.at(0)->process();
    4754}
    4855
     
    5057
    5158
    52 void AITeamMember::addModule(AIModule* newModule){
     59void AITeamMember::addModule(AIModule* newModule)
     60{
     61                std::cout << "AIModule added\n";
    5362                modules.push_back(newModule);
     63                newModule->setOwner(this);
    5464}
  • branches/ai/src/ai/ai_team_member.h

    r10041 r10045  
    66#include "ai_module.h"
    77
     8//class AIModule;
    89
    910class AITeamMember : public WorldEntity{
  • branches/ai/src/ai/movement_module.cc

    r10041 r10045  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1210
    1311   ### File Specific:
    14    main-programmer: Patrick Boenzli
     12   main-programmer: Thomas Fahrni
    1513   co-programmer:
    1614*/
    17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI
    1816
    1917#include "movement_module.h"
     18#include "ai_engine.h"
     19#include "state.h"
     20#include "debug.h"
     21
     22//class AIEngine;
    2023
    2124MovementModule::MovementModule(){
     25        //std::cout << "MovementModule created...\n";
    2226}
    2327
     
    2832void MovementModule::process()
    2933{
     34        //float dt=AIEngine::getInstance()->dtS;
     35        std::cout << "///////////////////Processing Movement Module/////////////////////\n";
    3036
    3137        //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();
    3441
    3542        PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z);
    3643
    37         Player* pl = State::getPlayer();
    38         Vector playerAbsPos = pl->getPlayable()->getAbsCoor();
     44        //Player* pl = State::getPlayer();
     45        /*Vector playerAbsPos = pl->getPlayable()->getAbsCoor();
    3946
    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);
    4148
    4249
     
    4855        float speed = 10.0f;
    4956
    50         this->shiftCoor( distanceVector * speed * dt);*/
     57        owner->shiftCoor( distanceVector * speed * dt);*/
    5158}
    5259
  • branches/ai/src/ai/movement_module.h

    r10029 r10045  
    1111   virtual void process();
    1212 private:
     13        //AITeamMember* owner;
    1314};
    1415
  • branches/ai/src/ai/shooting_module.cc

    r10029 r10045  
    1212
    1313   ### File Specific:
    14    main-programmer: Patrick Boenzli
     14   main-programmer: Thomas Fahrni
    1515   co-programmer:
    1616*/
    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"
    1820
    19 #include "shooting_module.h"
    2021
    2122ShootingModule::ShootingModule()
     
    2829
    2930void ShootingModule::process()
    30 {}
     31{
     32        //std::cout << "Processing Shooting Module...\n";
     33        return;
     34}
    3135
    3236
  • branches/ai/src/story_entities/game_world.cc

    r10040 r10045  
    505505void GameWorld::checkAI()
    506506{
    507   AIEngine::getInstance()->process();
     507  AIEngine::getInstance()->tick(this->dtS);
     508  //AIEngine::getInstance()->tick();
    508509}
    509510
  • branches/ai/src/world_entities/npcs/npc_test.cc

    r10041 r10045  
    3737
    3838
    39 NPC2::NPC2(const TiXmlElement* root)
    40   : NPC(NULL)
     39NPC2::NPC2(const TiXmlElement* root) : NPC(NULL)
    4140{
    4241  this->registerObject(this, NPC2::_objectList);
    4342
     43  if (root != NULL)this->loadParams(root);
    4444
    45   if (root != NULL)this->loadParams(root);
    46  
    4745  addToTeam(0);
    4846}
     
    5654{
    5755  NPC::loadParams(root);
    58 
    5956}
    60 
    61 
    6257
    6358
     
    6560void NPC2::tick(float dt)
    6661{
    67        
    68        
    69   // animating the md2 model (uninteressant)
     62  // animating the md2 model
    7063  if( likely(this->getModel(0) != NULL))
    7164    ((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 gathering
    80 
    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 reaction
    92 
    93   Vector distanceVector = playerAbsPos - absPosition;
    94   distanceVector.normalize();
    95 
    96   float speed = 10.0f;
    97 
    98   this->shiftCoor( distanceVector * speed * dt);
    99 
    100 
    101 
    10265}
    10366
  • branches/ai/src/world_entities/npcs/npc_test.h

    r9947 r10045  
    1414  NPC2 (const TiXmlElement* root);
    1515  virtual ~NPC2 ();
    16 
    1716  virtual void loadParams(const TiXmlElement* root);
    18 
    19 
    2017  virtual void tick(float dt);
    2118
Note: See TracChangeset for help on using the changeset viewer.