Skip to content

grid.ticks increments by 2 per tick() (pre-existing) #9

Description

@gilesknap

Summary

World::grid.ticks advances by 2 for every logical tick, not 1.

This is long-standing behaviour, not introduced by the multithreading work. The original World::tick() incremented grid.ticks at both its start and end:

pub fn tick(&mut self) {
    self.grid.ticks += 1;   // start
    // ... think + grass ...
    self.apply_updates();
    self.grid.ticks += 1;   // end
}

The think/resolve refactor (PR #5) preserved this exactly: one increment now lives in think_phase() and one in resolve_phase(), so tick() still yields +2.

Why it matters

grid.ticks is used by:

  • Grass-growth schedulingnext_grass_tick is compared against grid.ticks, so grass effectively grows on a tick scale that is 2× the logical tick count (and ticks_per_grass() is implicitly calibrated to the +2 cadence).
  • The GUI tick readout and ticks/sec display.
  • Saved-world tick counts (serialized in WorldGrid).

Decision needed

Changing it to +1 is a one-line removal of the resolve_phase() increment, but it shifts grass cadence and the meaning of ticks, and would want the grass timing / benchmarks re-checked. Filing this so the change can be made deliberately rather than bundled into the threading PR.

Flagged by CodeRabbit on PR #5.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions