The Constellations simulation represents the night sky as a weighted undirected graph. A JSON file defines one or more named constellation groups, each containing a list of stars. Every star becomes a vertex in the graph, and everyDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/Constellations/llms.txt
Use this file to discover all available pages before exploring further.
linkedTo entry between two stars becomes a shared weighted edge. This structure lets the game apply standard graph algorithms — shortest path, longest path — directly to the star map, while keeping the visual layout driven by the same data.
Vertices and Edges
Two classes insrc/models/Graph.py form the backbone of the topology: Vertex, which holds a star’s adjacency map and metadata, and Graph, which is the container for the whole star field.
{"distance": <float>, "blocked": <bool>}) rather than a plain number, so additional metadata can travel with the connection.
| Method | Parameters | Description |
|---|---|---|
add_vertex(id, data) | id — vertex key (star label); data — star JSON dict | Inserts a new Vertex. If the label already exists, updates its data payload instead of creating a duplicate. |
add_edge(from_id, to_id, weight) | from_id, to_id — star labels; weight — edge weight dict | Creates both directions of the edge atomically, enforcing undirectedness. Auto-creates either endpoint if it is missing. |
get_vertex(id) | id — star label | Returns the Vertex object, or None if the label is not present. |
get_vertices() | — | Returns a dict_keys view of all vertex labels currently in the graph. |
The graph is undirected —
add_edge() calls add_neighbor() on both endpoints simultaneously. Every link in Constellations.json is therefore stored as two half-edges, so you will see symmetric entries when iterating vertex.adjacent.Loading a Constellation
GraphController.load_graph() in src/controllers/GraphController.py is responsible for turning raw JSON into a live Graph. It works in two passes: first it builds an id → label look-up table and creates every vertex, then it iterates again to wire up the edges using labels as keys.
linkedTo are always resolved to human-readable labels (A, B, C …) before any edges are created. The full star JSON object — including coordenates, hypergiant, timeToEat, and research fields — is stored verbatim inside Vertex.data so every subsystem can access it without a separate look-up.
Graph Visualization
TheGraphView class in src/ui/views/GraphView.py reads the coordenates field directly from each star’s JSON data to position nodes on screen:
GraphView._assign_colors_to_constellations() iterates the constellation list, sorts the names alphabetically, and assigns one colour from a fixed palette in round-robin order:
| Palette slot | Arcade colour |
|---|---|
| 0 | BLUE_GREEN |
| 1 | PURPLE |
| 2 | ORANGE |
| 3 | CYAN |
| 4 | SKY_BLUE |
| 5 | ROSE |
| 6 | SPRING_GREEN |
| 7 | TURQUOISE |
| 8 | YELLOW_ORANGE |
| 9 | PASTEL_PINK |
| 10 | BANANA_YELLOW |
| 11 | LIGHT_CORAL |
"hypergiant": true is always drawn in gold (arcade.color.GOLD), making it immediately recognisable regardless of which constellation it belongs to. Star G in the bundled Constellations.json is the only hypergiant in the default data set.
Edge States
Every edge weight dictionary carries ablocked flag initialised to False by load_graph(). The flag is toggled at runtime by GraphController.toggle_edge(from_label, to_label), which flips the boolean on both half-edges simultaneously. GraphView.draw_graph() inspects the flag while rendering each line:
| State | Colour | Meaning |
|---|---|---|
blocked: False, not highlighted | White | Normal traversable edge |
blocked: True | Red | Blocked — skipped by Dijkstra and impassable to the donkey |
| Part of the active highlighted path | Yellow | Most recent shortest or longest path result |
"blocked": true during the relaxation step, so toggling an edge on or off takes effect immediately the next time a path is computed without requiring a graph reload.