Wednesday, 14 October 2026

Python Programming Through Gamification - Game Factory Challenge - Decorators, generators and exception handling : Day 3



Demo Game 1 — Vault Breaker

Template 1: Game Idea Canvas

Field

Filled-in response

Team name

Trainer Demo Team

Game name

Vault Breaker

Problem or mission

Crack a secret three-digit code to unlock a vault.

Player

A detective trying to open the vault.

Rules

The code must be between 100 and 999. The player has three valid guesses.

Winning condition

Enter the secret code correctly.

Losing condition

Use all three valid guesses without finding the code.

If the player makes a mistake

Invalid text or out-of-range numbers are rejected with a helpful message.

IAS officer shares baffling puzzle, challenges people to crack a 3-digit code | Trending

hindustantimes.com

Template 2: Input → Process → Output

Question

Filled-in response

Player input

A three-digit number

Main rule

Compare the guess against the secret code

Decision (if/else)

Is the guess correct? Is it higher or lower?

Output/message

Correct, try higher, try lower, or invalid input

Winning condition

Guess equals the secret code

Losing/exit condition

Three valid guesses are used

Template 3: Class & Object Blueprint

  • Parent class: Game
  • Child class: VaultBreaker
  • Common attributes: name, difficulty
  • Game-specific attributes: secret_code, attempts
  • Common method: run()
  • Specialized method: play()
  • Example object: vault_game = VaultBreaker()

The VaultBreaker class inherits the common game features and provides its own play() method.

Template 4: Flowchart

START

Display vault instructions and initialize attempts = 3

Enter code

Is input a valid three-digit number?

NO

Show error and retry

YES

Compare with secret code

If correct: unlock the vault. If incorrect: decrement attempts and repeat until attempts run out.

Display WIN or LOSE result

END

Template 5: Four-Feature Design Lab

Feature

Filled-in response

Decorator

Display game start and end messages; log the session.

Generator

Optional extension: generate a sequence of vault clues one at a time.

Exception

Catch ValueError if the player types letters instead of a number.

Defensive check

Reject empty input and numbers outside 100–999.

Template 6: Bug Hunter Test Sheet

Test

Input/action

Expected behaviour

Normal input

Enter 427 when that is the secret

Vault opens

Wrong answer

Enter 200

Hint to try higher

Invalid input

Enter hello

Friendly error; no crash

Boundary case

Enter 99

Reject as not three digits

Repeated action

Enter three wrong valid guesses

Game ends with a loss

Most dangerous bug: Accepting invalid guesses as valid attempts or allowing attempts to become negative.

Proposed fix: Validate the input before decrementing the attempt count.

Demo Game 2 — Mission to Mars

Template 1: Game Idea Canvas

Field

Filled-in response

Team name

Trainer Demo Team

Game name

Mission to Mars

Problem or mission

Complete three tasks to prepare a spacecraft for a Mars landing.

Player

A mission commander responsible for the spacecraft.

Rules

Complete oxygen checks, activate navigation, and prepare for landing in sequence.

Winning condition

Complete all three missions.

Losing condition

Fail to complete a mission or exit before finishing.

If the player makes a mistake

Show a message and let the player retry or record the task as incomplete, depending on the game rules.

Mars in a Minute: How Do You Get to Mars? - NASA Science

science.nasa.gov

Template 2: Input → Process → Output

Question

Filled-in response

Player input

Confirmation such as DONE

Main rule

Missions must be processed in sequence

Decision (if/else)

Did the player enter DONE?

Output/message

Mission completed or mission incomplete

Winning condition

All three missions are completed

Losing/exit condition

Player exits or finishes without completing all missions

Template 3: Class & Object Blueprint

  • Parent class: Game
  • Child class: MissionToMars
  • Common attributes: name, difficulty
  • Game-specific attributes: mission sequence, completed mission count
  • Common method: run()
  • Specialized method: play()
  • Example object: mars_game = MissionToMars()

The mission sequence is:

  1. Check oxygen supplies.
  2. Activate navigation.
  3. Land the spacecraft.

The generator produces these missions one at a time.

Template 4: Flowchart



START

Initialize mission generator

Display next mission

Get player confirmation

Is the response DONE?

YES

Mark mission complete

NO

Mark incomplete or retry

Are more missions available?

YES → Display the next mission. NO → Display final mission summary.

END

Template 5: Four-Feature Design Lab

Feature

Filled-in response

Decorator

Log when the mission session starts and finishes.

Generator

Yield oxygen, navigation, and landing missions one at a time.

Exception

Handle interrupted input or unexpected input conditions where appropriate.

Defensive check

Validate confirmation text and track which missions have been completed.

Template 6: Bug Hunter Test Sheet

Test

Input/action

Expected behaviour

Normal input

Enter DONE for every task

All missions completed

Wrong answer

Enter NO

Task remains incomplete or player retries

Invalid input

Enter a blank response

Handle according to the chosen rule

Boundary case

Finish the third mission

No fourth mission is requested

Repeated action

Try to complete the same mission again

Avoid incorrectly increasing the mission count

Most dangerous bug: The game announces success even when one or more missions remain incomplete.

Proposed fix: Track completed missions and check the completion count before displaying success.

Demo Game 3 — Robot Rescue

Template 1: Game Idea Canvas

Field

Filled-in response

Team name

Trainer Demo Team

Game name

Robot Rescue

Problem or mission

Guide a robot through a grid to reach a stranded person.

Player

A rescue operator controlling the robot.

Rules

Move up, down, left, or right. Stay inside the grid and avoid the obstacle at (1, 1).

Winning condition

Reach the rescue destination at (2, 2).

Losing condition

Run out of allowed turns before reaching the destination.

If the player makes a mistake

Reject invalid commands or blocked moves and explain why the move was rejected.

PPT - Exploration PowerPoint Presentation, free download - ID:478944

slideserve.com

Template 2: Input → Process → Output

Question

Filled-in response

Player input

U, D, L, or R

Main rule

Calculate the next position and check whether the move is allowed

Decision (if/else)

Is the command valid? Is the destination within the grid? Is it blocked?

Output/message

Move accepted, invalid command, obstacle detected, or rescue successful

Winning condition

Robot reaches (2, 2)

Losing/exit condition

Six turns are used without reaching the destination

Template 3: Class & Object Blueprint

  • Parent class: Game
  • Child class: RobotRescue
  • Common attributes: name, difficulty
  • Game-specific attributes: x, y, goal, obstacle
  • Common method: run()
  • Specialized method: play()
  • Example object: robot_game = RobotRescue()

The robot's position changes with each valid move. The program calculates a proposed position first and updates the actual position only if the move passes the safety checks.

Template 4: Flowchart



START

Initialize robot at (0, 0)

Get movement command

Is the command valid?

NO → Show error and request another command.

Calculate proposed position

Is the move safe and within the grid?

NO → Reject move. YES → Update robot position.

Rescue reached or turns exhausted?

NO → Return to movement command. YES → Show result.

END

Template 5: Four-Feature Design Lab

Feature

Filled-in response

Decorator

Log the start and end of every robot rescue session.

Generator

Optional extension: yield a sequence of rescue instructions one at a time.

Exception

Handle unexpected input interruptions if required; validate movement commands before processing them.

Defensive check

Reject commands outside R, L, U, D; prevent moves outside the grid or into obstacles.

Template 6: Bug Hunter Test Sheet

Test

Input/action

Expected behaviour

Normal input

Move right using D from (0, 0)

Robot reaches (1, 0)

Wrong action

Move into the obstacle at (1, 1)

Move is rejected

Invalid input

Enter X

Error message; position unchanged

Boundary case

Move left from (0, 0)

Robot stays in place

Repeated action

Attempt a blocked move several times

Position remains unchanged

Most dangerous bug: Updating the robot's position before checking the boundaries or obstacles.

Proposed fix: Calculate new_x and new_y, validate the proposed position, and update self.x and self.y only after all checks pass.

Template 7: Three completed Final Game Blueprint summaries

These are the short versions you can use when presenting the completed workbook to students. They follow the final poster's fields on page 5 of your uploaded template.

Game development Template.pdf

A. Vault Breaker

Theme and mission

Crack the vault's secret code within three valid attempts.

Three-game family connection

A code-cracking game that shares common launch and monitoring behaviour with other games.

Class diagram

Game → VaultBreaker

Four Python upgrades

  • Decorator: session monitoring
  • Generator: optional clue sequence
  • Exception: invalid numeric input
  • Defensive check: three-digit range and attempt limits

Test plan

Valid code, wrong code, letters, out-of-range numbers, and exhausted attempts.

Unique feature

Hints that guide the player toward the secret code.

B. Mission to Mars

Theme and mission

Complete three spacecraft preparation tasks in sequence.

Three-game family connection

A mission-based game that shares common launch and monitoring behaviour with other games.

Class diagram

Game → MissionToMars

Four Python upgrades

  • Decorator: session monitoring
  • Generator: mission sequence
  • Exception: appropriate input/interruption handling
  • Defensive check: mission completion tracking

Test plan

Complete tasks, skip tasks, submit blank responses, and check the final summary.

Unique feature

Missions are generated one at a time.

C. Robot Rescue

Theme and mission

Navigate a robot safely to the rescue destination.

Three-game family connection

A navigation game that shares common launch and monitoring behaviour with other games.

Class diagram

Game → RobotRescue

Four Python upgrades

  • Decorator: session monitoring
  • Generator: optional instruction sequence
  • Exception: handle appropriate unexpected input conditions
  • Defensive check: command, grid, and obstacle validation

Test plan

Valid moves, invalid commands, boundaries, obstacles, and exhausted turns.

Unique feature

A safe-movement system that rejects dangerous moves.

How to use these : Hand students the blank workbook, then display one completed example at a time. Ask them to explain why each answer belongs in that section. After the discussion, ask each team to fill in the same fields for its own three games before coding.




Three connected games to each team of four students. Each team will design a mini-game collection that progressively demonstrates Python OOP concepts and the four advanced programming practices: decorators, generators, exceptions, and defensive programming.

The goal is not to create 33 completely unrelated games. Each team should build a small game family with a shared theme, a common parent class, and three specialized games.

How the four students will work

Student 1 — Game Architect

Designs the game rules, identifies the parent class, and defines shared attributes.

Student 2 — Python Programmer

Implements the classes, constructors, objects, and inheritance.

Student 3 — Debugger & Safety Inspector

Tests invalid inputs, adds exception handling and defensive programming, and checks edge cases.

Student 4 — Game Presenter

Integrates the three games, explains polymorphism, and demonstrates decorators and generators.

These are role assignments, not restrictions: all four students should participate in designing, testing, and presenting.

The 33 games: Team-wise assignment

Each team gets a unique theme and three related games. They can use one parent class for all three games and override the play() method in each child class.

Cool Math Games Educational: 5 Ways to Make Learning Fun

Team 1 — Number Detectives

Logic and arithmetic

  1. Kaprekar Challenge — Transform a four-digit number toward 6174.
  2. Missing Number Hunt — Find the missing number in a sequence.
  3. Math Sprint — Solve timed arithmetic questions.

Special focus: number validation, attempt counters, generated questions.

Chemistry - Atoms and Molecules Find the Pair  Game KS3 | Teaching Resources

Team 2 — Science Explorers

Science and discovery

4. Periodic Table Quiz — Identify elements and symbols.

5. Space Mission Quiz — Answer questions about planets and space.

6. Human Body Challenge — Match organs with their functions.

Special focus: question generators, answer checking, score monitoring.

Password Treasure Map | Kubrio

Team 3 — Treasure Hunters

Adventure and puzzles

7. Hidden Treasure Hunt — Follow clues to locate treasure.

8. Escape Room Challenge — Solve puzzles to unlock a room.

9. Secret Code Breaker — Decode a hidden message.

Special focus: clue generators, valid answer checks, controlled game progression.

Palavras Cruzadas Tesouro – Babebi | Babebi | Ideiaria Brinquedos

Team 4 — Word Wizards

Language and vocabulary

10. Word Scramble — Rearrange letters to find a word.

11. Vocabulary Builder — Match words with meanings.

12. Spell Master — Correct spelling mistakes.

Special focus: string validation, generated words, handling empty answers.

matrix style cyber corridor as big data storage locked

Team 5 — Cyber Guardians

Computing and cybersecurity

13. Password Strength Challenge — Classify password strength using safe sample passwords.

14. Binary Code Decoder — Convert simple binary values.

15. Phishing Spotter — Identify suspicious features in fictional messages.

Special focus: input rules, defensive checks, safe handling of test data.

Easy Coding Game - Loomini

Team 6 — Maze Masters

Paths and navigation

16. Grid Maze Runner — Navigate a grid to reach the exit.

17. Shortest Path Puzzle — Find the route with the fewest steps.

18. Robot Navigator — Guide a robot using directional commands.

Special focus: command validation, generators for moves, handling blocked paths.

Mi Pequeña Tienda - Juego de Matemáticas Para Niños

Team 7 — Smart Shopkeepers

Business and money

19. Budget Shopping Game — Buy items without exceeding a budget.

20. Price Calculator Challenge — Calculate totals and discounts.

21. Inventory Detective — Find stock shortages and incorrect counts.

Special focus: numeric validation, negative-value checks, exception handling.

SmartFloor | PAKIET | PIONKI W AKCJI – SmartFloor

Team 8 — Sports Champions

Sports and scoring

22. Penalty Shootout — Simulate a sequence of penalty attempts.

23. Basketball Score Challenge — Calculate scores from different shots.

24. Tournament Manager — Record results and determine a winner.

Special focus: score validation, decorators for match logs, generators for rounds.

Lär dig trafikspelet - Lekolar

Team 9 — Traffic Controllers

Transport and decisions

25. Traffic Signal Simulator — Respond to red, amber, and green signals.

26. Road Sign Quiz — Match signs with their meanings.

27. Route Planner — Compare simple routes between locations.

Special focus: valid states, rule-based behaviour, route and input checks.

Gathering A Garden Board Game - Toy Box Michigan

Team 10 — Eco Innovators

Environment and sustainability

28. Waste Sorting Challenge — Classify waste into suitable categories.

29. Water Conservation Game — Make choices to reduce water use.

30. Smart Farming Simulator — Make decisions based on simple soil and weather readings.

Special focus: category validation, generated scenarios, safe handling of missing readings.

Search and Find– Shape Pattern
 – Tevety

Team 11 — Creative Thinkers

Memory and pattern recognition

31. Pattern Predictor — Predict the next item in a sequence.

32. Memory Match — Match pairs of symbols or words.

33. Color Code Master — Guess a hidden sequence of colors.

Special focus: generators for rounds, attempt tracking, validation, reusable game rules.

How to make all 33 games demonstrate the syllabus

Every team should use the same basic architecture, but customize the three child classes for its own theme.

Every team must include these four upgrades

  1. Decorator: Log when a game starts and finishes.
  2. Generator: Supply questions, clues, rounds, or missions one at a time.
  3. Exception handling: Handle invalid input without an unhandled crash.
  4. Defensive programming: Validate names, difficulty, scores, and other game-specific inputs.

Recommended deliverables for each team

Each team should submit:

  1. A paper blueprint showing the parent class and three child classes.
  2. Three game rules and their attributes.
  3. Python code with inheritance and method overriding.
  4. At least one decorator and one generator.
  5. Exception handling and defensive checks.
  6. A demonstration of all three games.
  7. A brief explanation of what happens when invalid input is entered.

 



No comments:

Post a Comment