Project 1

CSU 670 Fall 2007
Out: September 7, 2007
Due September 14, 2007

Reading: Review chapters 1 through 5 of the text book. These chapters cover material from your object-oriented design course.

The picture on page 9 demonstrates what we will achieve in this course: to engineer the illusion of simplicity. We will write programs that play a game but behind the interfaces of those programs, if they play the game well, is a lot of technology.

==================
NOTE: This description is intentionally a bit underspecified.
Ask questions in class to clarify the requirements so that
you have a more complete picture.
==================

Before we start:

Sign up for the mailing list: https://lists.ccs.neu.edu/bin/listinfo/csu670

Add your picture to the class gallery (nice pictures only): https://wiki.ccs.neu.edu/display/CSU670/Gallery

The project of Fall 2007 CSU 670 is about designing and implementing an algorithmic derivative trading game, called the Specker Derivative Game. The objects traded are financial derivatives. (Financial derivatives are financial instruments whose value derives from the value of assets underlying them. Examples of financial instruments used in derivative transactions are options. Options are financial instruments that convey the right, but not the obligation, to engage in a future transaction on some underlying security.) Each derivative has a creator and can be bought by a player at the price offered by the creator. We say that a buyer owns a derivative. When you own a derivative of type T, you have the right to request raw material of type T and you have the right to sell back to the creator the product you produce from the raw material at a price that is equal to the quality of your product. The better quality you produce, the more you will be paid. On the other hand, the creator of the derivative has only the obligation to give you raw material of type T but he/she may make it hard for you to produce a high quality product.

The game has an administrator and a list of players. A player consists of a name, a list of offers (derivatives offered for sale), a list of sold derivatives (derivatives bought by other players), a list of bought derivatives (derivatives bought from other players), and a money field for the money owned by the player. Initially, each player gets 5 million dollars.

A derivative consists of a name, a type (currently unspecified), a creator (a player), a price, and a few fields representing the state of the derivative as follows. If the optional boughtBy field is present, the derivative has been bought by another player. If the optional rawMaterial field is present, the buyer has requested raw material (currently unspecified). If the optional finished field is present, the buyer has delivered the finished product which is currently unspecified but it has a quality field which says how much the buyer has to be paid by the creator of the derivative.

Create an object-oriented design for The Specker Derivative Game. Include also the history, the list of moves that happened during a game (the administrator keeps track of this information). The moves that must be recorded include CreateDerivative, BuyDerivative, DeliverRawMaterial, DeliverFinishedProduct. CreateDerivative creates a derivative (unsold). BuyDerivative records who bought the derivative. DeliverRawMaterial records the raw material delivered by the creator of the derivative. DeliverFinishedProduct records the finished product delivered by the buyer and the quality (a real number in [0,1]) of the product. All prices are real numbers in [0,1] (fraction of a million $).

Here is an example of the kind of information you need to represent. This representation contains redundancy and you should attempt to reduce some or all of the redundancy in your design.

(player 
    name Peter
    offers 
      (derivative
	 name d1
         type unspecified
	 creator Peter
	 price 0.75
       derivative
	 name d2
         type unspecified
	 creator Peter
	 price 0.618
       )
    soldOffers
      (derivative
	 name d3
         type unspecified
	 creator Peter
	 price 0.85
	 boughtBy Paul
       derivative
	 name d4
         type unspecified
	 creator Peter
	 price 0.618
	 boughtBy Paul
       )
    boughtOffers
      (derivative
	 name d5
         type unspecified
	 creator Paul
	 price 0.85
	 boughtBy Peter
       derivative
	 name d6
         type unspecified
	 creator Paul
	 price 0.6
	 boughtBy Peter
       )
    money 0
)
history 
  (create 
     derivative
	 name d1
         type unspecified
	 creator Peter
	 price 0.75
   create
     derivative
	 name d4
         type unspecified
	 creator Peter
	 price 0.618
   buy
     derivative
         name d3
         type unspecified
	 creator Peter
	 price 0.85
	 boughtBy Paul
   
   delivered
     derivative
         name d3
         type unspecified 
	 creator Peter
	 price 0.85
	 boughtBy Paul
	 rawMaterial
           unspecified raw material
   finished
     derivative
         name d3
         type unspecified
	 creator Peter
	 price 0.85
	 boughtBy Paul
	 rawMaterial
           unspecified raw material
         finished
	   unspecified finished product
	   quality 0.25
  )
The above example is intentionally incomplete and not from a real game. The purpose is only to show the kind of information that needs to be represented.

Turn in your object-oriented design, together with the corresponding Java classes (or data types in your favorite language). Write a program that prints for each player the amount of money owned. The format is:

player Paul: 45.66
player Lisa:  23.54
player Henry: 11.01
The players are sorted by the amount of money they own.

You have complete freedom how you design your language and your objects. For example, you could create an XML based language and a corresponding object-oriented design. Keep in mind that our later goal is to create software for a player that makes a lot of money by creating derivatives and selling them at a profit.

The details of the game will be introduced later. Basically, the players get a turn during which they create new derivatives or buy one from one of the players. It is explicitly allowed to create a derivative of type T and price p even if there is already a derivative of the same type T but with a higher price offered by some player.

If the derivatives are too expensive, nobody will buy them. For example, if all cost one (million). The rules of the game will make the players buy or lower the prices: Here is an important rule:

When it is a player's turn: The player must buy at least one derivative from another player or re-offer all derivatives that are for sale with a lower price. This will create new derivatives of an existing type, one for each type. In addition, a player may create new derivatives of new types. (The idea is that if a player does not want to buy, s/he must demonstrate that the prices are too high by lowering all of them. Several derivatives of the same type will be usually for sale and the clever buyer will normally choose the cheapest one.)

The game terminates after a fixed number of rounds (say 20). The winning player is the one who has the most money at the end of the game.

1. by careful thinking. Buy derivatives where you are guaranteed to make money.

2. by exploiting mistakes of others: (a) Sell derivatives where the buyer uses suboptimal techniques to create the finished product. This will lower the amount of money you have to pay for the finished product and will increase your profit. (b) Buy derivatives where you think the seller will make a mistake by giving you raw material from which you can produce a high quality product.

So in order to play the game well you must be good at: 1. spotting the best buys (which includes spotting the bad buys) 2. creating a high quality finished product out of the raw material.

In addition it helps, if you know the shortcomings of the other players but this is not needed to win in this game.

Of course, this all depends on the type of raw product, and what it means to finish a raw product. This will be specified in project 2.

What to turn in for project 1: Turn in your object-oriented design (including a UML class diagram) that can represent the required information. Turn in your player sorting program with sufficient test data. Use Eclipse or your favorite IDE to produce your UML class diagram and your player sorting program.

The projects are done using pair programming. Find a partner and let me know if you cannot find one. http://www.ccs.neu.edu/home/lieber/courses/csg111/f07/ppp/

You must turn in a development diary for each project: http://www.ccs.neu.edu/home/lieber/courses/csg111/f07/ppp/development-diary.html

check out blackboard: turn in electronically, header to use.

PS. If you would like to think of a concrete situation, lets go to chemistry: What is the type? A set of atoms that will be used to build molecules, say H (hydrogen) and O (oxygen). What is the raw material? One mol of molecules made of those atoms only and using each kind of molecule at least once. (For example H2O, water.) What is the finished product? A chemical product that you produce from the given raw material and that you can sell at some price between 0 and 1. In the case of our example, the finished product might be pure hydrogen which you can sell at a price close to 1 because it can be used to run a green, zero-emission car. You have some insight into chemistry that lets you make a judgment, that says that whatever raw material of the given type you get, you can produce a substance with a certain value. This allows you to judge the price of a derivative appropriately so that even if you get "bad" raw material, you can still produce a substance of a value that will let you recover the costs of the derivative.

Technical Help

A tool that can help you manage your project is the IDE called Eclipse. Eclipse has a plug-in architecture that allows third-party developers to extend its functionality. For creating the UML diagrams needed for this homework you can use one of the many UML plugins for Eclipse, one of which is called EclipseUML made by a company called Omondo.

EclipseUML lets you draw UML diagrams, generate a class hierarchy out of your UML diagram, and keep in sync the UML diagram and the source code (so when you change one, the changes are propagated to the other).

Probably the easiest way to install Eclipse and EclipseUML in Windows is to download the free version of EclipseUML bundled together with Eclipse. The steps you need to follow are:

1) Download and install JDK 5 from Sun:

http://java.sun.com/javase/downloads/index_jdk5.jsp

2) Download the file called: "Eclipse 3.3 + EclipseUML Studio Zip file
for windows XP/2000/Vista"

(it's about 300MB) from:

http://www.eclipsedownload.com/download_free_eclipse_3.3.html

This contains both Eclipse 3.3 and EclipseUML. Install this file and you
should be able to use Eclipse and EclipseUML.
Be careful: if you have installed previous versions of Eclipse keep the 3.3 version in a *fresh* directory and make sure that the project space that it will ask you to create the first time you run it also to be in a fresh directory.

Is the free version of EclipseUML on college machines?