Snakes and Ladders - Game Overview & Development Blog
A comprehensive breakdown of how our Snakes and Ladders educational game works, its technical architecture, and how the team split the work.
- How the Game Works
- Game Flow
- Six Sections of the Board
- Section 1 — Lessons (Squares 1–6)
- Section 2 — Question Gauntlet (Squares 7–56)
- Section 3 — Mode Selection Hub
- Section 4 — Boss Battle (Co-op Multiplayer)
- Section 5 — PvP Arena (1v1 Competitive)
- Section 6 — Victory Page & Hall of Champions
- Characters & Powerups
- Technical Architecture & Transactional Data
- Team Work Split
- Akhil
- Moiz
- Samarth
- Arnav
- Ethan
- Aneesh
- Input (Big Idea 3)
- Persistent Data Storage (Big Idea 3)
- Sequencing (Big Idea 3)
- Selection (Big Idea 3)
- Iteration (Big Idea 3)
- Lists / Collections (Big Idea 3)
- Procedures / Functions (Big Idea 3)
- Algorithms (Big Idea 3)
- The Internet (Big Idea 4)
- Impact of Computing (Big Idea 5)
- Akhil — AP CSP Alignment
- Moiz — AP CSP Alignment
- Samarth — AP CSP Alignment
- Arnav — AP CSP Alignment
- Ethan — AP CSP Alignment
- Aneesh — AP CSP Alignment
How the Game Works
Our Snakes and Ladders game is a gamified educational platform that teaches AP Computer Science Principles through an interactive board game. Players learn CS concepts by progressing through the board — and the knowledge they gain directly translates into firepower for the final battles.
Game Flow
Six Sections of the Board
Section 1 — Lessons (Squares 1–6)
Five interactive lessons covering programming basics, data structures, networking, cybersecurity, and data ethics. Each completed lesson awards bullets that carry over to the boss fight.Section 2 — Question Gauntlet (Squares 7–56)
Players roll a dice to advance across 50 squares, each containing a multiple-choice question from one of five CS topics. Correct answers earn additional bullets. Wrong answers? No penalty, but no ammo either.Section 3 — Mode Selection Hub
After completing enough questions, players reach the Mode Selection page (mode-selection.html) where they choose between cooperative Boss Battle or competitive PvP Arena. Real-time Socket.IO updates show current player counts in each mode.
Section 4 — Boss Battle (Co-op Multiplayer)
Up to 10 players cooperate in real-time via WebSockets to defeat a dragon boss. The boss has complex AI with multiple movement patterns (dash, zigzag, chase, circle). Powerups spawn every 5 seconds, and a group chat allows coordination. Notifications appear on-screen for player joins, powerup pickups, and defeats.Section 5 — PvP Arena (1v1 Competitive)
Two players battle head-to-head in a real-time duel. Players are separated by a center wall barrier, using earned bullets as ammo. Movement via WASD/arrows, mouse aiming, and click/spacebar to shoot. Lives tracked with health bars, chat system for communication, and auto-matchmaking when opponents join.Section 6 — Victory Page & Hall of Champions
Winners are directed tovictory.html with animated confetti, player stats summary (bullets earned, time played, win mode), and the Hall of Champions leaderboard showing all game completers. Players can cement their victory or reset progress to play again.
Characters & Powerups
Players choose from four pixel-art characters, each with a unique visual identity:
| Character | Icon | Color |
|---|---|---|
| Knight | Shield | Blue |
| Wizard | Magic | Purple |
| Archer | Bow | Green |
| Warrior | Sword | Orange |
During the boss battle, four powerup types spawn on the arena:
- Damage Boost — 2x damage for 8 seconds
- Speed Boost — 1.5x movement speed for 10 seconds
- Rapid Fire — +15 bullets instantly
- Health Restore — Recover 1 life (or +10 bullets if full)
Technical Architecture & Transactional Data
The system uses a Jekyll static frontend communicating with a Flask (Python) backend via REST APIs and WebSocket connections.
File Structure
| Layer | File | Purpose |
|---|---|---|
| Frontend | game-board-part1.html | Lessons, character selection, login |
game-board-part2.html | Question board with dice rolling | |
mode-selection.html | Battle mode hub (Boss vs PvP) | |
boss-battle.html | Co-op boss arena with canvas rendering | |
pvp-arena.html | 1v1 competitive arena with center wall | |
victory.html | Victory celebration, Hall of Champions | |
| Shared JS | snakes-game.js | Core game logic, API calls, autosave |
questions_bank.js | 50 questions across 5 CS topics | |
| Backend API | api/snakes_game.py | CRUD, leaderboard, champions, reset |
api/snakes_extended.py | Lessons, questions, unlock endpoints | |
api/boss_battle.py | Battle room creation/joining | |
| WebSocket | socketio_handlers/boss_battle.py | Boss + PvP sync, chat, powerups |
| Models | model/snakes_game.py | SnakesGameData (progress, bullets, lives) |
model/boss_room.py | BossRoom, BossPlayer, BossBattleStats |
How Transactional Data Flows
Every user action triggers a backend transaction. Here are the key data flows:
Lesson Completion:
Answering Questions:
Autosave (Every 10 seconds):
Boss Battle (Real-time):
Key API Transactions
| Action | Method & Endpoint | Payload | Server Response |
|---|---|---|---|
| Load progress | GET /api/snakes/ |
— | Full game state |
| Complete lesson | POST /api/snakes/complete-lesson |
{lesson_number, bullets_earned} |
Updated totals |
| Answer question | POST /api/snakes/answer-question |
{square, bullets_earned, correct} |
Updated position |
| Join boss battle | POST /api/boss/join |
{bullets, lives, character} |
{room_id, players} |
| Get leaderboard | GET /api/snakes/leaderboard |
— | Top 10 by bullets |
Authentication Flow
All API calls are secured with JWT tokens stored in HttpOnly cookies. The @token_required() decorator extracts the user ID from the token payload and associates all game data with the correct SnakesGameData database record. Guest/demo mode uses sessionStorage as a fallback with no server persistence.
Team Work Split
Akhil
- Project coordination, sprint planning, and stand-ups
- WebSocket handler (
socketio_handlers/boss_battle.py) - Real-time player sync for both Boss Battle and PvP
- Group chat system (lobby + in-battle messaging)
victory.htmlwith confetti animation and Hall of Champions- Leaderboard API, Champions API, game completion endpoints
- Autosave mechanism (10s interval) and demo/guest mode
Code Snippet
```python # WebSocket player sync (socketio_handlers/boss_battle.py) @socketio.on('boss_player_move') def handle_player_move(data): room_id = data.get('room_id') boss_battles[room_id]['players'][request.sid]['x'] = data['x'] boss_battles[room_id]['players'][request.sid]['y'] = data['y'] emit('boss_player_position', {'sid': request.sid, 'x': data['x'], 'y': data['y']}, room=room_id, include_self=False) ```Moiz
- Backend deployment: Dockerfile, docker-compose, Nginx
- Production environment variables and CORS config
- JWT authentication system (
api/jwt_authorize.py) - Cookie management and
@token_required()decorator - Demo/Guest mode with sessionStorage fallback
- Flask application factory and server configuration
Code Snippet
```python # JWT token validation (api/jwt_authorize.py) def token_required(): def decorator(f): @wraps(f) def decorated(*args, **kwargs): token = request.cookies.get('jwt') if not token: return {"message": "Token missing"}, 401 data = jwt.decode(token, SECRET_KEY, algorithms=["HS256"]) g.current_user = User.query.get(data['user_id']) return f(*args, **kwargs) return decorated return decorator ```Samarth
- Five interactive lesson pages (
lessons/lesson1-5.html) - Arcade-style lesson CSS and UI animations
POST /api/snakes/complete-lessonendpoint- Section unlocking logic (half1 → half2 → boss)
- Lesson completion tracking and bullet rewards
- Progress persistence across sessions
Code Snippet
```javascript // Lesson completion (lessons/lesson1.html) async function completeLesson(lessonNum) { const res = await fetch(API + '/snakes/complete-lesson', { method: 'POST', credentials: 'include', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({lesson_number: lessonNum, bullets_earned: 10}) }); if (res.ok) unlockNextSection(); } ```Arnav
- Full
boss-battle.htmlwith canvas-based rendering - Pixel-art character sprites and boss AI movement patterns
- Bullet physics and collision detection (
Math.hypot) pvp-arena.htmlwith center wall and 1v1 mechanics- Powerup spawning/collection system (damage, speed, heal)
- Database models: BossRoom, BossPlayer, BossBattleStats
Code Snippet
```javascript // Boss AI movement patterns (boss-battle.html) function updateBossPosition() { if (pattern === 'chase') { const dx = targetPlayer.x - boss.x; const dy = targetPlayer.y - boss.y; boss.x += dx * 0.02; boss.y += dy * 0.02; } else if (pattern === 'zigzag') { boss.x += Math.sin(Date.now() / 200) * 5; boss.y += bossSpeed; } } ```Ethan
- 50-question bank across 5 CS topics (
questions_bank.js) - Question modal template and answer validation
POST /api/snakes/answer-questionendpoint- Bullet-awarding logic for correct answers
- Square visit tracking to prevent re-answering
- Visual feedback for correct/incorrect answers
Code Snippet
```javascript // Question bank structure (questions_bank.js) const QUESTIONS = [ {square: 7, topic: "Programming Basics", question: "What keyword declares a variable in Python?", options: ["var", "let", "def", "None of these"], correct: 3, bullets: 5}, // ... 49 more questions ]; ```Aneesh
- Main game board UI and dice-rolling mechanics
- Character selection carousel with pixel-art sprites
- Mode Selection hub page (
mode-selection.html) - Frontend navigation flow between all game pages
game-board-part1.html,game-board-part2.html- Board square rendering and progression visualization
Code Snippet
```javascript // Dice roll animation (game-board-part2.html) function rollDice() { const roll = Math.floor(Math.random() * 6) + 1; diceElement.classList.add('rolling'); setTimeout(() => { diceElement.textContent = roll; movePlayer(currentSquare + roll); }, 800); } ```Meeting AP CSP College Board Requirements
Our game directly addresses multiple College Board AP CSP requirements through its design and implementation:
Input (Big Idea 3)
Users provide input through HTML form elements (character selection clicks, question answer buttons, chat text input) and JavaScript event listeners (keyboard WASD/arrows for movement, mouse position for aiming, spacebar/click for shooting).
Persistent Data Storage (Big Idea 3)
Game state is stored in a relational database (SQLite/MySQL) via Flask-SQLAlchemy. Player progress (current_square, total_bullets, completed_lessons, visited_squares) persists across sessions through authenticated API calls.
Sequencing (Big Idea 3)
The game enforces ordered execution: lessons must complete before questions unlock, questions must be answered before the boss section unlocks. API calls execute sequentially (fetch progress → validate → update → respond).
Selection (Big Idea 3)
Conditionals drive game logic throughout: if (correct) awards bullets, if (lives <= 0) triggers death, if (square >= 56) unlocks boss, if (bossHealth <= 0) ends the battle. The backend validates conditions before granting access.
Iteration (Big Idea 3)
Loops run the game: requestAnimationFrame drives the render loop, setInterval handles autosave (10s), position broadcasting (50ms), and powerup spawning (5s). The question system iterates through visited_squares to track progress.
Lists / Collections (Big Idea 3)
Arrays and JSON objects store structured data: visited_squares[], completed_lessons[], unlocked_sections[], powerups[], otherPlayers{}. The backend manages lists of players per room and leaderboard rankings.
Procedures / Functions (Big Idea 3)
Modular functions with parameters and return values: applyPowerup(type), shoot(), loadPlayerData(), sendChatMessage(), spawn_powerup_for_room(room_id). Backend uses decorated route handlers with request parsing.
Algorithms (Big Idea 3)
The boss AI implements pathfinding algorithms with pattern switching (normal, dash, zigzag, chase, circle). Collision detection uses the distance formula (Math.hypot). The leaderboard uses sorting algorithms to rank players by score.
The Internet (Big Idea 4)
The game operates over HTTP/HTTPS with RESTful APIs (GET, POST, PUT) and WebSocket connections for real-time multiplayer. JWT tokens authenticate requests, CORS headers control access, and Nginx handles reverse proxying.
Impact of Computing (Big Idea 5)
The game itself teaches CS ethics and data privacy concepts through its lesson content. Guest mode demonstrates data minimization principles — no personal data is collected for unauthenticated users.
Individual AP CSP Requirements by Team Member
Each team member’s contribution demonstrates specific College Board requirements:
Akhil — AP CSP Alignment
- The Internet: WebSocket events (
emit/on) for real-time sync across clients - Iteration:
setIntervalbroadcasts position every 50ms; autosave every 10s - List:
boss_battles[room_id]['players']dict;champions[]for leaderboard - Procedure:
handle_player_move(data)with room_id parameter and broadcast - Data Storage:
ChampionsAPIqueries completed games;ResetProgressAPIclears state
Moiz — AP CSP Alignment
- The Internet: JWT tokens over HTTPS, CORS configuration, cookie security flags
- Selection:
if not tokenreturns 401,if token_expiredreturns 403 - Procedure:
@token_required()decorator with nested function and return - Data Storage: User credentials hashed with bcrypt, stored in SQLAlchemy
- Impact: Guest mode protects privacy; no data stored without authentication
Samarth — AP CSP Alignment
- Sequencing: Lessons 1-5 must complete in order; each unlocks the next section
- Selection:
if (lessonCompleted)awards bullets and updatesunlocked_sections - List:
completed_lessons[]array tracks which lessons are done - Procedure:
completeLesson(num)with parameter and async API call - Data Storage: Lesson progress persists via PUT to
/api/snakes/
Arnav — AP CSP Alignment
- Algorithm: Boss AI uses distance formula
Math.hypot(dx,dy)for chase pattern - Iteration:
requestAnimationFramegame loop at 60fps; bullet array updates - Selection:
if (pattern === 'zigzag')changes movement;if (collision)damages - List:
playerBullets[],opponentBullets[],powerups[]arrays - Procedure:
checkCollisions()iterates bullets, uses selection for hit detection
Ethan — AP CSP Alignment
- List:
QUESTIONS[]array of 50 objects with topic, options, correct index - Iteration:
forEachto render answer options; filter to find unvisited squares - Selection:
if (selectedAnswer === correct)awards bullets - Procedure:
checkAnswer(square, answer)validates and updates state - Algorithm: Binary search through
visited_squaresto check completion
Aneesh — AP CSP Alignment
- Input: Click handlers for dice rolls, character selection buttons, navigation links
- Selection:
if (roll + currentSquare > 56)redirects to mode selection - Iteration:
forloop renders 56 board squares with dynamic CSS classes - Procedure:
rollDice()function with animation timing and state updates - List: Character array
['knight','wizard','archer','warrior']for carousel
Create Performance Task Alignment
The project structure maps directly to the CPT requirements:
- Program Purpose: Educate users on AP CSP concepts through gamified learning
- Program Function: Interactive game board with progression, questions, multiplayer boss battle, and PvP arena
- Input → Output: User answers (input) → bullet rewards and progression (output); keyboard/mouse (input) → character movement and shooting (output)
- List Usage:
visited_squaresarray stores/retrieves which questions have been answered, iterated to show progress - Procedure with Parameter:
applyPowerup(type)takes a powerup type, applies the corresponding buff using selection logic, and modifies game state - Algorithm with Sequencing + Selection + Iteration: Boss AI movement function sequences through pattern selection (
if patternTimer > threshold), iterates to calculate new positions, and selects behavior based on player proximity