Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » FreeStars » Detailed mineral mining table
Detailed mineral mining table Mon, 01 October 2007 17:07 Go to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
I've been reading through the freestars! code as well as I can, it appears to be missing tables on mineral depletion.

As I've written a table and a program to generate the table for use in my stars clone, I'm posting it here so that it can be reviewed and, if whoever is in charge of freestars! likes it, they can use it too.

Would someone who knows something about mineral depletion mind glancing over the table or program and telling me if there are any errors? It does seem more or less correct, but mineral depletion is very hard to measure accurately.

It's based on the following post done some time ago in the academy:
Quote:


Ages ago Jason Cawley wrote in RGCS newsgroup about minerals per concentration point (if mined with remote miners or 10 efficency mines):

> So my guess is it is supposed to be something like this ->
> con greater than 30 -> 12500 kT * ln (starting con/ending con)
> less than 30, greater than 3 -> 456 kT per point

Later there were made tests that from 4 to 3 and from 3 to 2 were about 1000 kT minerals and from 2 to 1 about 2000 kT of minerals.
On case the mine efficiency is not 10 then these amounts have to be multiplied with mine efficiency/10.
It seemed correct enough back then. Nod

My recent testing however shows that the logarithmic formula does not fit for concentrations above 100. There seems to be like 123 or 124 kT of minerals per point above 100. I am not sure if it was always so or only in latest patches. Confused

The maximum mineral conc possible seems to be 200 (even huge comet does not push it higher).



program:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
  int i;
  double a;
  int sum = 4000;
  for (i = 5; i < 30; i++)
  {
    sum += 456;
    printf("%d %d\n", i, sum);
  }
  for (; i < 101; i++)
  {
    a = (double)i / (double)(i - 1);
    a = log(a);
    a *= 12500;
    sum += (int)a;
    printf("%d %d %d\n", i, (int) a, sum);
  }
  for (; i < 201; i++)
  {
    sum += 124;
    printf("%d %d\n", i, sum);
  }

  return 0;
}


table:
con| this level | total
---+------------+------------
1  |          0 |          0
2  |       2000 |       2000
3  |       1000 |       3000
4  |       1000 |       4000
5  |        456 |       4456
6  |        456 |       4912
7  |        456 |       5368
8  |        456 |       5824
9  |        456 |       6280
10 |        456 |       6736
11 |        456 |       7192
12 |        456 |       7648
13 |        456 |       8104
14 |        456 |       8560
15 |        456 |       9016
16 |        456 |       9472
17 |        456 |       9928
18 |        456 |      10384
19 |        456 |      10840
20 |        456 |      11296
21 |        456 |      11752
22 |        456 |      12208
23 |        456 |      12664
24 |        456 |      13120
25 |        456 |      13576
26 |        456 |      14032
27 |        456 |      14488
28 |        456 |      14944
29 |        456 |      15400
30 |        423 |      15823
31 |        409 |      16232
32 |        396 |      16628
33 |        384 |      17012
34 |        373 |      17385
35 |        362 |      17747
36 |        352 |      18099
37 |        342 |      18441
38 |        333 |      18774
39 |        324 |      19098
40 |        316 |      19414
41 |        308 |      19722
42 |        301 |      20023
43 |        294 |      20317
44 |        287 |      20604
45 |        280 |      20884
46 |        274 |      21158
47 |        268 |      21426
48 |        263 |      21689
49 |        257 |      21946
50 |        252 |      22198
51 |        247 |      22445
52 |        242 |      22687
53 |        238 |      22925
54 |        233 |      23158
55 |        229 |      23387
56 |        225 |      23612
57 |        221 |      23833
58 |        217 |      24050
59 |        213 |      24263
60 |        210 |      24473
61 |        206 |      24679
62 |        203 |      24882
63 |        200 |      25082
64 |        196 |      25278
65 |        193 |      25471
66 |        190 |      25661
67 |        187 |      25848
68 |        185 |      26033
69 |        182 |      26215
70 |        179 |      26394
71 |        177 |      26571
72 |        174 |      26745
73 |        172 |      26917
74 |        170 |      27087
75 |        167 |      27254
76 |        165 |      27419
77 |        163 |      27582
78 |        161 |      27743
79 |        159 |      27902
80 |        157 |      28059
81 |        155 |      28214
82 |        153 |      28367
83 |        151 |      28518
84 |        149 |      28667
85 |        147 |      28814
86 |        146 |      28960
87 |        144 |      29104
88 |        142 |      29246
89 |        141 |      29387
90 |        139 |      29526
91 |        138 |      29664
92 |        136 |      29800
93 |        135 |      29935
94 |        133 |      30068
95 |        132 |      30200
96 |        130 |      30330
97 |        129 |      30459
98 |        128 |      30587
99 |        126 |      30713
100|        125 |      30838
101|        124 |      30962
102|        124 |      31086
103|        124 |      31210
104|        124 |      31334
105|        124 |      31458
106|        124 |      31582
107|        124 |      31706
108|        124 |      31830
109|        124 |      31954
110|        124 |      32078
111|        124 |      32202
112|        124 |      32326
113|        124 |      32450
114|        124 |      32574
115|        124 |      32698
116|        124 |      32822
117|        124 |      32946
118|        124 |      33070
119|        124 |      33194
120|        124 |      33318
121|        124 |      33442
122|        124 |      33566
123|        124 |      33690
124|        124 |      33814
125|        124 |      33938
126|        124 |      34062
127|        124 |      34186
128|        124 |      34310
129|        124 |      34434
130|        124 |      34558
131|        124 |      34682
132|        124 |      34806
133|        124 |      34930
134|        124 |      35054
135|        124 |      35178
136|        124 |      35302
137|        124 |      35426
138|        124 |      35550
139|        124 |      35674
140|        124 |      35798
141|        124 |      35922
142|        124 |      36046
143|        124 |      36170
144|        124 |      36294
145|        124 |      36418
146|        124 |      36542
147|        124 |      36666
148|        124 |      36790
149|        124 |      36914
150|        124 |      37038
151|        124 |      37162
152|        124 |      37286
153|        124 |      37410
154|        124 |      37534
155|        124 |      37658
156|        124 |      37782
157|        124 |      37906
158|        124 |      38030
159|        124 |      38154
160|        124 |      38278
161|        124 |      38402
162|        124 |      38526
163|        124 |      38650
164|        124 |      38774
165|        124 |      38898
166|        124 |      39022
167|        124 |      39146
168|        124 |      39270
169|        124 |      39394
170|        124 |      39518
171|        124 |      39642
172|        124 |      39766
173|        124 |      39890
174|        124 |      40014
175|        124 |      40138
176|        124 |      40262
177|        124 |      40386
178|        124 |      40510
179|        124 |      40634
180|        124 |      40758
181|        124 |      40882
182|        124 |      41006
183|        124 |      41130
184|        124 |      41254
185|        124 |      41378
186|        124 |      41502
187|        124 |      41626
188|        124 |      41750
189|        124 |      41874
190|        124 |      41998
191|        124 |      42122
192|        124 |      42246
193|        124 |      42370
194|        124 |      42494
195|        124 |      42618
196|        124 |      42742
197|        124 |      42866
198|        124 |      42990
199|        124 |      43114
200|        124 |      43238

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 07:19 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2755
Registered: October 2004
Location: Third star to the left
I guess this is meant to give the amount of minerals to extract to get from the initial minconc to the end one? The code seems somewhat incomplete, I'm afraid. Also, is there any hope that it's more accurate than other known formulas/tables? Confused



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 12:10 Go to previous messageGo to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
Quote:

I guess this is meant to give the amount of minerals to extract to get from the initial minconc to the end one?

Yes. It's purpose is to give mineral extraction needed to drop by 1% concentration and to give the total mineral extraction needed to drop all the way to 1% concentration (fully depleted).
Quote:


The code seems somewhat incomplete, I'm afraid.

I'm just concerned about it getting the right numbers. The code is demonstration code and would need a little work to actually be useful in a program. Concentrations 1-4%, which are omitted from the program, are just hardcoded as 0, 2000, 1000, 1000.
Quote:

Also, is there any hope that it's more accurate than other known formulas/tables?

It's only as good as the formula I based it on. I'm confident I reproduced the formula accurately, but not sure if the formula itself is accurate.


[Updated on: Tue, 02 October 2007 12:15]

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 12:20 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2755
Registered: October 2004
Location: Third star to the left
yartrebo wrote on Tue, 02 October 2007 18:10

Could you elaborate. It seems pretty complete to me. If you're talking about concentrations 1, 2, 3, and 4, the numbers are 0, 2000, 1000, and 1000 respectively, and the table reflects that.


Yep, I wondered where your code was outputting those nicely rounded values, as well as the table header. It seems I also misread at least one of your loops, so now it all seems quite OK to me. Sherlock Whip


Quote:

It's only as good as the formula I based it on. I'm confident I reproduced the formula accurately, but not sure if the formula itself is accurate.


AFAIK, the formula stumbles on the lower minconcs, just where you've decided to use those nice fixed values. There's also been doubts about its accuracy if minconc>100. Deal

I'm personally wary of anything that's not pure integer math where Stars! formulas are concerned, since it would not be the 1st time that the *real* calculations for seemingly complex results were actually based on just integer ops. Twisted Evil

Wish I could think of a better formula than the currently "best", but there's still hope. Rolling Eyes



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 13:22 Go to previous messageGo to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
Quote:

Wish I could think of a better formula than the currently "best", but there's still hope.


I'm going to give it a try. Mineral depletion is a very important part of game balance, and it's worthwhile assuring that the formula is at least reasonably close.

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 13:55 Go to previous messageGo to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
I've given it a try and the first thing I found that is running a single mine on a planet is horribly inefficient. I got less than 100kT of minerals per % concentration in the 100%+ range. With 30 mines, the numbers come out pretty close to the formula.

What this means is that stars! seems to round up your mineral usage for the turn, perhaps to the next whole kT.

Seeing how this bug makes it near impossible to get accurate high-resolution data (ie., 1 mine run for thousands of turns), I think I'm going to go with the formula posted above and not replicate the bug. Mineral production will be kept to the nearest thousandth, as will depletion (should be 100% accurate since concentration comes in hundredths and mine efficiency in tenths).

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 17:46 Go to previous messageGo to next message
PaulCr

 
Chief Warrant Officer 3
Stars! V.I.P

Messages: 187
Registered: February 2007
Location: An Island that kinda look...
With regard to mineral concentrations. I've decoded most of the values used to store data in relation to planets and mineral concentration depletion is stored as a single byte. Not actually tried to decode how it works but if you want to take a look yourself you could use the unencrypted patched version of the game and use the xml parser on my website to look at your homeworld in your .m file and how mining effects mineral concentrations. You could look at the .hst since the same structure is used for your inhabited planets as it uses but it includes every planet so looking at the .m file is simpler especially if you remove everything else, ie fleets, designs, battle plans etc.
No byte is used if there has been no depletion and from what I remember it is a decreasing value, ie counting down to 0 rather than up.

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 22:27 Go to previous messageGo to next message
LEit is currently offline LEit

 
Lt. Commander

Messages: 879
Registered: April 2003
Location: CT
Here is where mineral concentrations are reduced. I haven't looked through what you've done and compared it to what this routine does to see how similar or different they are.

void Planet::Mine(long mines, const Player * miner)
{
	if (mines == 0)
		return;

	long rate;
	if (GetOwner() == NULL)
		rate = 10;
	else
		rate = GetOwner()->MineRate();

	for (long mineral = 0; mineral < Rules::MaxMinType; ++mineral) {
		long conc;
		if (mHomeWorld && miner == GetOwner())
			conc = max(mMinConc[mineral], Rules::GetConstant("MineralHWMinimum"));
		else
			conc = mMinConc[mineral];

		mContains[mineral] += (conc * mines * rate + 500) / 10 / 100;
		mMinMined[mineral] += mines;
		long minesper = Rules::GetConstant("MineralDecayFactor") / mMinConc[mineral] / mMinConc[mineral];
		if (mMinMined[mineral] > minesper) {
			mMinConc[mineral] -= mMinMined[mineral] / minesper;
			if (mMinConc[mineral] < Rules::GetConstant("MineralMinimum"))
				mMinConc[mineral] = Rules::GetConstant("MineralMinimum");

			mMinMined[mineral] %= minesper;
		}
	}
}



- LEit

Report message to a moderator

Re: Detailed mineral mining table Tue, 02 October 2007 23:36 Go to previous messageGo to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
LEit, I'm looking at your code and it doesn't seem to account for the very complex nature of depletion.

You code seems to imply that depletion is inverse square wrt mine*years. I believe that only holds true for the range 30 < concentration < 100. For concentrations below 30 and above 100, the formula is different (depletion is slower than expected over 100, and faster than expected below 30).

While the code I'm working with isn't 100% perfect and could be improved, it is pretty close and should be a good springboard towards the real formula.

PS: My program and table uses actual minerals mined instead of mine*years. Do keep this in mind when comparing our programs.

Report message to a moderator

Re: Detailed mineral mining table Wed, 03 October 2007 03:07 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2755
Registered: October 2004
Location: Third star to the left
Hi,

I've searched a bit, but cannot find enough hard data on just exactly how minconcs are reduced thru time (with, say, 10 and 100 mines) from 100 to 1, as well as exactly how much minerals are mined at every step. Sherlock Sad

I wonder if a testbed consisting of, say, one race with standard mines, and another with, say, double mining eff, and a third with the same standard eff but double mines operated in a maxmins universe would be worth running it. Confused Whip



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Detailed mineral mining table Wed, 03 October 2007 14:11 Go to previous messageGo to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
I've run testbeds with 100 and 1000 mines (eff 10). My results are as follows:
original formula is accurate for conc >= 30 and conc <= 100.
proper constant for 100 < conc is 125 kT (minor change).
proper constant for 4 < conc < 30 is: 480 kT/level
levels 2, 3, and 4 are 1,200 kT/level

Here is the updated formula:
con    | minerals/level depletion
  100+ | 125 kT
30-100 | 12,500kT * ln(n / (n - 1))
 5-29  | 480 kT
 2-4   | 1,200 kT
   1   | infinite


It appears to be accurate to +/- 100 kT for depletion from 100 conc to 1 using large numbers of mines (at least 100).


[Updated on: Wed, 03 October 2007 14:29]

Report message to a moderator

Re: Detailed mineral mining table Wed, 03 October 2007 14:54 Go to previous messageGo to next message
yartrebo is currently offline yartrebo

 
Petty Officer 3rd Class

Messages: 43
Registered: July 2006
Location: North America
I've been looking at those suspiciously similar numbers (125kT for 100+, and the 12,500kT factor for the ln() formula), and it's hit me that the ln() is not needed.

The derivative of ln(x) is quite simply 1/x, and 12,500/100 equals exactly 125kT.

With this in mind, I've revised the formula and it now has no floating point math needed:
con    | minerals/level depletion
  100+ | 125 kT
30-100 | 12,500kT / con
 5-29  | 480 kT
 2-4   | 1,200 kT
   1   | infinite

Report message to a moderator

Re: Detailed mineral mining table Wed, 03 October 2007 19:43 Go to previous message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2755
Registered: October 2004
Location: Third star to the left
yartrebo wrote on Wed, 03 October 2007 20:54

I've been looking at those suspiciously similar numbers (125kT for 100+, and the 12,500kT factor for the ln() formula), and it's hit me that the ln() is not needed.

The derivative of ln(x) is quite simply 1/x, and 12,500/100 equals exactly 125kT.

With this in mind, I've revised the formula and it now has no floating point math needed:



Now *that* is extremely interesting! Sherlock Very Happy

It makes a lot of sense too, given the Jeffs' penchant for all-integer math. Twisted Evil Teleport



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Previous Topic: Rebuilding Race Traits
Next Topic: Race Wizard almost done (but not quite)
Goto Forum:
  


Current Time: Sun May 19 04:41:53 EDT 2019