diff --git a/internal/app/engine/engine.go b/internal/app/engine/engine.go index b7bcdf2c..989d4ba7 100644 --- a/internal/app/engine/engine.go +++ b/internal/app/engine/engine.go @@ -43,6 +43,7 @@ type Engine struct { botNumberProcessor BotNumberProcessor tickChanProvider func() <-chan time.Time rand *rand.Rand + randomPlacingTeam state.Team } // NewEngine creates a new engine @@ -74,6 +75,7 @@ func NewEngine(gameConfig config.Game, engineConfig config.Engine) (e *Engine) { return time.After(25 * time.Millisecond) } e.rand = rand.New(rand.NewSource(time.Now().Unix())) + e.randomPlacingTeam = state.Team_UNKNOWN return } diff --git a/internal/app/engine/process_continue_next_action.go b/internal/app/engine/process_continue_next_action.go index ed4df65b..f57c39c5 100644 --- a/internal/app/engine/process_continue_next_action.go +++ b/internal/app/engine/process_continue_next_action.go @@ -164,6 +164,9 @@ func (e *Engine) nextActions() (actions []*ContinueAction, hints []*ContinueHint actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FREE_KICK, state.Team_YELLOW)) actions = append(actions, e.createNextCommandContinueAction(ContinueAction_FREE_KICK, state.Team_BLUE)) } + } else { + // reset random placing team + e.randomPlacingTeam = state.Team_UNKNOWN } if *e.currentState.Command.Type == state.Command_HALT { @@ -309,9 +312,12 @@ func (e *Engine) ballPlacementTeam() state.Team { teamInFavor = *e.currentState.NextCommand.ForTeam } if teamInFavor.Unknown() { - // select a team by 50% chance (for example for force start) - teamInFavor = e.randomTeam() - log.Printf("No team in favor. Chose one randomly.") + if e.randomPlacingTeam.Unknown() { + // select a team by 50% chance (for example for force start) + e.randomPlacingTeam = e.randomTeam() + log.Printf("No team in favor. Chose one randomly: %v", e.randomPlacingTeam) + } + teamInFavor = e.randomPlacingTeam } if e.currentState.TeamInfo(teamInFavor).BallPlacementAllowed() {