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

Method update

bwapi/TestAIModule/Source/MPHSTest.cpp:31–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30}
31void MPHSTest::update()
32{
33 if (running == false) return;
34 if (fail)
35 {
36 running = false;
37 return;
38 }
39 int thisFrame = Broodwar->getFrameCount();
40 BWAssert(thisFrame==nextFrame);
41 nextFrame++;
42 Broodwar->setScreenPosition(unit->getPosition() - Position(320,240));
43 if (thisFrame<startFrame+30)
44 {
45 }
46 else if (thisFrame==startFrame+30)
47 {
48 BWAssertF(unit->isBurrowed()==false,{fail=true;return;});
49 BWAssertF(unit->isSieged()==false,{fail=true;return;});
50 BWAssertF(unit->isMoving()==false,{fail=true;return;});
51 BWAssertF(unit->isPatrolling()==false,{fail=true;return;});
52 BWAssertF(unit->isHoldingPosition()==false,{fail=true;return;});
53 BWAssertF(unit->isIdle()==true,{fail=true;return;});
54 targetPosition=unit->getPosition();
55 targetPosition.y+=32*30;
56 targetPosition.makeValid();
57 BWAssertF(unit->move(targetPosition),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;});
58 BWAssertF(unit->getOrder()==Orders::Move,{fail=true;return;});
59 BWAssertF(unit->isMoving()==true,{fail=true;return;});
60 BWAssertF(unit->isPatrolling()==false,{fail=true;return;});
61 BWAssertF(unit->isIdle()==false,{fail=true;return;});
62 BWAssertF(unit->getTargetPosition()==targetPosition,{fail=true;return;});
63 }
64 else if (thisFrame<startFrame+110)
65 {
66 if (thisFrame>startFrame+50)
67 {
68 BWAssertF(unit->getOrder()==Orders::Move,{fail=true;return;});
69 BWAssertF(unit->isMoving()==true,{Broodwar->printf("frame %d",thisFrame-startFrame);fail=true;return;});
70 BWAssertF(unit->isIdle()==false,{fail=true;return;});
71 }
72 BWAssertF(unit->isPatrolling()==false,{fail=true;return;});
73 if (thisFrame>startFrame+60)
74 {
75 BWAssertF(unit->getTargetPosition().getDistance(targetPosition)<64,{Broodwar->printf("frame: %d",thisFrame-startFrame);fail=true;return;});
76 }
77 }
78 else if (thisFrame==startFrame+110)
79 {
80 targetPosition=unit->getPosition();
81 targetPosition.y-=32*30;
82 targetPosition.makeValid();
83 BWAssertF(unit->patrol(targetPosition),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;});
84 BWAssertF(unit->getOrder()==Orders::Patrol,{fail=true;return;});
85 BWAssertF(unit->isMoving()==true,{fail=true;return;});
86 BWAssertF(unit->isPatrolling()==true,{fail=true;return;});
87 BWAssertF(unit->isIdle()==false,{fail=true;return;});
88 BWAssertF(unit->getTargetPosition()==targetPosition,{fail=true;return;});

Callers 1

runTestCasesMethod · 0.45

Calls 15

isBurrowedMethod · 0.80
isSiegedMethod · 0.80
isMovingMethod · 0.80
isPatrollingMethod · 0.80
isHoldingPositionMethod · 0.80
isIdleMethod · 0.80
printfMethod · 0.80
c_strMethod · 0.80
getLastErrorMethod · 0.80
getSecondaryOrderMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45

Tested by

no test coverage detected