CreateGroup function
Moderators: hoijui, Moderators
- tow_dragon
- Posts: 45
- Joined: 05 May 2006, 13:53
CreateGroup function
Does it work? And what should I put as first argument?
- tow_dragon
- Posts: 45
- Joined: 05 May 2006, 13:53
Trust me when I say it involves a lot more time, and then at the end your left with something balancing on a very unstable foundation. It's much faster to use a CGroup class or implement a groupAI's functionality in your own AI
Something I wrote up in a few minutes.. That alone should do what the AI interface does, all it wont do is assign a groupAI and hand over events, but you can derive from that basic class for those things..... And for groupAI's you're better off copy pasting the groupAI's code into your AI.
Code: Select all
class CGroup{
private:
set<int> units;
IAICallback* cb;
public:
CGroup(IAICallback* cb){
this->cb = cb;
}
void IssueCommand(Command* c){
for(set<int>::iterator i = untis.begin(); i != units.end(); ++i){
cb->GiveOrder(c,*i);
}
}
void Add(int unit){
units.insert(unit);
}
void Remove(int unit){
units.erase(unit);
}
bool Empty(){
return units.empty();
}
set<int> GetUnits(){
return units;
}
};
map<int,CGroup> groups;
Something I wrote up in a few minutes.. That alone should do what the AI interface does, all it wont do is assign a groupAI and hand over events, but you can derive from that basic class for those things..... And for groupAI's you're better off copy pasting the groupAI's code into your AI.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
madrat we already have skirmish AI play, and bots that'll run in multiplayer games. Your starting to make me think you've never actually played spring.
Also there are no bandwidth benefits from grouping. Sending a group an order is then translated into an order for each unit, so overall its more cpu intensive than just giving the units their orders straight off. Instead command caching/buffering is a better solution
Also there are no bandwidth benefits from grouping. Sending a group an order is then translated into an order for each unit, so overall its more cpu intensive than just giving the units their orders straight off. Instead command caching/buffering is a better solution