Skip to content

Commit f9b9fd9

Browse files
committed
[rules] Add new division-specific timeout times to config
1 parent 799ba1b commit f9b9fd9

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

config/ssl-game-controller.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ game:
2121
multiple-placement-failures: 5
2222
auto-ref-proposal-timeout: 5s
2323
default-division: DIV_A
24-
free-kick-time:
24+
prepare-timeout: 10s
25+
free-kick-timeout:
26+
DIV_A: 5s
27+
DIV_B: 10s
28+
no-progress-timeout:
2529
DIV_A: 5s
2630
DIV_B: 10s
27-
general-time: 10s
2831
ball-placement-time: 30s
2932
ball-placement-time-top-up: 10s
3033
normal:

internal/app/config/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ type Game struct {
4545
MultiplePlacementFailures int32 `yaml:"multiple-placement-failures"`
4646
MaxBots map[Division]int32 `yaml:"max-bots"`
4747
AutoRefProposalTimeout time.Duration `yaml:"auto-ref-proposal-timeout"`
48-
FreeKickTime map[Division]time.Duration `yaml:"free-kick-time"`
49-
GeneralTime time.Duration `yaml:"general-time"`
48+
PrepareTimeout time.Duration `yaml:"prepare-timeout"`
49+
FreeKickTimeout map[Division]time.Duration `yaml:"free-kick-timeout"`
50+
NoProgressTimeout map[Division]time.Duration `yaml:"no-progress-timeout"`
5051
BallPlacementTime time.Duration `yaml:"ball-placement-time"`
5152
BallPlacementTimeTopUp time.Duration `yaml:"ball-placement-time-top-up"`
5253
StateStoreFile string `yaml:"state-store-file"`
@@ -148,8 +149,9 @@ func DefaultControllerConfig() (c Controller) {
148149
c.Game.MultipleFoulStep = 3
149150
c.Game.MultiplePlacementFailures = 5
150151
c.Game.AutoRefProposalTimeout = 5 * time.Second
151-
c.Game.GeneralTime = time.Second * 10
152-
c.Game.FreeKickTime = map[Division]time.Duration{DivA: time.Second * 5, DivB: time.Second * 10}
152+
c.Game.PrepareTimeout = time.Second * 10
153+
c.Game.FreeKickTimeout = map[Division]time.Duration{DivA: time.Second * 5, DivB: time.Second * 10}
154+
c.Game.NoProgressTimeout = map[Division]time.Duration{DivA: time.Second * 5, DivB: time.Second * 10}
153155
c.Game.BallPlacementTime = time.Second * 30
154156
c.Game.BallPlacementTimeTopUp = time.Second * 10
155157

internal/app/config/testdata/config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ game:
2121
multiple-placement-failures: 5
2222
auto-ref-proposal-timeout: 5s
2323
default-division: DIV_A
24-
free-kick-time:
24+
prepare-timeout: 10s
25+
free-kick-timeout:
26+
DIV_A: 5s
27+
DIV_B: 10s
28+
no-progress-timeout:
2529
DIV_A: 5s
2630
DIV_B: 10s
27-
general-time: 10s
2831
ball-placement-time: 30s
2932
ball-placement-time-top-up: 10s
3033
normal:

internal/app/statemachine/change_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ func (s *StateMachine) NewCommand(newState *state.State, newCommand *NewCommand)
1313
case state.Command_BALL_PLACEMENT:
1414
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.BallPlacementTime)
1515
case state.Command_DIRECT, state.Command_INDIRECT:
16-
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.FreeKickTime[newState.Division.Div()])
16+
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.FreeKickTimeout[newState.Division.Div()])
1717
case state.Command_KICKOFF, state.Command_PENALTY:
18-
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.GeneralTime)
18+
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.PrepareTimeout)
1919
case state.Command_TIMEOUT:
2020
*newState.TeamInfo(*newState.Command.ForTeam).TimeoutsLeft--
2121
}

internal/app/statemachine/change_gameevent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (s *StateMachine) AddGameEvent(newState *state.State, change *AddGameEvent)
143143
// defender too close to kick point
144144
if *gameEvent.Type == state.GameEvent_DEFENDER_TOO_CLOSE_TO_KICK_POINT {
145145
log.Printf("Reset current action time because defender of team %v was too close to kick point", byTeam)
146-
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.GeneralTime)
146+
newState.CurrentActionTimeRemaining = ptypes.DurationProto(s.gameConfig.PrepareTimeout)
147147
}
148148

149149
// stop the game if needed

internal/app/statemachine/statemachine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Test_Statemachine(t *testing.T) {
3535
}},
3636
wantNewState: func(s *state.State) {
3737
s.Command = state.NewCommand(state.Command_DIRECT, state.Team_BLUE)
38-
s.CurrentActionTimeRemaining = ptypes.DurationProto(gameConfig.FreeKickTime[config.DivA])
38+
s.CurrentActionTimeRemaining = ptypes.DurationProto(gameConfig.FreeKickTimeout[config.DivA])
3939
},
4040
},
4141
{

0 commit comments

Comments
 (0)