18xx icon indicating copy to clipboard operation
18xx copied to clipboard

Move the auto-router path timeout check to an inner loop

Open ollybh opened this issue 1 year ago • 0 comments

Implementation Notes

Explanation of Change

The auto-router's path timeout is supposed to stop too much time being spent on building up the set of possible routes for trains. It was being checked once in each iteration of possible starting nodes for routes.

However, in particularly degenerate cases this meant that far too long was elapsing between timeout checks: issue tobymao#11252 had more than ten hours pass before the first and second timeout checks.

This moves the timeout check to an inner loop, so it is checked more frequently.

Fixes #11252.

Any Assumptions / Hacks

This uses a custom error class to break out of the loop if too long has elapsed. There are other ways that this could be done, I'm not sure if this is the best.

Before clicking "Create"

  • [x] Branch is derived from the latest master
  • ~Add the pins or archive_alpha_games label if this change will break existing games~
  • [x] Code passes linter with docker compose exec rack rubocop -a
  • [x] Tests pass cleanly with docker compose exec rack rake

ollybh avatar Oct 06 '24 18:10 ollybh