Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1837] Use backtracking graph in the token step #11602

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ollybh
Copy link
Collaborator

@ollybh ollybh commented Mar 3, 2025

Explanation of Change

1837 has two graphs: a standard one and one that allows track to backtrack at junctions. The latter is needed for placing station tokens, where this type of route is allowed.

The token step was not using this graph, it was using the standard one. This meant that not all possible token locations were being included, and an auto-pass was being generated for the token step if the only possible token locations involved backtracking.

Fixes #11600.

This shouldn't break any games. There will be games where the BH should have been able to lay a token on its first turn but wasn't allowed to, but a pass action will have been generated for those turns and that will be in the game actions.

Before clicking "Create"

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

1837 has two graphs: a standard one and one that allows track to
backtrack at junctions. The latter is needed for placing station tokens,
where this type of route is allowed.

The token step was not using this graph, it was using the standard one.
This meant that not all possible token locations were being included,
and an auto-pass was being generated for the token step if the only
possible token locations involved backtracking.

Fixes tobymao#11600.
@ollybh ollybh added the 1837 label Mar 3, 2025
@ollybh ollybh requested a review from crericha March 3, 2025 18:25
@@ -27,7 +27,7 @@ def can_place_token?(entity)
# Cheaper to do the graph first, then check affordability
current_entity == entity &&
!(token = entity.next_token).nil? &&
@game.graph.can_token?(entity) &&
@game.token_graph.can_token?(entity) &&
Copy link
Collaborator

@crericha crericha Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@game.token_graph_for_entity(entity).can_token?(entity)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated (even though it does the same thing).

@@ -40,7 +40,7 @@ def multiple_tokens?(entity)
end

def can_afford_token?(token, cash)
@game.graph.tokenable_cities(token.corporation).any? do |city|
@game.token_graph.tokenable_cities(token.corporation).any? do |city|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@game.token_graph_for_entity(entity).tokenable_cities(token.corporation).any?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Change requested from code review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1837] Cannot token by reverse over junction
2 participants