@@ -11,7 +11,9 @@ const minPreparationTime = time.Second * 2
1111const distanceToBallDuringPenalty = 1.0
1212
1313func (e * Engine ) processContinue () {
14- if ! (e .currentState .Command .IsPrepare () || * e .currentState .Command .Type == state .Command_STOP ) ||
14+ if ! (e .currentState .Command .IsPrepare () ||
15+ * e .currentState .Command .Type == state .Command_STOP ||
16+ (e .gameConfig .ContinueFromHalt && * e .currentState .Command .Type == state .Command_HALT )) ||
1517 e .gcState .TrackerStateGc .Ball == nil {
1618 e .gcState .ReadyToContinue = nil
1719 return
@@ -89,6 +91,12 @@ func (e *Engine) processContinue() {
8991 return
9092 }
9193
94+ if * e .currentState .Command .Type == state .Command_STOP &&
95+ (e .currentState .NextCommand == nil ||
96+ ! e .readyToContinueFromHalt ()) {
97+ return
98+ }
99+
92100 readyToContinue = true
93101
94102 if e .currentState .GetAutoContinue () {
@@ -138,6 +146,24 @@ func (e *Engine) readyToContinueFromStop() bool {
138146 return true
139147}
140148
149+ func (e * Engine ) readyToContinueFromHalt () bool {
150+ if e .gcState .TrackerStateGc .Ball == nil ||
151+ e .currentState .PlacementPos == nil ||
152+ ! e .ballSteady () ||
153+ e .currentState .PlacementPos .DistanceTo (e .gcState .TrackerStateGc .Ball .Pos .ToVector2 ()) > e .gameConfig .BallPlacementTolerance ||
154+ e .tooManyRobots (state .Team_BLUE ) ||
155+ e .tooManyRobots (state .Team_YELLOW ) {
156+ return false
157+ }
158+ return true
159+ }
160+
161+ func (e * Engine ) tooManyRobots (team state.Team ) bool {
162+ maxAllowed := * e .currentState .TeamState [team .String ()].MaxAllowedBots
163+ current := numRobotsOfTeam (e .gcState .TrackerStateGc .Robots , team )
164+ return current > maxAllowed
165+ }
166+
141167func (e * Engine ) timeSinceLastChange () time.Duration {
142168 if e .stateStore .LatestEntry () != nil {
143169 lastChangeTs := goTime (e .stateStore .LatestEntry ().Timestamp )
0 commit comments