Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed colony buildings to use ShortestPath rather than JumpsBetween, #1

Closed
wants to merge 1 commit into from

Conversation

Dilvish-fo
Copy link
Owner

using a ship speed of 80 as reference, and with a slight exponential reduction meant to roughly account for very large empires being likely to have faster ships

this content requires recent updates to the FO executables

…, using a ship speed of 80 as reference, and with a slight exponential reduction meant to roughly account for very large empires being likely to have faster ships
@Dilvish-fo
Copy link
Owner Author

It's hardly fair to complain this is not exact when it was explicitly described as _roughly_ accounting for increasing ship speeds. I did consider a fairly exact correspondence by taking a max speed of all ships owned by the empire; I passed on that to streamline the calculation but it might not really be all that costly of a calculation so we could give that a try. I don't like the idea of something that just scales up over time regardless of what the empire has accomplished or not accomplished. The distance involved at least was very likely to have a correlation with how much the empire had advanced. The exponential also allowed for a slightly better then flat 0.06 improvement as the distances got larger, though the effect was not huge. If you experiment with any other calculations, keep in mind that a range of x<60 is essentially meaningless for this calc, due to the base speed and the floor of 5 turns the calculation only really matters if x is in the hundreds.

I'll also take a stab at using the speed statistic from the empire's actual ships.

@Morlic-fo
Copy link

Let me rephrase it then: I do not think the exponent you added is enough to make the new colonization approach on par with using colony ships as it scales too weakly.

I'm not sure why you think x is supposed to be in the hundreds. Maybe you are talking about ShortestDistance which is indeed to be in the hundreds, however I discussed x=ShortestDistance/80 as stated in the previous comment. x is thus pretty much equivalent to number of turns to build (asymptotically) and thus obviously numbers for x<60 are highly relevant.

I made some mistake though in the calculation and values are off by a factor of 80^0.025 or 11%, but the conclusion remains the same. The effect is an average reduction of 7% of build time which does not compare to a simple ship upgrade which corresponds quickly to 20-50%. 7% is not even a rough approximation of that value but quite subpar. For huge distances, the old, microintensive way thus would quickly outshine it. If we are to keep your current approach, I think it would be a good idea to decrease the exponent some more.

Considering the actual speed seems like a good idea if you manage to script that up. Maybe another idea could be to base the speed on (engine) techs? Let's say, for example, unlocking a new engine tech gives a bonus of 20.

@Dilvish-fo
Copy link
Owner Author

Ah, my apologies for overlooking/forgetting the normalized distance comment. My math still works out a bit differently than yours though-- for example, for a total distance of 600, the exponential reduction is over 9%, and at the distances it seems likely Magnate was contemplating swapping to ships for (~15 turns, or probably 1000 -1200+) the exponential is a bit over 10% reduction. Keep in mind I also gave a starting bonus to speed. It may still fall a bit short of the actual ships that people would build, and it's certainly an option to consider increasing the exponent.

Another thing to keep in mind is that loading up a colony ship with advanced engines can add quite a bit to its cost, and don't think it was a design requirement that this necessarily match the fastest possible ship at no additional cost. Basing the reference speed on researched techs is a decent idea, though I don't know that it need to match the absolute strongest engines at no cost. I guess it would be possible to also have the cost go up in that case. I think I prefer the 'fastest actually owned ship' approach, but the techs is good to keep in mind as an alternative, and both approaches have their drawbacks.

Vezzra, this whole thing was really kind of your baby, so if you have any strong preferences I won't argue with you (or, at least not too much 😃).

@Morlic-fo
Copy link

Do you ceil the results in your math? This obviously makes the effect discontinuous in absolut terms and adds fluctuations in the relative effect. That is why I was approximating the result by some step function and so got the average improvement in the first place.

If you have a similar approach, I guess I will have to check my math again, maybe some other step function describes it more accurately.

@Dilvish-fo
Copy link
Owner Author

I thought we had already established this calculation only mattered for distances above 400 (5 x 80), and even at that low end the reduction is greater than 8.5% (and increases with distance), so to get an average of 7% it seems that at the very least you must have chosen an inappropriate range.

@Dilvish-fo
Copy link
Owner Author

Also (or instead), I think your normalization doesn't work well here: (x^y)/80 != (x/80)^y

@Morlic-fo
Copy link

Thats where the mentioned wrong factor came into play. I'll look again into my script to see what else could've went wrong...

@Dilvish-fo
Copy link
Owner Author

Ah, yes, ok. What about the ranges? I hadn't been doing this in a spreadsheet, but I have now and I'm seeing the same results as before. The spreadsheet does make it easier to play with forms of the adjustment, in the range of 400:2000 an equation of the form x +ax - bx^2 seems to work out pretty decent with a being 1E-3 and b being 3E-4, works up to a 40% reduction. But anyway I should just try scripting up the actual ship speed statistic, I suppose.

@Morlic-fo
Copy link

Seems like a random 2 showed up in my formula. Probably mistyped and as the CAS used automatically multiplies numerals and symbols, no error was given. Anyway, multiply my numbers by 2 and we got an agreement. So, sorry for the buzz.

(~12% still may be too low considering naked organics reaching that improvement very early on in the game though, but shouldn't matter much if you're scripting the ship idea anyway now).

@Vezzra
Copy link

Vezzra commented Apr 30, 2015

Vezzra, this whole thing was really kind of your baby, so if you have any strong preferences I won't argue with you (or, at least not too much 😃).

I think I'm finally getting around to this. I'm going to take a look at your adjustments, then I'll give you my feedback.

After I've recovered from a bit of math overload I suffered by reading the above exchange, that is 😉

@Dilvish-fo
Copy link
Owner Author

ok, just a little update-- the script adjustment using the max speed of any ships owned by the given empire appears to be working (i.e. doesn't crash, gives reasonable results, and doesn't seem to slow things down), although I still need to verify that after building the first super-fast ship the required build times for the buildings do indeed go down.

@Dilvish-fo
Copy link
Owner Author

Sorry to rush things just as you got involved, Vezzra, but the ship speed statistic seems to work out fine, and I am wanting to get this off my plate, so this last version is committed: 77764c1
You are of course still invited to make any further changes that look good to you.

@Dilvish-fo Dilvish-fo closed this May 1, 2015
@Dilvish-fo Dilvish-fo deleted the shortestpath_testing branch May 1, 2015 00:34
@Vezzra
Copy link

Vezzra commented May 1, 2015

Sorry to rush things just as you got involved, Vezzra

No problem 😉 However, seems in your hurry you overlooked a serious flaw in your approach. See this forum thread, lets continue the discussion there (as you can see, I've also moved your forum post on the topic there).

Morlic-fo pushed a commit that referenced this pull request Jan 14, 2017
Make AddressSanitizer happy.
==5832==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f602f2e2925 at pc 0x7f602e81ce91 bp 0x7ffcdd76f600 sp 0x7ffcdd76f5f0
READ of size 1 at 0x7f602f2e2925 thread T0
    #0 0x7f602e81ce90 in std::char_traits<char>::length(char const*) /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4/bits/char_traits.h:263
    #1 0x7f602e81ce90 in std::string::append(char const*) /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4/bits/basic_string.h:1025
    #2 0x7f602e81ce90 in std::string::operator+=(char const*) /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4/bits/basic_string.h:958
    #3 0x7f602e81ce90 in ProductionQueue::ProductionItem::Dump() const /mnt/another/srcs/GIT/freeorion/Empire/Empire.cpp:774
0x7f602f2e2925 is located 0 bytes to the right of global variable '*.LC128' from '/mnt/another/srcs/GIT/freeorion/Empire/Empire.cpp' (0x7f602f2e2920) of size 5
  '*.LC128' is ascii string 'id: '
0x7f602f2e2925 is located 59 bytes to the left of global variable '*.LC129' from '/mnt/another/srcs/GIT/freeorion/Empire/Empire.cpp' (0x7f602f2e2960) of size 27
  '*.LC129' is ascii string 'ProductionQueue::Element ('
SUMMARY: AddressSanitizer: global-buffer-overflow /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4/bits/char_traits.h:263 std::char_traits<char>::length(char const*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants