CSCI 310 – Introduction to Operations, Fall 2025
Final Project – Option 1 (Multithreaded Race Game)
Group 8
This project is a multithreaded race game written in C using POSIX threads (pthreads).
Four Looney Tunes characters race on a grid-based board to be the first to carry a golden carrot/flag (C) to the Mountain (F) on Planet X.
Runners (each in their own thread):
- Bugs Bunny (
B) - Taz Devil (
D) - Tweety (
T) - Marvin the Martian (
M)
All runners share the same board and game state, which is protected with a pthread_mutex so the threads don’t corrupt each other’s data.
- Each character moves randomly around the board in its own thread.
- There are two golden carrots/flags (
C) on the board. - A runner must:
- Step on a
Cto pick it up. - Then reach the Mountain (
F) while carrying the carrot/flag.
- Step on a
- When a runner is carrying a carrot/flag, they are shown as e.g.
B(C). - The race ends immediately when any runner reaches
Fwhile carrying a carrot/flag.
- Only empty squares or special squares (
C,F) can be stepped on. - No two non-Marvin runners are allowed to stand on the same spot.
- No one is allowed to step on
Funless they are already carrying a carrot/flag.
- Marvin can activate the space-time machine after a certain number of full cycles.
- When the machine activates, the Mountain (
F) moves to a new random empty position on the board. - This makes the race more chaotic and changes the target location.
- Marvin is the only character allowed to step onto a square occupied by another runner.
- If Marvin lands on another runner:
- That runner is eliminated from the race.
- If the runner was carrying a carrot/flag, Marvin steals it.
- Other runners are not allowed to step on each other.
You will need:
- A C compiler (e.g.
gcc) - POSIX threads support (
-pthread)
Compile with:
gcc -pthread race_game.c -o race_game