Skip to content

Commit 3a623d9

Browse files
committed
Automatically request robot substitution on too many robots
1 parent 16b3a2d commit 3a623d9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

internal/app/engine/process_continue.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ func (e *Engine) readyToContinuePenalty() (issues []string) {
118118
}
119119

120120
func (e *Engine) readyToContinueFromStop() (issues []string) {
121+
for _, team := range state.BothTeams() {
122+
if e.currentState.TeamInfo(team).RequestsBotSubstitutionSince != nil {
123+
// next action is robot substitution, no need to check the other issues
124+
return
125+
}
126+
}
121127
if e.tooManyRobots(state.Team_YELLOW) {
122128
issues = append(issues, "Yellow team has too many robots")
123129
}

internal/app/statemachine/change_gameevent.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/RoboCup-SSL/ssl-game-controller/internal/app/state"
88
"google.golang.org/protobuf/proto"
99
"google.golang.org/protobuf/types/known/durationpb"
10+
"google.golang.org/protobuf/types/known/timestamppb"
1011
"log"
1112
"time"
1213
)
@@ -126,6 +127,20 @@ func (s *StateMachine) processChangeAddGameEvent(newState *state.State, change *
126127
changes = append(changes, s.createCommandChange(state.NewCommandNeutral(state.Command_HALT)))
127128
}
128129

130+
// too many robots
131+
if *gameEvent.Type == state.GameEvent_TOO_MANY_ROBOTS {
132+
byTeam := *gameEvent.GetTooManyRobots().ByTeam
133+
if byTeam.Known() {
134+
log.Printf("Team %s has too many robots. Requesting robot substition for them", byTeam)
135+
newState.TeamInfo(byTeam).RequestsBotSubstitutionSince = timestamppb.New(s.timeProvider())
136+
} else {
137+
log.Printf("Too many robots, but no information on team. Requesting for both")
138+
for _, team := range state.BothTeams() {
139+
newState.TeamInfo(team).RequestsBotSubstitutionSince = timestamppb.New(s.timeProvider())
140+
}
141+
}
142+
}
143+
129144
// challenge flag
130145
if *gameEvent.Type == state.GameEvent_CHALLENGE_FLAG {
131146
log.Printf("Reduce number of timeouts for %v by one for challenge flag", byTeam)

0 commit comments

Comments
 (0)