game
Class DoubleAuction

java.lang.Object
  extended by game.DiscreteGame
      extended by game.DoubleAuction
Direct Known Subclasses:
DoubleAuctionWithMem, GodeSunderDoubleAuction

public class DoubleAuction
extends DiscreteGame

Simulates a general double auction that implements "New York Rules". These rules dictate that every bid must be equal to or greater than the last bid. Conversely each ask must be equal to or less than the last ask.

Author:
tratch

Constructor Summary
DoubleAuction(Market pMarket, int length)
          Constructor
 
Method Summary
 void clearAllParticipantsInventory()
          Convenience method.
 void clearAllParticipantsOfCommodity(Commodity pCommodity)
          Convenience method.
 void endowAllBuyers(Commodity comm, double amt)
          For every buyer in the double auction this method endows them with the given commodity of the given amount
 void endowAllParticipants(Commodity comm, double amt)
          Convenience method.
 void endowAllSellers(Commodity comm, double amt)
          For every seller in the double auction this method endows them with the given commodity of the given amount
 Market getMarket()
           
 java.util.ArrayList<Participant> getParticipants()
           
 boolean isVerbose()
           
 void run()
          Iterates over the number of steps equal to the game length.
 void setMarket(Market market)
           
 void setParticipants(java.util.ArrayList<Participant> participants)
           
 void setRand(java.util.Random rand)
           
 void setVerbose(boolean verbose)
           
 void step()
          Simulates a single turn in a double auction.
 
Methods inherited from class game.DiscreteGame
getCurrentPeriod, getGameLength
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleAuction

public DoubleAuction(Market pMarket,
                     int length)
Constructor

Parameters:
pMarket -
length -
Method Detail

clearAllParticipantsInventory

public void clearAllParticipantsInventory()
Convenience method. For every participant in the double auction this method clears their entire inventory.


clearAllParticipantsOfCommodity

public void clearAllParticipantsOfCommodity(Commodity pCommodity)
Convenience method. For every participant in the double auction this method clears their entire inventory of the given commodity.

Parameters:
pCommodity -

endowAllParticipants

public void endowAllParticipants(Commodity comm,
                                 double amt)
Convenience method. For every participant in the double auction this method endows them with the given commodity of the given amount.

Parameters:
comm -
amt -

endowAllBuyers

public void endowAllBuyers(Commodity comm,
                           double amt)
For every buyer in the double auction this method endows them with the given commodity of the given amount

Parameters:
comm -
amt -

endowAllSellers

public void endowAllSellers(Commodity comm,
                            double amt)
For every seller in the double auction this method endows them with the given commodity of the given amount

Parameters:
comm -
amt -

run

public void run()
Iterates over the number of steps equal to the game length. Also this method increments this game's current period as well as the period in the market associated with this double auction.

Specified by:
run in class DiscreteGame
See Also:
DiscreteGame.run()

step

public void step()
Simulates a single turn in a double auction. First this method gets a random participant to simulate a random participant raising their hand to make a decision. This participant is given a finite amount of tries to make an acceptable decision otherwise nothing happens. At the end of the step the auction is cleared.

Specified by:
step in class DiscreteGame
See Also:
DiscreteGame.step()

getMarket

public Market getMarket()
Returns:
the market the double auction operates in

setMarket

public void setMarket(Market market)
Parameters:
market -

getParticipants

public java.util.ArrayList<Participant> getParticipants()
Returns:
returns a list of all participants in the auction

setParticipants

public void setParticipants(java.util.ArrayList<Participant> participants)
Parameters:
participants -

setRand

public void setRand(java.util.Random rand)
Parameters:
rand -

isVerbose

public boolean isVerbose()
Returns:
true if verbose mode is on, false otherwise

setVerbose

public void setVerbose(boolean verbose)
Parameters:
verbose -