670 S '05
Project 1
Project 2
Project 3
Project 4
Project 5
Project 6
Project 7
Project 8
Project 9
Project 10
Project 11
Project 12
Project 13

Project 6

Due date: 2/18 @ noon

Objective: to add components to an application via implementing interfaces; additional practice with the translation of use cases into the creation and modification of interfaces

Task 1: Your first task is to translate the end-of-game use case into modification to the existing interfaces:

use case: administrator ends the game 

 condition: there is no more turn, either because
 the administrator is out of tiles or because all
 players have dropped out;

 administrator requests all incomplete abbeys 
  from graph,
 determines the followers on them, and 
 scores them in the usual manner 

 administrator computes the ranking of the
 players and then constructs individualized 
 announcements for each player 

 administrator informs all (surviving) players 
 of final scores

 players and administrators end game 

What else would have to change if the final scoring included incomplete roads? [POINTS: 4]

Here are two more use cases for Carcassonne:

use case: player registers with administrator 

 player requests to play a game with the administrator 
 administrator checks that there are followers left
 if so, administrator assigns a follower to the player 
 if not, administrator declines the player's request. 

use case: initiate game 

 when enough players have signed up or
 when an external human supervisor signals 
 the beginning of the game

 run the game 

These use cases give rise to three interface specifications:

   ;; this game administrator runs a single game of Carcassonne 
   ;; [POINTS: 10]
   (define admin<%>
    (interface ()
      register ;; player<%> -> (union false Follower)
      ;; sign up a player for game, assign color, if possible 
      run-game ;; -> String 
      ;; run the game and produce final message

      ;; ASSUME: (register* . run-game)

  ;; a player is in a subscribe-notify relation with admin<%>
  ;; (listener or observer pattern) 
  ;; [POINTS: 10]
  (define player<%>
    (interface ()
      take-turn ;; turn<%> -> Void
      ;; it's the player's turn 
      score-and-token ;; Number Number -> Void 
      ;; the player has scored a point and receives some 
      ;; of the tokens back
      ;; Implementing the following callbacks in the relevant classes:
      ;; [POINTS: 6]

      ;; They help a player keep track of the graph as it evolves:
      placed-tile ;; tile<%> -> Void 
      ;; some other player placed t during a turn 
      placed-follower ;; tile<%> Follower Position -> Void 
      ;; some other player placed f on t at p 
      inform ;; String -> Void 
      ;; accept a message for the player 
  ;; a turn provides temporary access to the administrator's internal 
  ;; state and thus mediates between players and administrators 
  ;; [POINTS: 10]
  (define turn<%>
    (interface ()      
      get-index ;; -> Index
      ;; the index of the tile that you're allowed to place 
      potential-locations-for-tile ;; -> Listof[tile<%>]
      ;; given an index for a potential tile, compute a list of tiles
      ;; that could be placed into the graph
      ;; ASSUME: the result is a non-empty list 
      place-tile ;; tile<%> -> Void
      ;; _this_ turn places the given tile into the graph 
      ;; ASSUME: the given tile is placable in _this_ graph,
      ;; in the sense of _potential-locations-for-tile_      
      ;;      -> Listof[(list tile<%> Position)]
      ;; compute the potential tile locations and positions on these tiles
      ;; in _this_ graph where a follower could be placed 
      place-follower ;; tile<%> Position -> Void
      ;; this turn places the player's follower on t at p
      ;; ASSUME: the given coordinates and position are legal in the
      ;; sense of potential-locations-for-followers; the player has followers

I have modified some of project 4's interfaces and encourage you to do so, too:

  ;; represent the tiles inside a graph 
  (define tile<%> ;; [POINTS: 2]
    (interface () 
      equal ;; tile<%> -> Boolean 
      ;; compare _this_ tile with the given tile 

      index ;; -> Index 
      ;; the index from which _this_ tile was built 

Task 2: Draw an interaction diagram for the observer system of players and administrator here. [POINTS: 4]

Task 3: Your second task is to modify and extend your implementation of project 4. Specifically, implement the administrator, player, and turn classes based on the above interfaces; also modify the classes from project 4 as appropriate. Don't forget to keep up your test suite from project 5 if you do so. [POINTS: 45]

Product: Mail a tar bundle with three subdirectories labeled YourName_Interfaces6, YourName_Carcassonne6, and YourName_Diagram6. Place the relevant pieces into the subdirectories and add a README file to make sure your graders can compile and run the program.

last updated on Tue Jun 9 22:03:19 EDT 2009generated with PLT Scheme