BWAPI
Skynet/Skynet/UnitGroup.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "Interface.h"
00004 
00005 class RegionClass;
00006 typedef std::tr1::shared_ptr<RegionClass> Region;
00007 
00008 class UnitGroup
00009 {
00010 public:
00011         UnitGroup();
00012 
00013         //Utility functions
00014         int countCompletedBy(int time) const;
00015 
00016         // 0 is equality, less than 0 for lose, greater than 0 for a win
00017         int ratingDifference(const UnitGroup &other) const;
00018         bool isWorthEngaging(const UnitGroup &other) const;
00019 
00020         Position getCenter() const;
00021 
00022         UnitGroup getBestFittingToCircle(int circleSize, int inFramesTime = 0) const;
00023 
00024         Unit getClosestUnit(Unit unit) const;
00025         Unit getClosestUnit(Position position) const;
00026 
00027         bool isAnyInRange(const UnitGroup &otherGroup) const;
00028         int minDistanceBetween(const UnitGroup &otherGroup) const;
00029 
00030         int getBuildScore() const;
00031 
00032         int getAverageTerrainHeight() const;
00033         double getAverageSpeed() const;
00034         Region getMajorityRegion() const;
00035         bool canAttackAir() const;
00036         bool canAttackGround() const;
00037 
00038         bool canMajorityAttack(const UnitGroup &other) const;
00039 
00040         bool hasDetection() const;
00041         std::set<Unit>::size_type getCloakedCount() const;
00042         std::set<Unit>::size_type getFlyingCount() const;
00043 
00044         // Functions to encapsulate the set, not derived as sets destructor is not virtual
00045         typedef std::set<Unit>::iterator iterator;
00046         typedef std::set<Unit>::const_iterator const_iterator;
00047 
00048         iterator begin();
00049         const_iterator begin() const;
00050         iterator end();
00051         const_iterator end() const;
00052 
00053         void clear();
00054         std::set<Unit>::size_type count(Unit const &unit) const;
00055         bool empty() const;
00056 
00057         void erase(iterator position);
00058         std::set<Unit>::size_type erase(Unit const &unit);
00059         void erase(iterator first, iterator last);
00060 
00061         iterator find(Unit const &unit);
00062         std::set<Unit>::const_iterator find(Unit const &unit) const;
00063 
00064         std::pair<iterator, bool> insert(Unit const &unit);
00065         iterator insert(iterator position, Unit const &unit);
00066         void insert(const_iterator first, const_iterator last);
00067 
00068         std::set<Unit>::size_type size() const;
00069 
00070         bool operator==(const UnitGroup &other) const;
00071         bool operator!=(const UnitGroup &other) const;
00072 
00073         operator std::set<Unit>() const;
00074 
00075         UnitGroup &operator+=(const UnitGroup &other);
00076         UnitGroup operator+(const UnitGroup &other) const;
00077         
00078 private:
00079         std::set<Unit> mUnits;
00080 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines