15-112 Fall 2012 Homework 9
Due Monday, 5-Nov, at 10pm

Read these instructions first!


  1. OO-based Animation Case Study Review [20 pts]
  2. Adding Text to AnimationWithRetainedGraphics [40 pts]
  3. 2d Board Game [40 pts]
  4. Bonus: Othello [5 pts]

  1. OO-based Animation Case Study Review [20 pts]
    This problem is COLLABORATIVE.  You may work in groups of up to 4 students (yourself included).  Your task here is to meet in a group and to carefully work through the course notes from this week, and then to write Animation.py from scratch, and then to write AnimationWithRetainedGraphics.py also from scratch.  You may peek at the notes and even the solutions as needed, but it is expected that you will be able to completely write these easily from scratch under quiz conditions.  This is not a minor task, and we expect you to allocate about 4 hours for this.

    What to submit:  In your hw9.py file, there is a comment at the header that presently reads "I did NOT do #1."  Assuming you did in fact meet with your group, and that you invested hours of hard work into this, and that you can basically write Animation.py and AnimationWithRetainedGraphics.py from scratch under quiz conditions, then you should change this comment to read "I *DID* do #1, along with <andrewId's of your groupmates>".  That's it!
     
  2. Adding Text to AnimationWithRetainedGraphics (SOLO) [40 pts]
    This problem is SOLO.   In the designated part of the file hw9.py, write the classes Font, Text, and AnimationWithRetainedGraphicsWithText so that the Hw9_textExample code in hw9-driver.py runs without errors and produces this output:

    Hint:  if you forget to include the anchors, the text will not be properly positioned, and it may instead appear that the fonts are wrong.
     
  3. 2d Board Game [40 pts]
    This problem is COLLABORATIVE.  You may work in groups of up to 4 students (yourself included).  In the designated part of the file hw9.py, following the guidelines provided below, write the classes Piece and BoardGame to implement a basic 2d board game that extends AnimationWithRetainedGraphics so that the Hw9_boardGameDemo code in hw9-driver.py runs without errors, and produces this output:

    This "game" (just a simple demo, really) changes players when you click on a cell.  Player 0 is blue, player 1 is red.  Clicking changes player 0 to player 1 and player 1 to no player (actually, player == None).  Thus, here is the "game" after clicking in each of the cells one-at-a-time across the first row:


    Guidelines:
    1. Create a Piece class that extends Circle (which extends Shape).
    2. The game should include a board (self.board), which should be a 2d list of Piece instances.  Initially, piece.player == None for all of these.
    3. Do not include the checkerboard background squares as actual Shape instances.  Instead, draw these first (basically in the background) and then call super class redrawAll to get all the Shape instances (just the circular pieces) to draw.
    4. Include the method getCellBounds that takes a row and col (in addition to self) and returns a tuple (left, top, right, bottom) that defines the pixel boundaries of that cell.  You should use this method to help compute the values you provide in the calls to the Piece constructor.
    5. Include the method cellPressed(self, row, col), and then include the code in mousePressed that determines in which cell the press occurred and calls cellPressed accordingly.  Provide a default cellPressed method that just passes.
       
  4. Bonus:  Othello (SOLO) [up to 5 pts]
    This problem is SOLO.   In the designated part of the file hw9.py, write the class Othello that extends the BoardGame class to implement a playable game of Othello (also known as Reversi).  It should be human-human playable (no computer player / AI needed!).  Hint:  you will probably want to adapt the wordSearch code from earlier this semester.  If you do that, this is not an overly complicated task.

    Have fun!


carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem