State Representation
[M_left, C_left, Boat]
M_left is missionaries on the left bank, C_left is cannibals on the left bank, and Boat is 1 for left or 0 for right.
Python • Pygame • FSA • PyInstaller
A Python/Pygame implementation of the classic Missionaries and Cannibals problem, demonstrating finite state automata, state transitions, and rule-based validation.
Project Overview
This project started as a Python/Pygame game created to visualize state-based logic in the Missionaries and Cannibals puzzle. The original implementation is preserved as a runnable desktop game, then packaged into a Windows application using PyInstaller so recruiters can try the game without manually installing Python.
Problem Statement
Three missionaries and three cannibals must cross a river using one boat. The boat can carry a maximum of two people and must carry at least one passenger to move.
The key rule is that missionaries cannot be outnumbered by cannibals on either river bank when missionaries are present on that bank.
Solution Approach
[M_left, C_left, Boat]
M_left is missionaries on the left bank, C_left is cannibals on the left bank, and Boat is 1 for left or 0 for right.
Initial state: [3, 3, 1]
Goal state: [0, 0, 0]
[1,0], [0,1], [1,1], [2,0], [0,2]
Each action represents passengers carried by the boat.
Every move triggers a state transition. The game checks whether the new state is valid, detects unsafe bank conditions, displays a game-over condition when rules are violated, and detects the winner condition when the final state is reached.
Original Python/Pygame Implementation
The original app keeps the Pygame game loop, character selection, boat movement, state display, images, music, and sound effects.
main.py — Pygame loop and puzzle logicPerson.py — character objectsBoat.py — boat behaviorimages/ — visual assetsmusic/ — background music and sound effectsWindows Executable
The project can be distributed as a Windows executable, allowing recruiters to run the game without manual Python setup. The executable is built with PyInstaller folder mode for better Pygame stability and easier asset debugging.
Download Windows App →Local Setup
cd "YOUR DIRECTORY"
python -m venv venv
.\venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt
python main.py
Read Setup Guide
Screenshots
Video Demo
Technical Highlights
Recruiter View
Built a playable desktop app with real user input and visual feedback.
Modeled puzzle conditions using explicit state representation and transition rules.
Packaged the Python/Pygame project into a Windows app using PyInstaller.
Presented an older academic project in a recruiter-friendly portfolio format.
Project ini adalah game Python/Pygame original untuk puzzle Missionaries and Cannibals yang menggunakan representasi state, transition, validasi rule, game over, dan winner state. Project juga dikemas menjadi Windows executable menggunakan PyInstaller agar mudah dicoba oleh recruiter tanpa setup Python manual.