Crate ticket2ride[−][src]
Expand description
Relevant data structures for representing ticket to ride Europe.
Here I provide some enumerations and hash maps that are required for representing the ticket to ride Europe game in my code. This is a first implementation so be gentle in judging it.
Structs
The struct for representing a game ticket which includes the departure city, the arrival city and the value of the ticket when it is satisfied. This struct is used for both regular tickets and the six big tickets.
Enums
All available cities of the game are included into this handy enumeration, so that my code is more clear. The cities are not entered with any particular order, I just started from Edinburgh and traversed the map gradually most of the times randomly.
Functions
This function creates the game network. This is a Hash map of which the keys are the cities of the game and the value of each key is a Hash map of the cities that the key city can connect with and the number of trains that are needed to connect to that city.
This function returns a vector with the 6 big tickets of the game. Differentiating between big tickets and small tickets is not relevant for computing the max theoretical score but still it’s nice to have it separately, for future stuff to come.
This returns a vector with the regular tickets of the game.
This is a helper function the finds the maximum value in a HashMap and returns the key of that maximum value. This is basically used to find the path with the largest score in the possible paths computed from a specific starting city.