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

Method onStart

bwapi/TestAIModule/Source/MapTest.cpp:4–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3using namespace BWAPI;
4void MapTest::onStart()
5{
6 BWAssert(Broodwar->isReplay()==false);
7 Broodwar->enableFlag(Flag::CompleteMapInformation);
8 Broodwar->setLocalSpeed(0);
9 Broodwar->setFrameSkip(512);
10 BWAssert(Broodwar->mapWidth()==192);
11 BWAssert(Broodwar->mapHeight()==128);
12 BWAssert(Broodwar->mapFileName()=="MapTest.scx");
13 //Don't assert this since path is allowed to differ
14 Broodwar->printf("%s",Broodwar->mapPathName().c_str());
15 BWAssert(Broodwar->mapName()=="Test Map");
16
17 //Update this whenever the map is modified
18 BWAssert(Broodwar->mapHash()=="b1458acae03d6bbacd223ba8c96830b28a6035fb");
19
20 for ( int x = 0; x < 10; ++x )
21 for ( int y = 0; y < 10; ++y )
22 {
23 BWAssert(Broodwar->isWalkable( WalkPosition(x,y) ));
24 BWAssert(Broodwar->getGroundHeight(x,y)==2);
25 BWAssert(Broodwar->isBuildable(x,y));
26 BWAssert(Broodwar->isVisible(x,y));
27 BWAssert(Broodwar->isExplored(x,y));
28 }
29
30 for(int x=5;x<14;x++)
31 {
32 BWAssertF(Broodwar->hasCreep(x,0), { log(" hasCreep(%u,0)", x); });
33 }
34 for(int x=14;x<40;x++)
35 {
36 BWAssert(Broodwar->hasCreep(x,0)==false);
37 }
38 for(int x=13;x<20;x++)
39 {
40 for(int y=10;y<15;y++)
41 {
42 BWAssert(Broodwar->hasPower(x,y,2,2));
43 }
44 }
45 for(int x=50;x<60;x++)
46 {
47 for(int y=50;y<60;y++)
48 {
49 BWAssert(Broodwar->getGroundHeight(x,y)==0);
50 BWAssert(Broodwar->isBuildable(x,y));
51 BWAssert(Broodwar->isVisible(x,y)==false);
52 BWAssert(Broodwar->isExplored(x,y)==false);
53 BWAssert(Broodwar->hasPower(x,y,2,2)==false);
54 }
55 }
56
57 //briefly check some of these functions. Can add more test cases later if needed
58 BWAssert(Broodwar->canBuildHere(TilePosition(18,12),UnitTypes::Protoss_Pylon));
59 BWAssert(Broodwar->canBuildHere(TilePosition(18,12),UnitTypes::Protoss_Gateway));
60 BWAssert(Broodwar->canMake(UnitTypes::Protoss_Gateway)==false);
61 BWAssert(Broodwar->canResearch(TechTypes::Psionic_Storm)==false);

Callers

nothing calls this directly

Calls 15

logFunction · 0.85
printfMethod · 0.80
c_strMethod · 0.80
hasPowerMethod · 0.80
canBuildHereMethod · 0.80
canMakeMethod · 0.80
isReplayMethod · 0.45
enableFlagMethod · 0.45
setLocalSpeedMethod · 0.45
setFrameSkipMethod · 0.45
mapWidthMethod · 0.45
mapHeightMethod · 0.45

Tested by

no test coverage detected