Merge pull request #35 from mdiluz/fix-starting-wind

Add the starting wind as north and ensure it's only updated the next day
This commit is contained in:
Marc Di Luzio 2020-07-24 23:27:07 +01:00 committed by GitHub
commit abf67f7f37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,7 @@ func NewWorld(chunkSize int) *World {
TicksPerDay: 24,
CurrentTicks: 0,
Accountant: accounts.NewSimpleAccountant(),
Wind: roveapi.Bearing_North,
}
}
@ -617,11 +618,6 @@ func (w *World) Tick() {
}
}
// Change the wind every day
if (w.CurrentTicks % w.TicksPerDay) == 0 {
w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing
}
// Move all the rovers based on current wind and sails
for n, r := range w.Rovers {
// Skip if we're not catching the wind
@ -675,6 +671,11 @@ func (w *World) Tick() {
// Increment the current tick count
w.CurrentTicks++
// Change the wind every day
if (w.CurrentTicks % w.TicksPerDay) == 0 {
w.Wind = roveapi.Bearing((rand.Int() % 8) + 1) // Random cardinal bearing
}
}
// ExecuteCommand will execute a single command