Source code for game.utils.constants

"""Game constants and configuration."""

from pathlib import Path

[docs] PACKAGE_DIR = Path(__file__).parent.parent # game/ directory
# Screen settings
[docs] SCREEN_WIDTH = 900
[docs] SCREEN_HEIGHT = 900
[docs] FPS = 60
# Isometric tile settings
[docs] TILE_WIDTH = 64
[docs] TILE_HEIGHT = 32
[docs] TILE_OFFSET_X = TILE_WIDTH // 2
[docs] TILE_OFFSET_Y = TILE_HEIGHT // 2
# Map settings are now loaded dynamically from the map file. # These constants are obsolete and can cause bugs. # MAP_WIDTH = 30 # MAP_HEIGHT = 20 # Game timing
[docs] GAME_DURATION = 90 # 1:30 minutes in seconds
[docs] FEAST_COOLDOWN = 20 # 20 seconds between feasts
[docs] PIG_BIRTH_RATE = 1 # Pigs born per second
# --- Gameplay Tuning: Degradation and Recovery Rates --- # DEGRADATION_RATE = 0.06 # Obsolete: Replaced by entity-specific and cascade rates below. # Degradation caused by entities per second
[docs] PIG_DEGRADATION_RATE = 0.6 # Per-pig rate per second (applied per frame to the pig's tile).
[docs] VILLAGER_DEGRADATION_RATE = 0.3 # Degradation from villagers.
# Cascading degradation effect for heavily damaged tiles
[docs] CASCADE_DEGRADATION_RATE = 0.04
# Natural recovery rate of the island per second
[docs] NATURAL_RECOVERY_RATE = 0.12 # Fast enough that removing pigs gives visible recovery within ~8 s.
[docs] ECOSYSTEM_COLLAPSE_THRESHOLD = 0.8 # Increased from 0.7 to better suit the more volatile gameplay.
# Tile type groups
[docs] WALKABLE_TILES = ['grass', 'degraded_grass', 'forest', 'degraded_forest']
[docs] FOREST_TILES = ['forest', 'degraded_forest']
[docs] ISLAND_TILES = ['grass', 'forest']
# Colors
[docs] COLOR_HEALTHY_GRASS = (34, 139, 34)
[docs] COLOR_DEGRADED_GRASS = (139, 69, 19)
[docs] COLOR_WATER = (0, 0, 0)
[docs] COLOR_FOREST = (0, 100, 0)
[docs] COLOR_DEGRADED_FOREST = (139, 69, 19)
# Entity settings
[docs] PIG_MOVE_SPEED = 4 # tiles per second
[docs] VILLAGER_MOVE_SPEED = 10
[docs] PIG_EATING_RADIUS = 2 # tiles
[docs] VILLAGER_CHOPPING_RADIUS = 2
# Pig reproduction settings
[docs] PIG_REPRODUCTION_URGE_RATE = 0.1 # How fast the urge builds up per second (0 to 1)
[docs] PIG_REPRODUCTION_THRESHOLD = 0.8 # Urge level required to be ready
[docs] PIG_REPRODUCTION_COOLDOWN = 15.0 # Seconds a pig must wait after reproducing
[docs] PIG_REPRODUCTION_RADIUS = 2.0 # How close pigs must be to mate (in tiles)
[docs] PIG_LITTER_SIZE = 3 # Number of offspring per birth
# UI settings
[docs] UI_FONT_SIZE = 24
[docs] BUTTON_WIDTH = 200
[docs] BUTTON_HEIGHT = 50
[docs] INFO_POPUP_DURATION = 3 # seconds
# Scoring
[docs] SCORE_PER_SECOND = 10
[docs] SCORE_BONUS_HEALTHY_ENVIRONMENT = 0
[docs] SCORE_PENALTY_DEGRADED_ENVIRONMENT = -7
[docs] GRAPH_HISTORY_LENGTH = 200 # How many data points to show on the graph
[docs] GRAPH_UPDATE_INTERVAL = 0.2 # Seconds between graph data points
# Villager Happiness Constants
[docs] HAPPINESS_IDEAL_PIG_MIN = 150 # Minimum pigs for peak food happiness
[docs] HAPPINESS_IDEAL_PIG_MAX = 300 # Maximum pigs for peak food happiness
[docs] HAPPINESS_MAX_PIG_COUNT = 600 # Pig count at which food happiness becomes 0 due to overpopulation