Saint Louis University |
Computer Science 150
|
Dept. of Math & Computer Science |
The goal of this assignment is to create an image of an initial checkerboard configuration, such as the following:
In terms of the end result, you must do the following:
You are creating a square window (you may choose the precise size)
As closely as possible, there should be no extraneous margins left within the canvas. That is the corners of the checkerboard should be aligned with the corners of the canvas. (though the window itself may have an unavoidable margin surrounding the canvas).
You are creating an 8x8 grid, with alternating red and black squares, as shown above with red in the top-left corner.
You will also be adding 12 yellow and 12 green checkers, in the configuration as shown in the above figure. In particular, all checkers reside on black squares, with yellow ones in the top three rows, green ones in the bottom three rows and no checkers in the middle two rows.
Equally important in this assignment is your technique. You must make legitimate use of control structures to exploit the obvious patterns which exist in the board.
Given that the end result is fixed, it would be possible for someone to write code which technically works by individually drawing each of the 64 squares and each of the 24 circles. But you will not receive full credit for such an approach.
As a general rule, if you ever find yourself "cutting-and-pasting" code from one part of a program to another, there is a better way to express the repetition!
For this assignment, you must work individually in regard to the design and implementation of your project.
Please make sure you adhere to the policies on academic integrity in this regard.
You should create a new file, checkers.py, which contains all of your own code. This file must be submitted electronically.
You should also submit a separate 'readme' text file, as outlined in the general webpage on programming assignments.
Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.
The assignment is worth 10 points.
For the required portion of the assignment, we did not make any requirements about the overall size of the board. For extra credit, we want you to write your program in a way that scales your picture to a desired window size.
Specifically, when executing your program, you should first prompt the user for the desired width of the window, measured in pixels. Since the board is presumed to be square, you need not explicitly ask for the height of the board. Once you have received that input, create such a window and draw the checkerboard accordingly.
If your program is well-written, you should be able to use it to not only create the standard 8x8 checkerboard, but to create an NxN checkerboard pattern for any (even) value of N. Let's presume that we wish to define the rules for an NxN game so that each player starts with three rows of checkers (namely the top three rows and the bottom three rows, respectively). For example, here is an image of a hypothetical 20x20 game of checkers.
To meet this goal, ask the user of the software to enter a value for N.