MCPcopy Create free account
hub / github.com/bwapi/bwapi / setNeighbors

Method setNeighbors

bwapi/BWAPIClient/Source/RegionImpl.cpp:9–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7 : self ( &BWAPI::BWAPIClient.data->regions[index] )
8 { }
9 void RegionImpl::setNeighbors()
10 {
11 int accessibleBestDist = 99999;
12 int inaccessibleBestDist = 99999;
13 for ( int i = 0; i < self->neighborCount; ++i )
14 {
15 BWAPI::Region neighbor = Broodwar->getRegion(self->neighbors[i]);
16 this->neighbors.insert(neighbor);
17
18 // Obtain the closest accessible and inaccessible Regions from their Region center
19 int dst = this->getCenter().getApproxDistance(neighbor->getCenter());
20 if ( this->getRegionGroupID() == neighbor->getRegionGroupID() )
21 {
22 if ( dst < accessibleBestDist )
23 {
24 accessibleBestDist = dst;
25 this->closestAccessibleRgn = neighbor;
26 }
27 }
28 else if ( dst < inaccessibleBestDist )
29 {
30 inaccessibleBestDist = dst;
31 this->closestInaccessibleRgn = neighbor;
32 }
33 }
34 }
35};

Callers 1

onMatchStartMethod · 0.80

Calls 5

getCenterMethod · 0.95
getRegionGroupIDMethod · 0.95
getApproxDistanceMethod · 0.80
getRegionMethod · 0.45
getCenterMethod · 0.45

Tested by

no test coverage detected