The Ski Resort Simulator is a console-based application that models the visitor flow in an arbitrary skiing resort. The system is implemented in C, focusing on dynamic data handling, pointer-based architecture, and explicit memory management.
The simulation follows a full day at the resort with interacting systems such as the lift, slopes, stations, queues, transportation, and visitor behaviour — all driven by time and probabilistic decision-making.
- Full-day simulation of a ski resort (08:40 → 22:20)
- Real-time evolving system with:
- lift operations (110 gondolas, continuous movement)
- skier routing and behaviour
- queues and boarding logic
- Multiple arrival and departure systems:
- bus (scheduled)
- car park (capacity-based)
- hotel guests
- Ticket system:
- 10-ride tickets
- day tickets
- Bistro with limited stay and realistic behaviour
- Pseudo-graphical console output showing:
- queue lengths
- slope usage
- lift occupancy
- visitor count
- ticket sales
- parking and bus status
- Interactive controls:
- pause / resume
- turbo mode (×10 speed)
- abort simulation
The simulation provides a pseudo-graphical dashboard that updates in real time.
It visualises:
- lift movement and occupancy
- slope usage
- lift queue sizes
- visitor statistics
- system state
The actual output is continuously updated and rendered in-place to simulate a live dashboard.
Requirements:
- C compiler (e.g.
gcc,clang) - CMake ≥ 3.10
Build:
cmake -S . -B build
cmake --build buildRun:
./build/app/mainThe system is structured into modular components with clear responsibilities.
Core Principles:
- Struct-based design (no OOP abstractions available in C)
- Explicit memory ownership
- Pointer-driven data flow
- Time-step simulation loop
Each simulation tick:
- arrivals are processed
- lift movement and exits occur
- skiers progress on slopes
- bistro activity updates
- queues and boarding are handled
- departures are processed
Pointer-Based Architecture:
- Entities are interconnected via pointers
- No global state — everything is explicitly passed
Manual Memory Management:
- Controlled allocation (calloc)
- Deterministic cleanup (destroy_*)
- Clear ownership boundaries
Custom Data Structures:
- Doubly linked lists
- Queues
- Circular linked gondola system
Probabilistic Simulation:
- Uniform, normal, and log-normal distributions
- Used for:
- arrivals and departures
- activity durations (skiing, eating at bistro, resting at hotel)
- routing decisions
- ticket selection
.
├── app/ → Entry point (main.c)
├── include/skiresort → Public headers
├── src/ → Implementation
├── tests/ → Unit tests
├── docs/ → Reference material
├── CMakeLists.txt
└── README.md
Core Simulation:
- central control loop and time progression
simulation,resort,clock
Infrastructure & Flow Logic:
- routing logic and state transitions of people
station,lift_queue
Entities:
- moving actors and transport containers
person,gondola
Environment:
- physical resort components and activity spaces
lift,slope,bistro,hotel
Transport Systems:
- arrival and departure mechanisms
bus,bus_stop,car,car_park
Data Structures:
- custom dynamic data structures
list,queue,node
Utilities:
- randomness and user interaction
probability,input
The project includes a comprehensive suite of unit tests, using static assertions to verify correctness and invariants. They cover:
- data structures (List, Queue, Node)
- memory handling
- scheduling logic
- probabilistic behaviour
- system interactions
Build tests:
cmake -S . -B build
cmake --build buildRun all tests:
ctest --test-dir buildRun specific test (example):
ctest -R list_tests --test-dir build- System modelling in pure C
- Robust dynamic memory handling
- Pointer-based architecture
- Simulation of complex interacting systems
- Modular design without object-oriented abstractions
- Realistic behaviour through probabilistic modelling
- Clear separation of responsibilities across modules
Feel free to:
- Explore the simulation logic
- Extend system behaviour
- Add new features (e.g. weather, pricing, AI)
- Use the project as a reference for systems programming in C
This project demonstrates how complex, dynamic systems can be built in pure C using clean structure, careful memory management, and well-defined data flow.
Happy coding! 🚀
