Sliding Puzzle GUI 2024
Sliding Puzzle GUI 2024
OVERVIEW
In this assignment, you are going to design and develop a GUI based sliding puzzle game using Turtle
Graphics for three different sizes: 3x3, 4x4 and 5x5 as depicted above. The objective of this game
remains the same as the console-based version of Sliding Puzzle. However, the interaction between the
game and the player is based on the Mouse Click events and the player is not prompted to enter the
move. Instead, the player simply clicks one of the tiles adjacent to the empty white space to select the
move.
The figure below illustrates an 8-number puzzle, with "INITIAL" as the starting point of the game. The
player must slide one adjacent tile at a time into the unoccupied space (empty space) repeatedly until all
numbers are in sequential order from left to right, top to bottom, as shown in “FINAL".
INITIAL FINAL
SCOPE
1. At the start of the game, prompt the user to enter the size of the game to play: 3, 4, or 5.
2. After successfully completing the prompt, generate a randomized, SOLVABLE puzzle accordingly
and display it on the screen using Turtle graphics. Display each tile as a square shape with a
minimum width of 80 pixels.
3. Wait for the mouse click event from any of the tiles adjacent to the empty white space.
4. Animate the movement of the chosen tile towards the empty white space. The number on the
tile will be displayed after the animation is completed. Essentially, while the tile is in motion, the
number is not visible.
5. When the puzzle is solved (i.e. the numbered tiles are in sequential order, left to right, top to
bottom), change the background color of all tiles to red as shown in the figure in the overview
section and leave the program in running mode.
a. You are not required to prompt the player to start another new game.
6. Choose one color for all the numbers displayed on the tiles, ensuring that the selected color is
not the background color of the Turtle's Windows. A penalty of 10% to Functionality will be
imposed if the Window's background color is used.
7. Use the standard turtle square shape to represent the tiles without incorporating custom,
external image files.
NOTE:
• In your design stick ONLY to functions, in other words, no class objects of your own.
STARTUP OPTIONS
Not applicable
SKILLS
In this assignment, you will be trained on the use of the followings:
PERMITTED MODULES
Only the following python modules are allowed to be used:
DELIVERABLES
1. Program source code (A2_School_StudentID.py)
where School is SSE, SDS, SME, HSS, FE, LHS, MED and StudentID is your 9-digit student ID.
Submit the plain (zip not required) python file by due date to the corresponding assignment folder
under “Assignment (submission).
For instances, a SME student with student ID “119010001” will name the python file as follows:
• A2_SME_119010001.py:
SAMPLE OUTPUT
MARKING CRITERIA
• Coding Styles – overall program structure including layout, comments, white spaces, naming
convention, variables, indentation, functions with appropriate parameters and return.
• Program Correctness – whether or the program works 100% as per Scope.
• User Interaction – how informative and accurate information is exchanged between your
program and the player.
• Readability counts – programs that are well structured and easy-to-follow using functions to
breakdown complex problems into smaller cleaner generalized functions are preferred over a
function embracing a complex logic with many nested conditions and branches! In other words,
a design with clean architecture with high readability is the predilection for the course
objectives over efficiency. The logic in each function should be kept simple and short, and it
should be designed to perform a single task and be generalized with parameters as needed.
• KISS approach – Keep It Simple and Straightforward.
• Balance approach – you are not required to come up a very optimized solution. However, take a
balance between readability and efficiency with good use of program constructs.
DUE DATE
April 2nd, 2024, 11:59:59PM