ch.sahits.game.openpatrician.model.product
Class SimplePriceCalculation

java.lang.Object
  extended by ch.sahits.game.openpatrician.model.product.SimplePriceCalculation
All Implemented Interfaces:
IPriceCalculation

final class SimplePriceCalculation
extends Object
implements IPriceCalculation

This is a very simple implementation of the price calculation algorithm. It is based on the cosinus and ignores theproductionRate, population structure and state of the city.

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 26, 2011

Constructor Summary
SimplePriceCalculation()
           
 
Method Summary
 double computePrice(int min, int max, int available, int saturation, int productionRate, IPopulationStructure pop, ECityState state)
          Compute the price for one item of the ware.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePriceCalculation

SimplePriceCalculation()
Method Detail

computePrice

public double computePrice(int min,
                           int max,
                           int available,
                           int saturation,
                           int productionRate,
                           IPopulationStructure pop,
                           ECityState state)
Compute the price for one item of the ware. Though the price is only handled in further computation as integer value, this method returns its value as double so this condition can be tested:
The higher the available amount (but still below the saturation value) the smaller (strictly) the returned value.
For different starting values:
If the starting value b is below starting point a the whole curve of b is below (not necessary strictly) the curve of a. The curve is continues between 0 (inclusive) and infinity.
Compute the price based on the cosine. If nothing is available the max value is returned, if more than the saturation value is available the min value is returned. In between the price is defined by the cosine which produces a curve that is pretty shallow towards the two extremes.

Specified by:
computePrice in interface IPriceCalculation
Parameters:
min - the lowest possible price (0 exclusive)
max - the highest possible price
available - amount of wares that are available in the market
saturation - amount of items at which the market is saturated (no further price change
productionRate - amount the city can produce within a week
pop - population structure that may have an influence on the calculated price
state - state of the city
Returns:
price for one item sold


Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.