-
Notifications
You must be signed in to change notification settings - Fork 1
Representing the Game Map
Rac Mukkamala edited this page Feb 25, 2019
·
3 revisions
- The map will be represented using the CityMap class, which contains an Adjacency Edge List.
- Train Tracks between cities are the edges, and the cities themselves are the vertices.
- The player will have their own graph of all their tracks, and GameState will also have a graph of every single connection created.
- This makes it easier for individual players to find their longest path and find connections using their personalized graph, while the "master" graph allows GameState to check who is occupying which tracks.
Finding if Two Cities are Connected: This problem can easily be solved by a standard Depth-First Traversal (DFS) through the graph.
Finding the longest continuous path: The longest path can found using a combination of dynamic programming (DP) and a Depth-First Search (DFS). The algorithm will basically find every single path and add up its edge weights and store these values, later returning the max of these values.
Adding Edges The Adjacency Edge List will be made of a List of ArrayLists, allowing for flexibility and ease in adding new cities and edges. Since this application involves an undirected graph, an edge will need to be added in both directions.