Releases: Auzzy/1846-routes
Stabilize route counts and missing subroutes
This release corrects two issues: a non-deterministic number of routes found, and generating an incomplete list of subroutes.
The non-deterministic number of routes was due to an incorrect hashing function. It was hashing the list of tile objects which make up a given route. Since the tiles were actually a set being converted to a list for hashing, their order was non-deterministic, meaning route collisions were not always detected. The solution was to instead hash cell coordinates, and to first sort them.
The incomplete list of subroutes was due to omitting the start coordinate when it was the last coorindate in a subroute. This was alright when subroutes was just used to increase the route options. But its use to determine that routes use a valid path through Chicago means we must include it.
Mark railroads as removed
If a railroad is removed from the game, its home city is not passable (all 3 removable railroads have a non-upgradable home city with 1 station). This effect can be achieved by simply denoting a railroad as opened, but having no trains or other stations. However, by allowing railroads to be explicitly marked as removed from the game, the library can be a bit more user friendly. It can prevent removed railroads from being assigned private companies, and from running routes, presenting a straightforward error message in each case,
Correct overlooked rule
Ensures that one of the counted cities in a route contains the railroad's station. Used the same logic to confirm both terminal cities are counted if a route gets the EW bonus, which was no longer certain given the first fix.
NOTE: 0.18 was skipped due to an error uploading it to PyPI.
Expose (and display) visited cities
Adds the visited_cities property and city_values dictionary to a run route. This allows consumers to more easily understand which cities contributed their value to the whole route value, and what that value was.
Fixed 2 minor route issues
One fix ensures that if a railroad has no valid routes, it will gracefully display no routes rather than raise an exception. This is only possible for Illinois Central and Grand Trunk, as the other 5 all have legal routes from their home city.
The other fix was to re-enable the route C5 -> D6 (Chicago Connections to Chicago). Incorrect filtering logic caused it to be marked as invalid. In reality, as long as the railroad has a station on Chicago, it's always legal (assuming the phase 2 tile or higher has been placed).
Remove independent railroad tokens in phase 3
Although the rest of the private company tokens are removed in phase 4, independent railroad tokens are removed in phase 3.
Support Independent Railroads
Adds support for Michigan Southern and Big 4.
When no owner is provided, their station is placed on their home city, and acts just like a regular station. If an owner is provided, that railroad is automatically assigned a station at the independent railroad's home city. If it's phase 4 and no owner is provided for the independent railroad, no station is placed, since private company tokens are removed during phase 4.
Separate private companies input
This replaces the old, awkward method of private company entry via the railroads table. By having its own table, it makes a number of things easier, such as validation. It also makes the entry easier, since each company has its own row instead of its own column.
Fix validation typo
A typo in the validation method caused the validation loop to end early. Since this loop returns a list of valid routes, early termination meant some routes were left out. Which routes were left out was effectively random, as it's iterating over a set, so it's up to the whims of Python's hashing and iteration implementation.
The simple solution was to switch a single "break" to "continue". The piece of code was originally inside a nested loop, and when I pulled it out, I missed making the switch.
Auto-place railroad stations
The user no longer needs to provide the railroad's home station, as it's automatically placed for them based on the railroad name.