Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! 2.6/7 » The Bar » Stars 3
Re: Stars 3 Fri, 06 June 2014 13:37 Go to previous messageGo to next message
theval is currently offline theval

 
Petty Officer 3rd Class

Messages: 43
Registered: May 2014
mrvan wrote on Thu, 05 June 2014 22:23
No luck Sad

http://i.imgur.com/jRHkY9G.png


Current build for windows. Available here:
https://drive.google.com/file/d/0B75-6sJwHlUyTDVna1JvZDZkRWs /edit?usp=sharing

Report message to a moderator

Re: Stars 3 Fri, 06 June 2014 15:32 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
theval wrote on Fri, 06 June 2014 13:37
mrvan wrote on Thu, 05 June 2014 22:23
No luck Sad

http://i.imgur.com/jRHkY9G.png


Current build for windows. Available here:
https://drive.google.com/file/d/0B75-6sJwHlUyTDVna1JvZDZkRWs /edit?usp=sharing


Which part of that screenshot made you think I was using windows? Wink

It's ok, we're not even near anywhere where we need to check out compatibility.

Report message to a moderator

Re: Stars 3 Fri, 06 June 2014 15:46 Go to previous messageGo to next message
theval is currently offline theval

 
Petty Officer 3rd Class

Messages: 43
Registered: May 2014
mrvan wrote on Fri, 06 June 2014 21:32

Which part of that screenshot made you think I was using windows? Wink


None. This is for those who use Windows and are curious about the progress. This is also for myself to check how difficult it is to get a Windows build.

mrvan wrote on Fri, 06 June 2014 21:32
It's ok, we're not even near anywhere where we need to check out compatibility.


True.


Report message to a moderator

Re: Stars 3 Fri, 06 June 2014 18:19 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
I added mining and a get_resources function.

My direct todo-list:
- implement production of planetary installations
- setup an 'integration test'

Questions on current code:
- As always, please check my unit tests and algorithms
- To mimic stars! behaviour, I had to set factory resources to round up production. Since stars! seems to round down everywhere, this strikes me as quite odd, and the freestars code (Planet.cpp +888) also just uses integer math, and even seems to round down factory and population production separately.

Test case: start a new game as humanoids but with factory efficiency, produce two factories, end turn. You now have 28.7k pop and 12 factories, which should produce 28.7 + 12*.9 = 39.5 resources, which matches the 39 displayed by stars!
End turn again. You now have 33k pop and 12 factories. This should yield 33 + 12*.9 = 43.8 resources, but stars! reports 44.
So, it seems that pop production is rounded down, but factory production is rounded up.

This is matched on a new planet: If I colonize a new planet (ie no factories), I get 1 resource for pop up to 1900, 2 up to 2900, etc; so it's rounded down with a minimum of 1. If I build a single factory (which should yield .9 resources) I get 2 resources for population up to 1900. With 10k pop and 8 factories, I get 18 resources, while 10+8*.9=17.2.


The relevant Planet.cpp code seems to not capture this:

Res = facts * GetOwner()->FactoryRate() / 10;
Res += pop / GetOwner()->PopEfficiency();

Since res is long, it is rounded down after computing factory resources and again after computing population resources. So, for the 28.7k pop + 12 factories you would get

Res = 12 * 9 / 10 = 10.8 --> 10 (long)
Res += 28700 / 1000 -> Res += 28.7 -> Res = 38 (compared to stars! reporting 39)

So, am I correct that factory production is rounded up (and hence is the freestars implementation inconsistent with stars!?)

Questions for production:
- Is tech gain processed immediately, i.e. does order of production matter such that if planet 3 researches enough for a new tech, planet 4 produces with reduced costs due to miniaturizaion? If so, I assume planets are processed in order of planet ID?
- Am I correct that if you cannot finish a (non-autoqueue) item due to lack of minerals, you produce N% such that the lowest mineral is depleted, and leftover resources go to research?





[Updated on: Fri, 06 June 2014 18:21]

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 04:38 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
mrvan wrote on Sat, 07 June 2014 00:19
I added mining and a get_resources function.

The mining code doesn't seem to include mineral depletion? Also, are ARs and remoteminers handled? Sherlock

Question: there's a way to "profile" python, I hope, and so check if a particular implementation is particularly fast or slow, yes? Work at computer


Quote:
So, am I correct that factory production is rounded up (and hence is the freestars implementation inconsistent with stars!?)

Pretty likely, as recently seen in this Academy thread (toward the end).

Freestars coders did their own tests (as comments show in some places) but this one might have escaped them. Whip

Quote:
Questions for production:
- Is tech gain processed immediately, i.e. does order of production matter such that if planet 3 researches enough for a new tech, planet 4 produces with reduced costs due to miniaturizaion? If so, I assume planets are processed in order of planet ID?
- Am I correct that if you cannot finish a (non-autoqueue) item due to lack of minerals, you produce N% such that the lowest mineral is depleted, and leftover resources go to research?

In theory, yes and yes. Sherlock


[Updated on: Sat, 07 June 2014 04:41]




So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 05:18 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
@M.A. Thanks

I'm assuming remote mining is done in the fleet WP0 tasks, right (plus AR inhabited WP1)

Indeed, mining is quite simplistic now, I've added the "limitations". My current push is to get to a "playable" version, ie a version where you can play a baseline testbedding game, and hopefully convince some people to start using it for testbedding.

I looked at the freestars code for the depletion, and I found a lot of strange code in Planet::GetMiningVelocity that never seems to be called. Can anyone enlighten me on that?

The freestars code for mineral depletion seems to be:

		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;
		}


So, the amount of mines needed to deplete a mineral is given by MineralDecayFactor=1500000 / conc^2. For conc 100, this is 150.
Then, there seems to be a persistent counter mMinMined to keep track of "fractional depletion", ie if the decay factor is 150 and we have 250 mines, it is depleted by 1 and the counter is set to 250 % 150 = 100. Next turn, minesper is 153, and we've "mined" 250 plus 100 remainder = 350, so we deplete by 2 and counter is now 350 % 153 = 44.

For remote mining, it seems that a mining module with max 18kt is simply processed as 18 mines at mining efficiency 10, so the 18 max is not actually the max if concentration > 100. Is that correct? Also, what happens if a player mines a planet inhabited by a different AR?


Edit:
Quote:
Question: there's a way to "profile" python, I hope, and so check if a particular implementation is particularly fast or slow, yes?


Sure. I usually do old fashioned profiling (record time, call function A N times, print time difference), which is very easy to do if you have separate functions, as in the current engine setup. You can also do more advanced profiling, which requires a bit more effort to set up, but can show you where the bottlenecks are in a complex program. See https://docs.python.org/3/library/profile.html




[Updated on: Sat, 07 June 2014 05:23]

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 06:04 Go to previous messageGo to next message
XAPBob is currently offline XAPBob

 
Lt. Commander

Messages: 957
Registered: August 2012
Remotes (and AR intrinsic?) are always mine efficiency 10 for depletion.

Might be an interesting change to have OBRM races rm @ 7 and ARM races at 15?

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 06:13 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
Yeah that's what I figured. Interestingly, the freestars code uses the owner's rate or 10 if no planet owner (=remote mining), which relies on AR always having mining efficiency 10.

7/10/15 is probably a bit too much, but some parameters might be interesting. Right now there is hardly a good reason to take ARM except for gateable superbugs and the small startup speed increase for AR. It would be interesting to prop up ARM for other races although boosting the mineral fountain might not be what we need, so maybe it needs to be balanced somehow for late-game AR. Perhaps decreasing super miner efficiency by the same factor as the ARM efficiency bonus? That way, resource fountain output it identical (assuming it uses superbugs), but ARM gets the additional bonuses of slower depletion and better "normal" mining mining modules.

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 07:20 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
I've added some simplistic production code.

At the moment, you can only build factories and mines (and actually only factories are tested), and there is no fractional completion; but I ran out of stars time for the moment Sad

What I find strange is how fractional production works in stars! I would have expected 50% to mean that 50% of resources and minerals are paid, so completing it costs 50% of resources, 50% of iron etc.

However, a very simplistic test on a new (red) world shows something subtly different. I set factory cost to 9 and planetary production to 3 to see how rounding is handled. Planet has 0 mines and so mining rate 0.

Turn 0: germanium 13
Turn 1: germanium 12kt, factory complete 43%.
Turn 2: germanium 10kt, factory complete 76%
Turn 3: germanium 9kt, factory complete

What I don't understand is where the 43% comes from. The planet only has production 3, so it can produce 33% of resources. It has paid 1kt germanium, so 25% of germanium. How does that add up to 43%?

I could also imagine that it records "cost remaining" instead of %complete, but the recent academy thread suggests otherwise and anyway if remaining costs are 6 out of 9 resources and 3 out of 4 germanium I still don't see where to get 43%.

Another question: How does it know to pay 1 germanium in the 1st and 3d turn of production and 2 in the second, if all it records is % complete?


Edit: setting research tax to 100% and queuing another factory (completion time: never) gives 10% done after end turn without any germanium consumed. However, queuing a ship in the main starbase with 100% tax gives 0% done???

Edit2: building a cost 5 mine on a 2 production world gives completion percentages 59% - 99% - done. With zero production it shows 19%. So it seems that actual production complete makes sense in both factory and mine case, with a "display bonus" of 10 and 19%, respectively. So the remaining questions are:

- what is the function or reason of the display bonus?
- how are fractional mineral completions dealt with? I guess a possibility is that it calculates mineral cost at new% - old% and pays the difference, e.g. for the factory case:

Turn 1: 0% -> 33%. Germanium cost for 0%=0, for 33%=1.333=1, so pay 1
Turn 2: 33% -> 67%. Germanium cost for 33%=1, for 67%=2.667=3, so pay 2
Turn 3: 67% -> 100%. Cost 4-3 = 1

However, a remaining question is how it gets to 67% from 33% plus 3 production. I guess it calculates new percentage as percentage given total invested resources, so after second round invested resources are 3 (33% of 9) plus 3 (current production) = 6, which is 6/9=66.6667->67 by rounding to nearest instead of rounding down?

In a sense, this means that invested resources are recalculated from the percentage, added to available resources, and that is used to calculate new percentage. Does that make sense?








[Updated on: Sat, 07 June 2014 07:46]

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 07:47 Go to previous messageGo to next message
theval is currently offline theval

 
Petty Officer 3rd Class

Messages: 43
Registered: May 2014
m.a@stars wrote on Thu, 05 June 2014 20:50
I can provide stories. Twisted Evil


Sent you an email with instructions. Looking forward to getting some interesting content!

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 08:07 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
mrvan wrote on Sat, 07 June 2014 11:18
I'm assuming remote mining is done in the fleet WP0 tasks, right (plus AR inhabited WP1)

Well, as far as anyone knows, remotes mine after WP1 colonization and before Production, so I guess they could be handled that way (and non-SD minelayers too?) Whip


Quote:
Indeed, mining is quite simplistic now, I've added the "limitations". My current push is to get to a "playable" version, ie a version where you can play a baseline testbedding game, and hopefully convince some people to start using it for testbedding.

Yay! Nod


Quote:
I looked at the freestars code for the depletion, and I found a lot of strange code in Planet::GetMiningVelocity that never seems to be called. Can anyone enlighten me on that?

Hmmmm, it looks weird, but some ppl talk about "mine equivalents" when studying depletion, and that same concept applies to remote miners, so perhaps it was cleverly coded that way. I wonder if they did tests confirming their approach. Sherlock


Quote:
Also, what happens if a player mines a planet inhabited by a different AR?

All dimensions explode, likely. Pirate


Quote:
I usually do old fashioned profiling (record time, call function A N times, print time difference), which is very easy to do if you have separate functions, as in the current engine setup.

Heh, that's how I usually do it too, though some times it's hard to tell what code performs best or why something is slow. Hit Computer



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 08:18 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
mrvan wrote on Sat, 07 June 2014 13:20
In a sense, this means that invested resources are recalculated from the percentage, added to available resources, and that is used to calculate new percentage. Does that make sense?

As much sense as plenty other "wrinkles" all over the code. I wonder if your "3 Res" planet is actually 3, or something close to 3 that's nudging the equations around. Sherlock



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 08:19 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
theval wrote on Sat, 07 June 2014 13:47
Sent you an email with instructions. Looking forward to getting some interesting content!

Looking forward to receiving it! Rolling Eyes



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 08:26 Go to previous messageGo to next message
theval is currently offline theval

 
Petty Officer 3rd Class

Messages: 43
Registered: May 2014
m.a@stars wrote on Sat, 07 June 2014 14:19
theval wrote on Sat, 07 June 2014 13:47
Sent you an email with instructions. Looking forward to getting some interesting content!

Looking forward to receiving it! Rolling Eyes


This means that something went wrong. I sent it quite a while ago. Are you sure you haven't got anything? Can you PM me something?

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 09:00 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
m.a@stars wrote on Sat, 07 June 2014 08:18
mrvan wrote on Sat, 07 June 2014 13:20
In a sense, this means that invested resources are recalculated from the percentage, added to available resources, and that is used to calculate new percentage. Does that make sense?

As much sense as plenty other "wrinkles" all over the code. I wonder if your "3 Res" planet is actually 3, or something close to 3 that's nudging the equations around. Sherlock


I did a limited inspection of ProdOrder.cpp (around line 349) and this indeed seems to be how freestars does it, as in, they record partial production for resources+minerals separately in a Cost object, and add those resoruces/minerals to the available stockpile.

I'm inclined to skip this for now, and move to ship production, at first limited to preset designs, and then move over to a first attempt at an HTML5 client.

Good things to do for contributors, in order of increasing complexity:

- add mineral depletion
- add partial production
- add defenses and terraforming
- add research

Any takers? Smile

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 09:29 Go to previous messageGo to next message
XAPBob is currently offline XAPBob

 
Lt. Commander

Messages: 957
Registered: August 2012
I'll take on depletion. Probably not today though Wink

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 09:33 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
Cool. No worries, I also don't have any time left today, although I might try to setup the integration test I've been talking about later today so we can test consistency between the various modules...

Let me know (here or on chat) if you need any help cloning the repo and getting the unit tests up and running.


[Updated on: Sat, 07 June 2014 09:48]

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 18:39 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
I've added an integration test. It basically consists of running a complete turn (as far as defined) and checking the results.

The purpose of this test is to make sure that (1) the universe/orders respresentations are consistent between the different engine modules, and (2) that any (future) subtle interactions between modules can be tested. It is not intended to be a feature complete check of every module (that is what the unit tests are for).

As secondary benefit is that it is an example of a compelte universe/orders representation.

When editing/creating engine modules, please update/create both the relevant unit test and the integration test!


[Updated on: Sat, 07 June 2014 18:39]

Report message to a moderator

Re: Stars 3 Sat, 07 June 2014 22:59 Go to previous messageGo to next message
skoormit is currently offline skoormit

 
Lieutenant

Messages: 665
Registered: July 2008
Location: Alabama
mrvan wrote on Sat, 07 June 2014 06:20

I set factory cost to 9 and planetary production to 3 to see how rounding is handled. Planet has 0 mines and so mining rate 0.

Turn 0: germanium 13
Turn 1: germanium 12kt, factory complete 43%.
Turn 2: germanium 10kt, factory complete 76%
Turn 3: germanium 9kt, factory complete

What I don't understand is where the 43% comes from.


Stars does an odd thing when displaying % complete. It figures out what % complete would be if you had spent one more resource, then subtracts 1%.

In this case, you spent 3 resources.
Had you spent 4, you would have been 44% complete.
44% - 1% = 43%.





What we need's a few good taters.

Report message to a moderator

Re: Stars 3 Sun, 08 June 2014 04:41 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
Interesting! Now why would they do that...?

Is that a behaviour we would want to mimic?

Report message to a moderator

Re: Stars 3 Sun, 08 June 2014 04:57 Go to previous messageGo to next message
XAPBob is currently offline XAPBob

 
Lt. Commander

Messages: 957
Registered: August 2012
I'd want to count resources spent. But that fails to deal with minit.

Hmm...

Report message to a moderator

Re: Stars 3 Sun, 08 June 2014 05:14 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
mrvan wrote on Sun, 08 June 2014 10:41
Interesting! Now why would they do that...?

Is that a behaviour we would want to mimic?

Perhaps it's a relic of earlier versions. Who knows. Confused

It reminds me of the flawed "fuel usage" guesstimator, and I don't think anyone will miss these flaws, as long as the underlying "real" costs are calculated exactly. Lurking



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars 3 Sun, 08 June 2014 06:01 Go to previous messageGo to next message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
Agree, so let's just remember exact 'resources spent', round up all fractions in spending resources*, and display the % rounded down, so we also don't get funny stuff like reported in the academy thread

*) What I mean is that if you want to produce something for 1000 iron and 1500 resources, and you have 500 production and 333 iron in the first round, want to spend math.ceil(1500*.333)=500 resources, and not int(1500*.333)=499, because then you can never finish it in three turns even if you get 334 iron in the last round...

Report message to a moderator

Re: Stars 3 Sun, 08 June 2014 09:24 Go to previous messageGo to next message
XAPBob is currently offline XAPBob

 
Lt. Commander

Messages: 957
Registered: August 2012
Does this mean that costs are fixed when you *start* building something - not when you queue it up, byut as each item is built it's costs are fixed.

So if I have a super weapon on a scout that costs 100 res this turn and I spend 60 res. Then I research 25 more levels of weaponry, with BET, and so the weapon now only costs 15 res - is it instantly built - or are we still building it using the original technology (i.e. mini doesn't affect part-built items. Obviously if we had 5 queued, then only the first would use old tech...

Report message to a moderator

Re: Stars 3 Sun, 08 June 2014 10:35 Go to previous messageGo to previous message
mrvan is currently offline mrvan

 
Officer Cadet 1st Year

Messages: 220
Registered: May 2014
I think the sensible way is to build it using the tech of the level it is finished in. From what I see in the freestars source code, that is also how they do it.

So in your example, you spend 60 res on your scout, next turn it has remembered 60 resources, and you get it for free. We should check to make sure that you don't get free resources, ie cost is minimized to amount spent already.

Report message to a moderator

Previous Topic: Stars! on a tablet ??
Next Topic: Replacement needed.
Goto Forum:
  


Current Time: Tue Apr 23 16:31:49 EDT 2024