Rename and comment ticksPerNormalMove

This commit is contained in:
Marc Di Luzio 2020-07-23 16:41:08 +01:00
parent be74183878
commit 46d904acc6
2 changed files with 7 additions and 6 deletions

View file

@ -11,7 +11,8 @@ import (
) )
const ( const (
TicksPerNormalMove = 4 // ticksPerNormalMove defines the number of ticks it should take for a "normal" speed move
ticksPerNormalMove = 4
) )
// CommandStream is a list of commands to execute in order // CommandStream is a list of commands to execute in order
@ -515,16 +516,16 @@ func (w *World) Tick() {
switch diff { switch diff {
case 0: case 0:
// Going with the wind, travel at base speed of once every 4 ticks // Going with the wind, travel at base speed of once every 4 ticks
ticksToMove = TicksPerNormalMove ticksToMove = ticksPerNormalMove
case 1: case 1:
// At a slight angle, we can go a little faster // At a slight angle, we can go a little faster
ticksToMove = TicksPerNormalMove / 2 ticksToMove = ticksPerNormalMove / 2
case 2: case 2:
// Perpendicular to wind, max speed // Perpendicular to wind, max speed
ticksToMove = 1 ticksToMove = 1
case 3: case 3:
// Heading at 45 degrees into the wind, back to min speed // Heading at 45 degrees into the wind, back to min speed
ticksToMove = TicksPerNormalMove ticksToMove = ticksPerNormalMove
case 4: case 4:
// Heading durectly into the wind, no movement at all // Heading durectly into the wind, no movement at all
default: default:

View file

@ -419,7 +419,7 @@ func TestWorld_Sailing(t *testing.T) {
assert.Equal(t, maths.Vector{Y: 0}, info.Pos) assert.Equal(t, maths.Vector{Y: 0}, info.Pos)
// Loop a few more times // Loop a few more times
for i := 0; i < TicksPerNormalMove-2; i++ { for i := 0; i < ticksPerNormalMove-2; i++ {
world.Tick() world.Tick()
info, err := world.GetRover(name) info, err := world.GetRover(name)
assert.NoError(t, err) assert.NoError(t, err)
@ -441,7 +441,7 @@ func TestWorld_Sailing(t *testing.T) {
assert.Equal(t, roveapi.Bearing_South, b) assert.Equal(t, roveapi.Bearing_South, b)
// Tick a bunch, we should never move // Tick a bunch, we should never move
for i := 0; i < TicksPerNormalMove*2; i++ { for i := 0; i < ticksPerNormalMove*2; i++ {
world.Tick() world.Tick()
info, err := world.GetRover(name) info, err := world.GetRover(name)
assert.NoError(t, err) assert.NoError(t, err)