Sample TP1 Proposal

This is a sample TP1 submission for a hypothetical student project, following the sample TP0 proposal. It shows the level of detail expected; your proposal will describe your own project. The course staff expects this project would receive a term project grade of about 80%, assuming all proposals are submitted on time and all interviews receive a score of 1.

Section 1: Summary of progress

Section 2: By next week: MVP

Part A: What these features do

1. Overview

By TP2: a complete game. Animated swaps, clears, and falls; 20 moves and a 1,500-point target; a cascade bonus; Title and Results screens; automatic reshuffling.

2. Screens and modes

Title (new): title, a row of six sample gems, and a Play button.

Main Board (changed): the top bar shows score (left), “Target: 1500” (middle), and moves remaining (right).

Results (new): “You win!” (score ≥ 1,500) or “Out of moves”; final score; longest cascade; Play Again and Title buttons.

3. Rules and behavior

Animation Shown Length
Swap Two gems slide past each other 0.2 s
Swap back They slide back (invalid swap) 0.2 s
Clear Matched gems shrink away 0.25 s
Fall Gems slide down; new gems slide in from above 0.3 s
Reshuffle “No moves! Shuffling…”, then the new board 0.5 s

4. Edge cases

Situation Result
Click, R, or Escape during an animation Ignored.
Long cascade on the last move Finishes and scores before Results.
Last move leaves no valid move Straight to Results; no reshuffle.
Reshuffle keeps making matches After 100 tries, generate a new board.
Target reached with moves remaining Game continues; target text turns green.

5. Design decisions

6. Out of scope this week

Part B: Core algorithms

Board format is unchanged from TP0.

Algorithm 1: Finding a valid move

1. The problem. Find a swap that would create a match, if one exists. Used to trigger reshuffles (and hints later).

2. Data. In: a board with no matches. Out: ((r1, c1), (r2, c2)), or None.

3. Steps.

  1. For each cell, top left to bottom right, and each neighbor to its right and below (if on the board):
    1. Swap them.
    2. If either swapped cell is now in a match (helper below), swap back and return the pair.
    3. Swap back.
  2. Return None.

Helper: count same-colored gems directly left and right of the cell, plus 1. If ≥ 3, it’s a match. Repeat for up and down.

Only right/below neighbors, so no pair is checked twice. Only the two swapped cells, since any new match must include one of them.

4. Worked example.

Row 0:  G  B  Y
Row 1:  R  G  G
Row 2:  B  Y  R

5. Edge cases.

6. Open questions. None for MVP. For hints: first valid move or a random one?

Algorithm 2: Reshuffling

1. The problem. Rearrange a board with no valid move into one with no matches and at least one valid move.

2. Data. In: the board. Out: the same 64 gems, rearranged.

3. Steps.

  1. Put all 64 colors in a list.
  2. random.shuffle it and refill the board row by row.
  3. If the board has a match or no valid move (Algorithm 1), repeat step 2.
  4. After 100 tries, generate a new board instead.

New boards from TP0’s generator are also checked with Algorithm 1 and regenerated if needed.

4. Worked example.

Row 0:  R  O  Y
Row 1:  G  B  P
Row 2:  Y  R  O

5. Edge cases.

6. Open questions. How many tries does an 8×8 reshuffle usually take? I’ll measure over 1,000 reshuffles.

Algorithm 3: Playing animations in order

1. The problem. One swap can set off a chain: swap, clear, fall, clear again, fall again. Each animation must finish before the next one starts, and the player can’t act until everything stops.

2. Data.

3. Steps. Each phase lasts a fixed number of steps, from the animation table in Part A: swap 6, clear 8, fall 9, shuffle 15. In onStep, add 1 to app.phaseTimer. When the phase’s time is up, reset the timer and choose the next phase:

  1. Swapping ends. If the swap made a match, use a move and go to clearing. If not, go to swapping back, which then ends in idle.
  2. Clearing ends. Score the matches (doubled if this isn’t the move’s first clear). Remove them, drop the gems, refill the board, and save fallDistances. Go to falling.
  3. Falling ends. If the board has new matches, go back to clearing. Otherwise the move is over:
    • 0 moves remaining → Results.
    • No valid move → shuffling, which then ends in idle.
    • Otherwise → idle.

The board changes all at once when clearing ends; falling only animates it. A gem that fell d cells starts d cells above its new cell and slides down: it is drawn d × 70 × (1 − phaseTimer / 9) px above it.

4. Worked example. The player has 20 moves and 0 points. They swap two gems, which makes a run of 3. When those gems clear and the gems above fall, the fallen gems make a second run of 3.

Steps What the player sees When the animation finishes, the game…
1–6 The two gems slide past each other. Finds a run of 3, so the swap counts. Moves remaining: 20 → 19. Starts clearing.
7–14 The 3 matched gems shrink away. Adds 30 points (score: 30). Removes the gems, drops the gems above, and adds new ones at the top. Starts falling.
15–23 Gems slide down into the gaps. Finds a new run of 3 made by the fallen gems. Starts clearing again.
24–31 The new run shrinks away. Adds 60 points: 30, doubled because it’s not the move’s first clear (score: 90). Drops and refills. Starts falling.
32–40 Gems slide down into the gaps. Finds no new runs, and at least one valid move remains. Goes idle.

Total: 40 steps (about 1.3 s). Clicks and keys are ignored until the game goes idle.

5. Edge cases.

6. Open questions. Should longer falls take longer than 0.3 s?

Part C: Hand-drawn sketches

We’ll be adding these shortly, sorry for the delay. We’re drawing as fast as we can.

Main Board Expansion

Picture of the main board

Screen Flow

Picture of the flow between screens

Algorithm 3

Picture of Algorithm 3