Department of Mathematics, Computer Science, and
                Statistics
St.
                Lawrence University
Zonohedron
 

What is this object?

...

Links
Overview
Schedule
Grading Info
Class Notes

 

CS 140: Introduction to Computer Programming


CLASS CREATION #3
Tuesday, October 1

This afternoon you can write a Python program that creates the opening position in a game of checkers, as suggested by the picture below.  (You may also try variations on this theme instead, so read all the bullet points before starting!)  Follow the guidelines beneath the picture when creating your image.

  • First open a 401 by 401 screen filled with a black background.
  • Using a nested for loop, create the alternating light and dark brown checkerboard.  (You figure out the correct dimensions for each square.)  These colors are given by the triplets [229,203,128] and [149,88,44], respectively.
  • Next use a regular for loop to draw a grid of horizontal and vertical black lines which separate the light and dark brown squares.

Now choose from among the following options for finishing your creation.

  1. Draw the dark red checkers in the appropriate places using another nested for loop, then do the same for the black checkers.  Try [130,0,0] for the red color.  You can add highlights to your checkers (black border, white highlight, etc.) as desired.
  2. OR Draw a circle on every single square.  Each circle should be either red, yellow, orange or green, colored at random.  (Or four colors of your choice.)  See if you get any five in a rows.
  3. OR Come up with your own way to finish.  As long as it involves circles and for loops it will count.  Have fun and be creative!

If you need any guidance do not hesitate to flag down Dr. V or ask a neighbor for help.  Once your program is running satisfactorily, be sure to have Dr. V try it out so that he can give you credit for your creation.