Skip to content

Commit

Permalink
Automatically request robot substitution on too many robots
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Apr 24, 2022
1 parent 16b3a2d commit 3a623d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/app/engine/process_continue.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ func (e *Engine) readyToContinuePenalty() (issues []string) {
}

func (e *Engine) readyToContinueFromStop() (issues []string) {
for _, team := range state.BothTeams() {
if e.currentState.TeamInfo(team).RequestsBotSubstitutionSince != nil {
// next action is robot substitution, no need to check the other issues
return
}
}
if e.tooManyRobots(state.Team_YELLOW) {
issues = append(issues, "Yellow team has too many robots")
}
Expand Down
15 changes: 15 additions & 0 deletions internal/app/statemachine/change_gameevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/RoboCup-SSL/ssl-game-controller/internal/app/state"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"log"
"time"
)
Expand Down Expand Up @@ -126,6 +127,20 @@ func (s *StateMachine) processChangeAddGameEvent(newState *state.State, change *
changes = append(changes, s.createCommandChange(state.NewCommandNeutral(state.Command_HALT)))
}

// too many robots
if *gameEvent.Type == state.GameEvent_TOO_MANY_ROBOTS {
byTeam := *gameEvent.GetTooManyRobots().ByTeam
if byTeam.Known() {
log.Printf("Team %s has too many robots. Requesting robot substition for them", byTeam)
newState.TeamInfo(byTeam).RequestsBotSubstitutionSince = timestamppb.New(s.timeProvider())
} else {
log.Printf("Too many robots, but no information on team. Requesting for both")
for _, team := range state.BothTeams() {
newState.TeamInfo(team).RequestsBotSubstitutionSince = timestamppb.New(s.timeProvider())
}
}
}

// challenge flag
if *gameEvent.Type == state.GameEvent_CHALLENGE_FLAG {
log.Printf("Reduce number of timeouts for %v by one for challenge flag", byTeam)
Expand Down

0 comments on commit 3a623d9

Please sign in to comment.