[Bastion-cvs] bastion/src/army AIDefender.cpp,1.9,1.10 AIDefender.h,1.6,1.7 ArmyAction.h,1.5,1.6 Sie
Brought to you by:
jacek_kolodziej
|
From: Michał Sła. <sw...@us...> - 2004-07-23 15:58:27
|
Update of /cvsroot/bastion/bastion/src/army In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1594 Modified Files: AIDefender.cpp AIDefender.h ArmyAction.h SiegePoint.cpp SiegePoint.h Log Message: Witam Obszerniejszego maila wysle wam osobno bo Neostrada ciagle mi przerywa ... To wkazdym razie jest AI w takim stanie w jakim jest teraz: - Ludziki wchodza na mury.... - wszystko jest jeszcze niewystarczajaco przetestowane - wszystko wymaga pewnych ustawien (aktualnie oddzialy potrzebuja np. za duzo wojska na murach i efekt tego jest smieszny - oddzialy jeszcze nie wchodza na mur tylko na nim startuja- odwlekalem to bo wiaze sie to z pewna decyzja, ktorej jeszcze nie podjalem (dodanie nowego stanu punktu obronnego). ---------------------------------------------------------------------- Index: ArmyAction.h =================================================================== RCS file: /cvsroot/bastion/bastion/src/army/ArmyAction.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ArmyAction.h 14 Jun 2004 11:02:20 -0000 1.5 --- ArmyAction.h 23 Jul 2004 15:58:16 -0000 1.6 *************** *** 36,39 **** --- 36,40 ---- }; + // Wydawanie rozkazu zadanej dru¿ynie. Dru¿yna mo¿e byæ okre¶lona, b±d¼ podawana za ka¿dym wywo³aniem. class GiveOrderAction : public ArmyAction { protected: *************** *** 44,53 **** orderPack = pack; team = t; }; bool doAction(ArmyBrain* aBrain) { ! ((team->getTeamBrain())->getOrderManager())->mergeWith(orderPack);; ! return true; }; }; class TestAction : public ArmyAction { protected: --- 45,62 ---- orderPack = pack; team = t; }; + GiveOrderAction(order::OrderPack* pack) { + orderPack = pack; team = NULL; + }; + + void getData(void* info) {team = (Team*) info;}; bool doAction(ArmyBrain* aBrain) { ! if (team) { ! ((team->getTeamBrain())->getOrderManager())->mergeWith(orderPack);; ! return true; ! } else {return false;}; }; }; + // Ogólna klasa do akcji warunkowych. Jej podklasy musz± przedefiniowaæ metodê 'test'. class TestAction : public ArmyAction { protected: *************** *** 77,80 **** --- 86,90 ---- }; + // Wczytuje dru¿yne i porównuje czy to zadana - do testowania czy mamy doczynienia z odpowiedni± dru¿yn±. class IsTeamTestAction : public TestAction { protected: *************** *** 110,113 **** --- 120,124 ---- public: SiegePointLookUpAction(AiDefender* _p,DefenderPoint* _d) : player(_p) , point(_d) {}; + void getData(void* _p) {point = (DefenderPoint*) _p;}; bool doAction(ArmyBrain* aBrain); }; Index: AIDefender.cpp =================================================================== RCS file: /cvsroot/bastion/bastion/src/army/AIDefender.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AIDefender.cpp 14 Jun 2004 11:02:20 -0000 1.9 --- AIDefender.cpp 23 Jul 2004 15:58:16 -0000 1.10 *************** *** 146,188 **** SiegePoint* point; switch (category) { ! TEAMS_OTHER: break; ! TEAMS_WALLS: point = new DefenderPoint(team,15,(double) 0.5); inSiege[team] = point; defendPoints[nrDefPoints] = (DefenderPoint*) point; nrDefPoints++; ! addAction(1,new SiegePointLookUpAction(this,(DefenderPoint*) point)); break; ! TEAMS_COURTYARD: point = new ReinforcementPoint(team); inSiege[team] = point; ! supportPoints[nrDefPoints] = (ReinforcementPoint*) point; nrSupPoints++; break; ! TEAMS_RAMPAGE: point = new RampagePoint(team); inSiege[team] = point; ! rampagePoints[nrDefPoints] = (RampagePoint*) point; nrRmpPoints++; break; default: break; }; }; void AiDefender::lookUp() { for (int i = 0;i<nrDefPoints;i++) { ! if (defendPoints[i]->lastLookUp - time > LOOKUP_TIME) { lookUp(defendPoints[i]); defendPoints[i]->lastLookUp = time; ! }; }; }; void AiDefender::lookUp(DefenderPoint* point) { ! if (point->state == SiegePoint::POINT_LOST || point->state == SiegePoint::POINT_UNAVAIABLE) return; int need = point->strenghtNeeded(); if (need>IGNORE_STRENGTH) { support(point,need); --- 146,211 ---- SiegePoint* point; switch (category) { ! case TEAMS_OTHER: break; ! case TEAMS_WALLS: point = new DefenderPoint(team,15,(double) 0.5); inSiege[team] = point; defendPoints[nrDefPoints] = (DefenderPoint*) point; nrDefPoints++; ! addAction(3,new SiegePointLookUpAction(this,(DefenderPoint*) point)); break; ! case TEAMS_COURTYARD: ! team->getPosX(); point = new ReinforcementPoint(team); inSiege[team] = point; ! supportPoints[nrSupPoints] = (ReinforcementPoint*) point; nrSupPoints++; break; ! case TEAMS_RAMPAGE: point = new RampagePoint(team); inSiege[team] = point; ! rampagePoints[nrRmpPoints] = (RampagePoint*) point; nrRmpPoints++; break; default: + std :: cout << "WARRNING! AiDefender::AddTeamInitial - WRONG PARAMETER = "<< category <<"!\n"; break; }; }; + void AiDefender::addPoint(int _x,int _y,int category) { + SiegePoint* point; + if (category == SiegePoint::TYPE_DEF) { + point = new DefenderPoint(_x,_y,15,(double) 0.5); + defendPoints[nrDefPoints] = (DefenderPoint*) point; + nrDefPoints++; + } else if (category == SiegePoint::TYPE_REI) { + point = new ReinforcementPoint(_x,_y); + supportPoints[nrSupPoints] = (ReinforcementPoint*) point; + nrSupPoints++; + } else if (category == SiegePoint::TYPE_RMP) { + point = new RampagePoint(_x,_y); + rampagePoints[nrRmpPoints] = (RampagePoint*) point; + nrRmpPoints++; + } else return; + }; + void AiDefender::lookUp() { + std :: cout << "lookin UP!!!!!!!!!!!\n"; for (int i = 0;i<nrDefPoints;i++) { ! //if (defendPoints[i]->lastLookUp - time > LOOKUP_TIME) { lookUp(defendPoints[i]); defendPoints[i]->lastLookUp = time; ! //}; }; + std :: cout << "~lookin UP!!!!!!!!!!!\n"; }; void AiDefender::lookUp(DefenderPoint* point) { ! point->lastLookUp = time; ! if (/*point->state == SiegePoint::POINT_LOST ||*/ point->state == SiegePoint::POINT_UNAVAIABLE) return; int need = point->strenghtNeeded(); + std :: cout << "lookin UP - need = "<< need <<"\n"; if (need>IGNORE_STRENGTH) { support(point,need); *************** *** 196,199 **** --- 219,223 ---- Team* actT = point->getTeam(); + std :: cout << "support() strenght = "<< strenght <<"\n"; ReinforcementPoint* supportP; Team* supportT; *************** *** 210,217 **** --- 234,243 ---- }; while (doWyslania>0) { + std :: cout << "support() wysylamy !"<< doWyslania <<"\n"; supportP = getClosestReinforcements(point); if (!supportP) return; supportT = supportP->getTeam(); int supportStrenght = supportT->getCount(); + std :: cout << "support() wysylamy !"<< supportStrenght <<"\n"; supportT->transferTo(&doWyslania,actT,-1); }; *************** *** 278,281 **** --- 304,308 ---- // Pierwszy znaleziony bestDist = to->distanceTo(supportPoints[i]); + best = supportPoints[i]; }; }; Index: AIDefender.h =================================================================== RCS file: /cvsroot/bastion/bastion/src/army/AIDefender.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AIDefender.h 1 Jun 2004 09:56:20 -0000 1.6 --- AIDefender.h 23 Jul 2004 15:58:16 -0000 1.7 *************** *** 43,47 **** // Statystyki //int rainforcementCounter; ! static const int IGNORE_STRENGTH=3; public: static const int TEAMS_OTHER = 0; --- 43,47 ---- // Statystyki //int rainforcementCounter; ! static const int IGNORE_STRENGTH=5; public: static const int TEAMS_OTHER = 0; *************** *** 73,76 **** --- 73,79 ---- void addTeam(Team* team); void addTeamInitial(Team* team,const int category = TEAMS_OTHER); + + void addPoint(int _x,int _y,int category = SiegePoint::TYPE_DEF); + void enemySpotted(Team* actTeam); void underAttack(Team* team); Index: SiegePoint.cpp =================================================================== RCS file: /cvsroot/bastion/bastion/src/army/SiegePoint.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SiegePoint.cpp 1 Jun 2004 09:56:20 -0000 1.4 --- SiegePoint.cpp 23 Jul 2004 15:58:16 -0000 1.5 *************** *** 1,7 **** --- 1,9 ---- #include "SiegePoint.h" + #include "../map/SeenSet.h" #include "../unit/Unit.h" + order::OrderPack SiegePoint::ordersToSend; *************** *** 15,20 **** SiegePoint::SiegePoint(Team* _team) { ! x = (int) team->getPosX(); ! y = (int) team->getPosY(); team = _team; state = POINT_GUARDED; --- 17,22 ---- SiegePoint::SiegePoint(Team* _team) { ! x = (int) _team->getPosX(); ! y = (int) _team->getPosY(); team = _team; state = POINT_GUARDED; *************** *** 38,44 **** int count;Team* dest; switch (point->getState()) { ! POINT_GUARDED: ! POINT_UNDERATTACK: ! POINT_UNAVAIABLE: dest = point->getTeam(); count = team->getCount(); --- 40,46 ---- int count;Team* dest; switch (point->getState()) { ! case POINT_GUARDED: ! case POINT_UNDERATTACK: ! case POINT_UNAVAIABLE: dest = point->getTeam(); count = team->getCount(); *************** *** 56,60 **** }; break; ! POINT_LOST: count = team->getCount(); if (ile>=count) { --- 58,62 ---- }; break; ! case POINT_LOST: count = team->getCount(); if (ile>=count) { *************** *** 110,119 **** // Wylicza danger i uruchamia int DefenderPoint::strenghtNeeded() { - SeenSet* seen = team->getSeenSet(); - danger = seen->getSeenEnemyCounter(); if (team) { return (priority+((int)(danger*protection)) - team->getCount()); } else { ! return (priority+((int) (danger*protection))); }; }; --- 112,121 ---- // Wylicza danger i uruchamia int DefenderPoint::strenghtNeeded() { if (team) { + SeenSet* seen = team->getSeenSet(); + danger = seen->getSeenEnemyCounter(); return (priority+((int)(danger*protection)) - team->getCount()); } else { ! return (priority); }; }; *************** *** 128,129 **** --- 130,140 ---- return DefenderPoint::strenghtNeeded(); }; + + RampagePoint::RampagePoint(int posX,int posY) : SiegePoint(posX,posY) {}; + RampagePoint::RampagePoint(Team* team) : SiegePoint(team) {}; + + ReinforcementPoint::ReinforcementPoint(int posX,int posY) : SiegePoint(posX,posY) {}; + ReinforcementPoint::ReinforcementPoint(Team* team) : SiegePoint(team) {}; + + + Index: SiegePoint.h =================================================================== RCS file: /cvsroot/bastion/bastion/src/army/SiegePoint.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SiegePoint.h 14 Jun 2004 11:02:20 -0000 1.5 --- SiegePoint.h 23 Jul 2004 15:58:16 -0000 1.6 *************** *** 94,98 **** public: int pointType() {return TYPE_REI;}; ! ReinforcementPoint(double posX,double posY); ReinforcementPoint(Team* team); }; --- 94,98 ---- public: int pointType() {return TYPE_REI;}; ! ReinforcementPoint(int posX,int posY); ReinforcementPoint(Team* team); }; *************** *** 102,106 **** public: int pointType() {return TYPE_RMP;}; ! RampagePoint(double posX,double posY); RampagePoint(Team* team); }; --- 102,106 ---- public: int pointType() {return TYPE_RMP;}; ! RampagePoint(int posX,int posY); RampagePoint(Team* team); }; |