CMPT 103 – Project Icebreaker

CMPT 103 – Project Icebreaker
General Information
Python version and IDE: Python 3.x and WingIDE 101
Due dates: in three milestones: MS1, MS2, MS3 as indicated by your lab instructor
Submission
 All Python source files must be submitted electronically.
 Also provide a plain ReadMe text file for each milestone, which gives an overview
of how you implemented your project.
 A portion of the total marks (20%) will be allocated for documentation and
programming style.
Assignment
REFERENCES
 Graphics.py version 5: http://mcsp.wartburg.edu/zelle/python/
 Graphics Reference ver 5:
http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf
 Graphics Reference online:
http://mcsp.wartburg.edu/zelle/python/graphics/graphics/index.html
BLACKBOARD RESOURCES
Download from Blackboard the file CMPT_103_Icebreaker_Sp22.zip, which includes:
 this CMPT_103_Icebreaker_Sp22.pdf file: project specifications
 graphics.py file, version 5
 graphics.pdf: reference document for graphics.py, version 5
 Image files for players: red_dot.gif and blue_dot.gif
CMPT 103 Spring 2022 – Project Icebreaker
2
ICEBREAKER GAME
Icebreaker is a two-player game on a board, which uses
game piece for each player, e.g.: a coloured dot, or other
image (up to the designer). Ice is represented by white
squares, while water is represented by blue squares. The
objective of the game is for each player to trap the other
player on the ice by surrounding them with water.
The starting setup of the game is as follows:
 All squares are white: the board is solid ice.
 Players start from different squares, either randomly
determined, or specified in code; an example is shown
on the right. In the starting position, there must be at
least one blank square between the players.
Players take turns, performing two tasks in each turn:
1. Player moves their piece to an adjacent free square of ice, by clicking on the target
square they want to move their player to. The player may be allowed as many clicks
as necessary to make a valid move. Diagonal moves are allowed.
2. Player clicks on a free square of ice to break it, which turns it blue. Only an unbroken
square of ice can be broken. The player may be allowed as many clicks as necessary
to make a valid ice break.
If a player cannot move, because all adjacent squares are broken, or occupied by the
opponent, that player loses the game, the winner is declared, and the users are prompted
to play another game or to quit.
The status of the game: whose turn it is, their coordinates, that player’s next task (move or
break ice) and the outcome of each mouse click, are displayed using graphics.py Text
objects.
At any time, the game may be terminated, or reset to the game’s starting setup, by clicking
the QUIT or RESET button, respectively.
BOARD LAYOUT
The main application window consists of a grid of board squares at the top, with a bottom
section containing two text messages and two buttons. The program should define a
constant for the gap between the game squares. The example at the top has game
squares of 40×40 pixels and a gap of zero. Examples below have a gap of 4.
CMPT 103 Spring 2022 – Project Icebreaker
3
GAME PLAY
A player’s turn consists of two tasks:
1) move their piece: a piece may be moved to any
adjacent white square (up, down, left, right or
diagonally). Your program must detect an attempt to
make an invalid move to a square outside the range of
adjacent squares, and report it NOT VALID in the
informative text.
For example, if red moves first, the board may change
to this:
2) break a square of ice: Any unbroken and unoccupied
square may be clicked. Once broken, a square remains
broken for the rest of the game. Clicking on a broken or
occupied square should be reported as NOT VALID.
The following shows the board after red has broken a
square of ice; a broken square of ice is changed to light
blue:
Once a player has moved and broken a piece of ice, the
turn changes to the other player (here: Blue).
Similarly, Blue may move to any unbroken and unoccupied
adjacent square. After Blue has moved and broken a piece
of ice, the game board may look like this:
How the game ends
The objective of the game is to enclose your opponent so
they cannot move. The first player to not be able to move
loses the game. A player is not able to move when all
squares surrounding it are either broken or occupied by the
other player. For example, here, Red has won the game:
STATUS DISPLAY
The current state of the game is identified by the current player, their next task, the
location of both players, the state of the board squares (ice or water), and where the
mouse has been clicked. Your game should display at least two status messages:
1) A player status message informing the users whose turn it is, and what their next
task is (move or break ice). This message should display the winning player when
the game ends.
CMPT 103 Spring 2022 – Project Icebreaker
4
2) A mouse click status message showing the board coordinates of a valid move, or
the text ‘NOT VALID’. When the QUIT or RESET button is quit, the mouse click
message should display ‘BYE BYE !!’, or ‘RESET’, respectively. Below are some
examples of the status section.
SUGGESTED APPROACH TO PROGRAM DEVELOPMENT
a) Program constants such as board dimensions (number of columns and rows), the
pixel dimensions of each game square and of the main application window, must be
defined at the beginning of the program. The program should also define a constant
for the gap width between the game pieces.
b) So called state-variables which uniquely and completely define the progress, or
ongoing state of the game at any point, must be created at the beginning (after
program constants), as global variables, e.g.:
 player: whose turn it is, identified by two distinct values (e.g. ‘red’/’blue’,
‘Popeye’/’Brutus’, 0/1)
 players: consists of the location of each player on the board, and information
about the visual object used as their game piece, e.g. a graphics.py object. The
two players are distinguished according to the above player variable.
 board: a grid of squares of solid or broken ice, which can be represented by a 2-
D list of lists, containing elements that represent the state of each square (solid or
broken). Note that lists can contain graphics.py objects.
 Player status message and mouse click status message (see previous
section)
CMPT 103 Spring 2022 – Project Icebreaker
5
PROGRAM LOGIC
Once the above constants and variables are defined, the general program logic can be
developed, for example:
main GUI loop:
1) Check whether the current player can make a valid move. If none is possible,
declare the winner and prompt the users to play again or quit.
2) Wait for the coordinates of the current user’s mouse click and determine how to
respond to it.
3) If clicked on Quit or Reset, display a message and respond accordingly
4) If clicked on a valid square, move the player’s game piece and update
messages accordingly.
5) If clicked anywhere else, display a message accordingly and ask for a new
mouse click until the player’s task is completed.
6) Repeat steps 2-5 for the player’s second task: breaking a piece of ice. If clicked
on a valid square: break the square and update messages accordingly.
7) Change player
PROGRAM MODULARITY
Your program should use functions to perform specific tasks. Examples of specific tasks
include:
 setting up the application window, which includes creating a GraphWin object, Text
objects for displaying messages, and buttons.
 setting up the board, including the game pieces at their starting positions.
 creating a button
 determining whether a player can make at least one allowed move
 moving the current player
 determining whether the mouse was clicked on a button
 determining whether the mouse was clicked on one of the game pieces
 determining whether the mouse was clicked on a piece that the current player is
allowed to move to
 resetting the board to its starting state
 etc.
CMPT 103 Spring 2022 – Project Icebreaker
6
STARTING AND ENDING THE GAME
After completing the main program, two separate graphics.py GraphWin objects should be
created to start and end the game:
1) When the game starts, a Splash screen should be displayed, showing the game’s
title, your name, some additional information, and a button labelled ‘Play Game’,
which launches the game when clicked.
2) When a game round ends, either after a winner is declared, or after the QUIT
button is clicked and the game has ended, a Score screen should be displayed,
which shows the current score of each player, and prompts the users to either
terminate the game completely, or restart the game for another round.
Examples of both screens are shown below:
BE CREATIVE
The screenshots shown in these project specifications are for illustration purposes only
and are not meant to be copied. Within the given rules and minimum program
requirements, you are encouraged to develop your own game, using your own ideas and
creativity. Have fun and good luck!
MILESTONES AND PROJECT SUBMISSION
The objectives of this project are divided into three milestones, each with their own
submission deadline. Files are submitted through eSubmit.
Each milestone submission must consist of at least two files:
• Proj_MS#_XX.py, where # is the milestone number, and XX are your initials:
Python code file. Your code needs to follow the Lab Submission and Style Guide,
and include docstrings for each function and comments to explain code.
• Proj_ReadMe_XX.txt, where XX are your initials: a separate documentation file.
• Additional module code files, if modules were used
CMPT 103 Spring 2022 – Project Icebreaker
7
The ReadMe file is meant to give an overview of how you implemented your project,
including program structure and game logic, variables, and functions. Include a ReadMe
file with each submission, describing your project up to each milestone. The ReadMe file
should contain the following information:
1) a brief description of the game rules
2) program structure and game logic, describing the control flow of the main program,
including loops and major decisions.
3) a list of program constants: name, type, and purpose
4) a list of global variables: name, type, and purpose
5) a list of function names and descriptions; function docstrings can be used here
MILESTONE 1: Proj_MS1_XX.py – 10% of final mark MARKS
1. Define game constants, including window size, board dimensions,
and separating gap.
/ 5
2. Initialize variables for the current player, and for the location and
game piece information of each player.
/ 5
3. Create a GraphWin object for the main application window, with your
name, project name, version, date as its title.
/ 5
4. Set up the board: 2-D array of squares [10], the two game pieces [5],
and separating gaps [10].
/ 25
5. Create Text objects for the player status and mouse click status
messages.
/ 5
6. Create Quit and Reset buttons / 10
7. Set up main GUI loop to:
a) wait for a mouse click
b) on clicking QUIT: display BYE BYE !!’, wait for one last mouse
click, close window, and terminate program
c) on clicking RESET: display “RESET and return to the top of
the GUI loop
d) on clicking on the board, display (column, row) of square
clicked and return to the top of the GUI loop
e) on clicking elsewhere, display ‘NOT VALID’ as the mouse
click status message.
/ 10
/ 5
/ 5
/ 5
8. Documentation, commenting, and programming style, including
separate Proj_ReadMe_XX.txt file
/ 20
Total / 100
CMPT 103 Spring 2022 – Project Icebreaker
8
MILESTONE 2: Proj_MS2_XX.py – 10% of final mark MARKS
1. Initialize the game board with players in starting locations and
initialized status messages
/ 10
2. The main GUI loop should:
a) allow each user to perform both tasks: move and break ice
b) respond appropriately to the QUIT and RESET buttons
c) for each task, the program should:
• detect invalid clicks and display ‘NOT VALID’ if needed
• allow the user to click until a valid square is selected
• move a game piece when needed
• break a board square when needed
d) switch turns to the other player after the current player
completes both tasks.
e) at all times indicate whose move it is
f) at all times indicate which click is expected: move piece or
break ice
/ 10
/ 10
/ 5
/ 10
/ 10
/ 10
/ 5
/ 5
/ 5
3. Documentation, commenting, and programming style including
separate Proj_ReadMe_XX.txt file
/ 20
Total / 100
MILESTONE 3: Proj_MS3_XX.py – 5% of final mark MARKS
1. Detect the game winner and display a message / 25
2. Winner announced / 10
3. Splash screen in a separate GraphWin object when the game starts
with a button to launch the icebreaker game.
/ 20
4. Score screen in a separate GraphWin object when a game round
ends, displaying the current score and a button to start a new round.
/ 25
5. Documentation, commenting, and programming style including
separate Proj_ReadMe_XX.txt file
/ 20
Total / 100

Get Your Custom Essay Written From Scratch
Are You Overwhelmed With Writing Assignments?
Give yourself a break and turn to our top writers. They’ll follow all the requirements to compose a premium-quality piece for you.
Order Now