A taxi simulation game that mimics the backend logic of ride-hailing apps, written in C++.
- Interactive taxi simulation with real-time updates through the terminal.
- Uses object-oriented design to manage taxis, passengers, and the dispatcher system.
- Implements Manhattan distance for efficient taxi assignment and shortest path calculation.
- Dynamic map visualization showing step-by-step taxi movements and state updates.
-
Passenger.h/Passenger.cpp: Defines the
Passenger
class, which stores and manages passenger information such as pickup and dropoff locations. -
Taxi.h/Taxi.cpp: Defines the
Taxi
class, representing individual taxis, their availability, and current positions. -
Dispatcher.h/Dispatcher.cpp: Implements the
Dispatcher
class, which manages the game logic, including:- Map updates.
- Taxi assignment based on shortest distance.
- Handling passenger requests and simulating taxi movements.
-
main.cpp: The entry point of the application. Initializes the game and provides a menu-driven interface for interacting with the simulation.
-
TerminalRedirect.h/TerminalRedirect.cpp: Opens GUI in separate terminal window to reduce clutter.
-
Makefile: Automates compilation and linking of the program. Contains rules for building the project, cleaning object files, and creating the executable.
.
├── Passenger.h
├── Passenger.cpp
├── Taxi.h
├── Taxi.cpp
├── Dispatcher.h
├── Dispatcher.cpp
├── main.cpp
├── Makefile
-
Ensure you have
g++
installed (C++17 support is required). -
Navigate to the project directory in the terminal.
-
Compile the code using the command:
make
-
On macOS/Linux, this will generate an executable named
taxi_simulation
. On Windows, it will generatetaxi_simulation.exe
.
- Run the program by executing:
-
On macOS/Linux:
./taxi_simulation
-
On Windows:
taxi_simulation.exe
-
- Follow the menu options to:
- Request a taxi.
- View the current map.
- Exit the simulation.
- More complex features are in development, such as
- Interactive Open World UX
- Multiple passenger requests
- Advanced algorithms for taxi assingments (Dijkstra’s, machine learning demand prediction, Hungarian Algorithm for optimal assignments)
- The terminal dynamically updates the map during taxi movement.
- The game uses
std::this_thread::sleep_for
to visually display step-by-step taxi movements. - Feel free to fork and extend this project with additional features!