Sample TP2 Proposal

This is a sample TP2 submission for a hypothetical student project, following the sample TP0 and TP1 proposals. 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: Advanced features

Part A: What these features do

1. Overview

By TP3: special gems that chain, hints, a How to Play screen, and a saved high score. Special gems reward planning; hints help stuck players; the high score encourages replay.

2. Screens and modes

Title (changed): adds a How to Play button below Play, and “High score: 2340” (or “none yet”) at the bottom.

How to Play (new): five short rule lines (swapping, scoring, move limit, special gems, H key), drawings of each special gem, and a Back button.

Main Board (changed):

Results (changed): high score under the final score; “New high score!” in gold when beaten.

3. Rules and behavior

Special gems

Scoring changes

Hints

High score

4. Edge cases

Situation Result
A swap makes a run of 4 and an L Each makes its own special gem.
Two special gems clear each other Each activates once.
A line gem’s row holds a bomb The bomb activates too.
Bomb on an edge or corner Clears only cells on the board (6 or 4).
Reshuffle with special gems They shuffle with the rest and keep their type.
highscore.txt missing, empty, or not a number High score = none; a valid file is written after the next game.
H during an animation Ignored.

5. Design decisions

6. Out of scope this week

Part B: Core algorithms

Special gems live in specials, a 2D list the same size as the board: None, 'rowLine', 'colLine', or 'bomb'. It must move with the board whenever gems fall, refill, or shuffle.

Algorithm 1: Creating special gems

1. The problem. After the player’s swap, decide which matches make special gems, and where.

2. Data. In: the board, the two swapped cells, and the runs found. Each run now records its direction ('h' or 'v') and its cells. Out: updated specials, toClear, points.

3. Steps. (First cascade step only.)

  1. Mark all runs unused.
  2. For each horizontal and vertical run of one color sharing a cell X: bomb at X; mark both used; +100.
  3. For each unused run of 4+: line gem at the swapped cell in the run ('rowLine' if horizontal, 'colLine' if vertical); mark used; score normally.
  4. Score remaining runs normally.
  5. toClear = all run cells, minus the new special gem cells.

4. Worked examples.

Run of 4: R swapped from (2,2) to (3,2); row 3 has R at columns 1–4.

L-shape: G runs (5,2), (5,3), (5,4) and (3,4), (4,4), (5,4).

5. Edge cases.

6. Open questions. If the swapped cell already holds a special gem in the new match, does the old one activate or get replaced?

Algorithm 2: Activating special gems in chains

1. The problem. Expand toClear with each cleared special gem’s area, activating any special gems caught in it, until none are left.

2. Data. In: toClear, specials. Out: expanded toClear, count of extra gems. queue: list of special gems waiting. activated: set of those done.

3. Steps.

  1. queue = special gems in toClear. activated = empty. extra = 0.
  2. While queue isn’t empty:
    1. Take the first cell. Skip it if in activated; otherwise add it.
    2. Area: its row ('rowLine'), column ('colLine'), or on-board 3×3 ('bomb').
    3. For each area cell not in toClear: add it, extra += 1, and queue it if it holds an unactivated special gem.
  3. Score 10 per extra gem (×2 in cascade steps 2+).

4. Worked example. A vertical match clears (1,5), (2,5), (3,5). (2,5) is a 'rowLine'; (2,1) is a 'bomb'.

5. Edge cases.

6. Open questions. Animate a chain all at once, or one gem at a time (needs a new phase)?

Algorithm 3: Choosing a hint

1. The problem. Pick a random valid swap to highlight.

2. Data. In: the board. Out: app.hintPair; app.hintTimer counts down 60 steps (2 s).

3. Steps.

  1. Change TP1’s valid-move search to return a list of all valid swaps.
  2. If empty, do nothing (shouldn’t happen, thanks to reshuffling).
  3. app.hintPair = random.choice(list), app.hintTimer = 60, app.hintsLeft -= 1.
  4. Each step, decrease the timer; at 0, clear app.hintPair.
  5. Draw a yellow outline on both cells, alternating 6 px and 3 px every 10 steps.

4. Worked example (TP1’s 3×3 board).

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

5. Edge cases.

6. Open questions. Should hints prefer swaps that make special gems?

Part C: Hand-drawn sketches

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