Skip to content

fix: define colors up to max player ID for non-consecutive IDs#60

Open
ravjot07 wants to merge 1 commit intogambitproject:mainfrom
ravjot07:fix/color-nonconsecutive-players
Open

fix: define colors up to max player ID for non-consecutive IDs#60
ravjot07 wants to merge 1 commit intogambitproject:mainfrom
ravjot07:fix/color-nonconsecutive-players

Conversation

@ravjot07
Copy link
Copy Markdown

Problem

For distinctipy and colorblind, LaTeX colour names are p1rgb, p2rgb, … and get_player_color() uses the actual player index (p{player}rgb). color_definitions() was driven by num_players taken as len(player_ids) for .ef games.
If a game used non-consecutive player IDs (e.g. 1, 2, 5), only three colours (p1rgb–p3rgb) were defined while the tree still referenced p5rgb, which broke LaTeX compilation with an undefined colour.

Solution

When inferring num_players from .ef player N lines, use max(player_nums) instead of len(player_nums), so the palette spans every ID that can appear in the diagram.
pygambit games are unchanged: num_players = len(game.players) still matches consecutive Gambit player indices.

color_definitions() names colors p1rgb, p2rgb, …, p{N}rgb sequentially,
and get_player_color() looks up p{player}rgb by actual player number.
When player IDs are non-consecutive (e.g. 1, 2, 5) the old code passed
len(player_nums)=3, leaving p5rgb undefined and causing a LaTeX error.

Use max(player_nums) instead so all referenced colors are defined.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant