TheDocumentation 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.
Donkey class is the core simulation entity in Constellations. It encapsulates all resource state — position, health, energy, stored grass, and age — and exposes the methods that GameView and DonkeyViewController call on every traversal step. Rather than raising exceptions on failure, every mutating method returns a BaseReturn so callers can check success or read a descriptive error inline.
HealthType Enum
HealthType is an Enum defined in Donkey.py that maps named health bands to a display string and a numeric percentage. The Donkey’s health_status attribute always holds one of these values.
| Value | Text | Percent |
|---|---|---|
EXCELLENT | Excellent | 100 |
GOOD | Good | 75 |
BAD | Bad | 50 |
DYING | Dying | 25 |
DEAD | Dead | 0 |
__init__: .text (the display string) and .percent (the numeric threshold).
Constructor
set_health_status(health) to derive the starting health_status enum member.
Horizontal grid coordinate of the donkey’s starting position.
Vertical grid coordinate of the donkey’s starting position.
Starting age in simulation years. Modified by
research_at_star via ageImpact.Starting energy level (0–100). Consumed by travel and research; replenished by eating.
Starting health percentage (0–100). Passed directly to
set_health_status during construction.Starting stored-grass reserve in kg. Consumed by travel and eating actions.
Sprite or display object used by the view layer. Stored as-is; not used by any model logic.
Methods
is_dead() → bool
Checks three mutually exclusive death conditions in order. Sets self.death_cause as a side-effect when a condition is met, or clears it to None when the donkey is alive.
| Condition | death_cause set |
|---|---|
health_percent <= 0 | "Health depleted" |
energy_donkey <= 0 | "Energy depleted" |
grass_stored <= 0 and energy_donkey < 10 | "Starvation (no grass)" |
bool
get_death_cause() → dict
Returns a snapshot of the donkey’s state at the time of the call. Calls is_dead() internally to decide which branch to use.
Returns: dict with keys:
| Key | Type | Description |
|---|---|---|
cause | str | "Alive" if living, otherwise the death string. |
energy | float | Current energy (floored at 0 if dead). |
health | float | Current health percent (floored at 0 if dead). |
age | int | Current age. |
grass | float | Current grass reserve (floored at 0 if dead). |
set_health_status(percent) → BaseReturn
Validates percent and updates both health_percent and health_status. After setting the value it calls is_dead() — if the donkey has just died, response.ok is set to False.
New health value. Must be in the range 0–100 (inclusive). Values outside this range produce a failed
BaseReturn without mutating state.BaseReturn — ok=False with a descriptive error if percent is out of range or the donkey has died.
can_eat() → bool
Returns True when the donkey’s health is in the range 0 < percent < 50. A donkey at full health or already dead cannot eat.
Returns: bool
travel(distance) → BaseReturn
Moves the donkey by distance units, consuming energy, grass, and health. Accepts either a raw number or a dict carrying a "distance" key (as produced by graph edge weights).
Distance to travel. If a
dict, the value at key "distance" is used. Pre-travel checks abort with ok=False if the donkey is already dead, or if energy or grass reserves are insufficient.| Resource | Formula |
|---|---|
energy_donkey | distance × 0.1 |
grass_stored | distance × 0.02 |
health_percent | distance × 0.05 |
BaseReturn — on success, response.msg is set to "Traveled {distance} units".
eat_at_star(star_data) → BaseReturn
Attempts to eat at the current star. Requires can_eat() to return True. Consumes star_data["timeToEat"] kg of stored grass and adds star_data["amountOfEnergy"] to energy_donkey (capped at 100). If the star is a hypergiant, health is boosted by 10 percentage points.
Star properties dict. Relevant keys:
| Key | Type | Description |
|---|---|---|
timeToEat | float | Grass cost in kg. Defaults to 0 if absent. |
amountOfEnergy | float | Energy gained. Negative values are made positive. |
hypergiant | bool | If True, grants +10 health percent after eating. |
BaseReturn — ok=False if the donkey is dead, cannot eat, or has insufficient grass.
research_at_star(star_data) → BaseReturn
Performs a research action at the current star. Consumes energy based on researchTime and energyPerResearchTime, then applies healthImpact and ageImpact to the donkey’s state.
Star properties dict. Relevant keys:
| Key | Type | Description |
|---|---|---|
researchTime | float | Duration of research. Defaults to 0. |
energyPerResearchTime | float | Energy consumed per unit of research time. |
healthImpact | float | Delta applied to health_percent (can be negative). |
ageImpact | float | Delta applied to age (can be negative). |
BaseReturn — on success, response.msg describes how many years were gained or lost.
get_health_percent() → float
Returns the current value of self.health_percent without any side effects.
Returns: float — the current health percentage (0–100).
get_travel_cost(distance) → dict
Returns a preview of the resource costs for a given distance without mutating any state.
Distance to cost-check. Accepts a raw number or a dict with a
"distance" key.dict
to_dict() → dict
Serialises the donkey’s current state to a plain dictionary suitable for JSON output or view rendering.
Returns: dict
| Key | Type | Description |
|---|---|---|
x | int | Current x coordinate. |
y | int | Current y coordinate. |
health | str | health_status.text (e.g. "Good"). |
age | int | Current age. |
energy_donkey | float | Current energy level. |
grass | float | Current grass reserve. |
sprite | Any | The sprite object passed at construction. |