Fix typos, memory management, formulae

This commit is contained in:
cim 2014-08-23 17:39:56 +01:00
parent 5fc0ebc193
commit f2087acf34
3 changed files with 74 additions and 72 deletions

View File

@ -8,12 +8,12 @@
"peak_import" = 0; // Rich Ind
"price_average" = 50; // decicredits
// fraction of average ~= 2.75 credits
"price_economic_component" = 0.55;
"price_economic" = 0.55;
// fraction of average ~= 0.2 credits
"price_random_component" = 0.04;
"price_random" = 0.04;
"quantity_average" = 13.5; // gets rounded
"quantity_economic_component" = 0.52;
"quantity_random_component" = 0.04;
"quantity_economic" = 0.52;
"quantity_random" = 0.04;
"export_legality" = 0;
"import_legality" = 0;
};
@ -24,11 +24,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 71;
"price_economic_component" = 0.18;
"price_random_component" = 0.09;
"price_economic" = 0.18;
"price_random" = 0.09;
"quantity_average" = 15;
"quantity_economic_component" = 0.23;
"quantity_random_component" = 0.1;
"quantity_economic" = 0.23;
"quantity_random" = 0.1;
"export_legality" = 0;
"import_legality" = 0;
};
@ -39,11 +39,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 231;
"price_economic_component" = 0.19;
"price_random_component" = 0.06;
"price_economic" = 0.19;
"price_random" = 0.06;
"quantity_average" = 16;
"quantity_economic_component" = 0.66;
"quantity_random_component" = 0.09;
"quantity_economic" = 0.66;
"quantity_random" = 0.09;
"export_legality" = 0;
"import_legality" = 0;
};
@ -54,11 +54,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 152;
"price_economic_component" = 0.45;
"price_random_component" = 0.40;
"price_economic" = 0.45;
"price_random" = 0.40;
"quantity_average" = 9.75;
"quantity_economic_component" = 1.10;
"quantity_random_component" = 1.59;
"quantity_economic" = 1.10;
"quantity_random" = 1.59;
"export_legality" = 1;
"import_legality" = 0;
};
@ -69,11 +69,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 291;
"price_economic_component" = 0.24;
"price_random_component" = 0.05;
"price_economic" = 0.24;
"price_random" = 0.05;
"quantity_average" = 20;
"quantity_economic_component" = 0.88;
"quantity_random_component" = 0.38;
"quantity_economic" = 0.88;
"quantity_random" = 0.38;
"export_legality" = 0;
"import_legality" = 0;
};
@ -84,11 +84,11 @@
"peak_export" = 0;
"peak_import" = 7;
"price_average" = 902;
"price_economic_component" = 0.12;
"price_random_component" = 0.01;
"price_economic" = 0.12;
"price_random" = 0.01;
"quantity_average" = 27.5;
"quantity_economic_component" = 1.02;
"quantity_random_component" = 0.05;
"quantity_economic" = 1.02;
"quantity_random" = 0.05;
"export_legality" = 0;
"import_legality" = 0;
};
@ -99,11 +99,11 @@
"peak_export" = 0;
"peak_import" = 0;
"price_average" = 512;
"price_economic_component" = 0;
"price_random_component" = 1.0;
"price_economic" = 0;
"price_random" = 1.0;
"quantity_average" = 32;
"quantity_economic_component" = 0;
"quantity_random_component" = 1.0;
"quantity_economic" = 0;
"quantity_random" = 1.0;
"export_legality" = 2;
"import_legality" = 0;
};
@ -114,11 +114,11 @@
"peak_export" = 0;
"peak_import" = 7;
"price_average" = 818;
"price_economic_component" = 0.24;
"price_random_component" = 0.01;
"price_economic" = 0.24;
"price_random" = 0.01;
"quantity_average" = 8.5;
"quantity_economic_component" = 5.77;
"quantity_random_component" = 0.17;
"quantity_economic" = 5.77;
"quantity_random" = 0.17;
"export_legality" = 0;
"import_legality" = 0;
};
@ -129,11 +129,11 @@
"peak_export" = 0;
"peak_import" = 7;
"price_average" = 560;
"price_economic_component" = 0.14;
"price_random_component" = 0.03;
"price_economic" = 0.14;
"price_random" = 0.03;
"quantity_average" = 22.5;
"quantity_economic_component" = 0.93;
"quantity_random_component" = 0.16;
"quantity_economic" = 0.93;
"quantity_random" = 0.16;
"export_legality" = 0;
"import_legality" = 0;
};
@ -144,11 +144,11 @@
"peak_export" = 0;
"peak_import" = 7;
"price_average" = 388;
"price_economic_component" = 0.03;
"price_random_component" = 0.16;
"price_economic" = 0.03;
"price_random" = 0.16;
"quantity_average" = 29;
"quantity_economic_component" = 0.12;
"quantity_random_component" = 0.53;
"quantity_economic" = 0.12;
"quantity_random" = 0.53;
"export_legality" = 0;
"import_legality" = 0;
};
@ -159,11 +159,11 @@
"peak_export" = 0;
"peak_import" = 7;
"price_average" = 692;
"price_economic_component" = 0.26;
"price_random_component" = 0.02;
"price_economic" = 0.26;
"price_random" = 0.02;
"quantity_average" = 1;
"quantity_economic_component" = 32.5;
"quantity_random_component" = 3.5;
"quantity_economic" = 32.5;
"quantity_random" = 3.5;
"export_legality" = 1;
"import_legality" = 0;
};
@ -174,11 +174,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 704;
"price_economic_component" = 0.18;
"price_random_component" = 0.18;
"price_economic" = 0.18;
"price_random" = 0.18;
"quantity_average" = 27.5;
"quantity_economic_component" = 1.15;
"quantity_random_component" = 1.15;
"quantity_economic" = 1.15;
"quantity_random" = 1.15;
"export_legality" = 0;
"import_legality" = 0;
};
@ -189,11 +189,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 120;
"price_economic_component" = 0.11;
"price_random_component" = 0.05;
"price_economic" = 0.11;
"price_random" = 0.05;
"quantity_average" = 58;
"quantity_economic_component" = 0.06;
"quantity_random_component" = 0.03;
"quantity_economic" = 0.06;
"quantity_random" = 0.03;
"export_legality" = 0;
"import_legality" = 0;
};
@ -204,11 +204,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 388;
"price_economic_component" = 0.11;
"price_random_component" = 0.05;
"price_economic" = 0.04;
"price_random" = 0.05;
"quantity_average" = 9;
"quantity_economic_component" = 0.39;
"quantity_random_component" = 0.39;
"quantity_economic" = 0.39;
"quantity_random" = 0.39;
"export_legality" = 0;
"import_legality" = 0;
};
@ -219,11 +219,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 718;
"price_economic_component" = 0.04;
"price_random_component" = 0.09;
"price_economic" = 0.04;
"price_random" = 0.09;
"quantity_average" = 13.5;
"quantity_economic_component" = 0.52;
"quantity_random_component" = 1.15;
"quantity_economic" = 0.52;
"quantity_random" = 1.15;
"export_legality" = 0;
"import_legality" = 0;
};
@ -234,11 +234,11 @@
"peak_export" = 7;
"peak_import" = 0;
"price_average" = 196;
"price_economic_component" = 0.07;
"price_random_component" = 0.15;
"price_economic" = 0.07;
"price_random" = 0.15;
"quantity_average" = 6.75;
"quantity_economic_component" = 0.26;
"quantity_random_component" = 1.11;
"quantity_economic" = 0.26;
"quantity_random" = 1.11;
"export_legality" = 0;
"import_legality" = 0;
};
@ -249,11 +249,11 @@
"peak_export" = 0;
"peak_import" = 7;
"price_average" = 436;
"price_economic_component" = 0.03;
"price_random_component" = 0.15;
"price_economic" = 0.48;
"price_random" = 0.03;
"quantity_average" = 0;
"quantity_economic_component" = 0;
"quantity_random_component" = 0;
"quantity_economic" = 0;
"quantity_random" = 0;
"export_legality" = 0;
"import_legality" = 0;
};

View File

@ -124,9 +124,9 @@ MA 02110-1301, USA.
{
float bias = [self economicBiasForGood:good inEconomy:economy];
float base = [good oo_floatForKey:kOOCommodityQuantityAverage];
float econ = base * [good oo_floatForKey:kOOCommodityQuantityEconomic] * -bias;
float random = base * [good oo_floatForKey:kOOCommodityQuantityRandom] * (randf() - randf());
float base = [good oo_floatForKey:kOOCommodityPriceAverage];
float econ = base * [good oo_floatForKey:kOOCommodityPriceEconomic] * -bias;
float random = base * [good oo_floatForKey:kOOCommodityPriceRandom] * (randf() - randf());
base += econ + random;
if (base < 0.0)
{

View File

@ -27,6 +27,7 @@ MA 02110-1301, USA.
#import "OOCollectionExtractors.h"
#import "OOStringExpander.h"
@implementation OOCommodityMarket
- (id) init
@ -34,7 +35,8 @@ MA 02110-1301, USA.
self = [super init];
if (self == nil) return nil;
_commodityList = [NSMutableDictionary dictionaryWithCapacity:24];
_commodityList = [[NSMutableDictionary dictionaryWithCapacity:24] retain];
return self;
}