Description
For this assignment, you will write a program that can model a chess game in progress and
will assess (numerically) who is winning using the relative value system. You can read
more about this approach at http://en.wikipedia.org/wiki/Chess_piece_relative_value, but
please note that you must use the values specified below.
Type Value
King 0
Queen 10
Rook 5
Knight 3.5
Bishop 3
Pawn 1
According to the relative value system,
“White” currently has a score of 3.5 and “Black” currently has a score of 10.
Therefore “Black” is currently winning.
COMP1405A/1005A (Fall 2019) − “Introduction to Computer Science I”
Specification for Assignment 6 of 6
To accomplish this task your program must:
• Provide instructions to the user for using your program,
• Provide a way for the user to type in a new “current state” for a chessboard,
• Calculate the score associated with each player and report which player is winning,
• Provide a way for the user to reposition (or remove) pieces, and
• Print (or draw using pygame) the current state of the chessboard.
Further details about how to complete these tasks are specified below.
To allow the user to type in the current state of a chessboard, you must ask the user to type
what pieces appear on each of the eight rows separately. Your program must use lowercase
letters for the white pieces and uppercase letters for the black pieces, and your program
must use the hyphen “-” for an empty space and the following abbreviations – (K)ing,
(Q)ueen, (B)ishop, k(N)ight, (R)ook, and (P)awn. If the user tries to enter a row that contains
an invalid character or is more or less than eight characters in length, your program must
reject that row and have them retype it.
As a clarifying example, to submit the chessboard on the previous page the user would be
expected to type the following:
—–k–
——–
—n—-
——–
——–
—-K—
——–
—Q—-
Your program must store the state of the chessboard as a two-dimensional list, but it
is up to you whether you would like to store the board as a list of lists of characters or process
it into a list of lists of integers instead. Once you have loaded the board you must present it
to the user, either by printing it to the terminal or by drawing it to a pygame window.
Since your program must store the value associated with each piece (from the table on
the previous page) in a list of floating-point values, you must then find a way to compute
the sum of the values corresponding to the pieces of each player. Since your chessboard must
be stored as a multidimensional list, you must use nested loops to accomplish this.
You must give the user the option to quit the program or to either enter another
chessboard from scratch or simply move a piece. It is not necessary for your program to
determine whether or not a move is legal, so you can accomplish this by first asking the user
the location of the piece to be moved and, if there actually is a piece at that location, then ask
the user for the location to which to move that piece. If the user tries to move one piece onto
a square currently occupied by another piece, you can simply remove that other piece. Once
the piece has been moved your program is expected to recompute the scores and present the
user with their options again. Your program should repeat these steps until the user
selects quit.
COMP1405A/1005A (Fall 2019) − “Introduction to Computer Science I”
Specification for Assignment 6 of 6
Your solution must not import any libraries.
Your solution must not use list comprehensions in any way.
Your solution must not use dictionaries or maps in any way either.
You are not permitted to use any built-in functions except input, print, range, len,
insert, append, pop, and the functions for creating or drawing upon a pygame window.
Please note that ‘in’ and ‘+’ are operators, not functions, so you are free to use these if you
wish. You may also use the indexing and slicing operators.
You must write a main function that takes no arguments and produces no return
values. Additionally, as the very last line of your program, you must call this main function.
Your program must be completely organized into a collection of functions, and your
program is not permitted to use any global variables whatsoever. Including the main
function mentioned above, your program must be organized into at least four functions (but
you may add as many as you wish).
You must use meaningful variable names and you must comment your code.
In addition to commenting your code normally, you are also required to write a
descriptive comment for each of the functions you create for this assignment. This
comment must begin with a short description of what the function does, contain a list
(labeled @params) of indented items corresponding to the parameter variables you use to
hold your function arguments, and contain a description of any return values (labeled
@return). If the function you are writing has no params or returns, then you must still
include the @params or @return tag and write (and indent) the word none.
Failure to observe any of these requirements will result in penalties.
Please remember that this assignment must be completed individually. Do NOT discuss
this assignment with anyone except the instructor or the teaching assistants, and do NOT
look for code samples on the internet or from any other source.
As with the previous assignment, you must create flowcharts before you start writing your
code for this assignment. You are expected to create a flowchart for each of the functions you
will be writing. You will not be submitting any flowcharts on cuLearn, but if you visit the
instructor or a teaching assistant you will be asked to show your flowcharts before you
will receive any assistance.