2017-10-21 10:40:11 +02:00
|
|
|
/**
|
2017-10-21 21:05:52 +02:00
|
|
|
* Normalize the trade gain as a function of mapSize for a default of: size=1024 and distance= 100m
|
2017-10-21 10:40:11 +02:00
|
|
|
*/
|
|
|
|
function TradeGainNormalization(mapSize)
|
|
|
|
{
|
2017-10-31 18:52:08 +01:00
|
|
|
return Math.sqrt(1024 / mapSize) / TradeGain(10000, mapSize);
|
2017-10-21 10:40:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-21 21:05:52 +02:00
|
|
|
* Part of the trade gain which depends on the distance, the full gain being TradeGainNormalization * TradeGain.
|
2017-10-21 10:40:11 +02:00
|
|
|
*/
|
2017-10-21 21:05:52 +02:00
|
|
|
function TradeGain(distanceSquared, mapSize)
|
2017-10-21 10:40:11 +02:00
|
|
|
{
|
2017-10-31 18:52:08 +01:00
|
|
|
return distanceSquared / (1 + 0.25 * Math.sqrt(distanceSquared) / mapSize);
|
2017-10-21 10:40:11 +02:00
|
|
|
}
|