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

Same seed on different platforms do not give same map #294

Closed
Vezzra opened this issue Aug 16, 2015 · 15 comments
Closed

Same seed on different platforms do not give same map #294

Vezzra opened this issue Aug 16, 2015 · 15 comments
Assignees
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game.

Comments

@Vezzra
Copy link
Member

Vezzra commented Aug 16, 2015

This issue has been brought up here.

Apparently, on Linux we get different maps from those generated on Windows and OSX with the same seed. Below is a screenshot I did of a default quickstart game with the 2015-08-10.2c00daa pre-release test build:

rel045quickstart

On Windows I get exactly the same map.

@MatGB: Pls, can you compare this screenshot to the maps you get with a default quickstart game on your Linux and Windows systems when using the above build?

@Dilvish-fo: As you're on Linux too, can you do the same on your system?

Everyone else who's on Linux, if you can test this, please do! I really want to get this issue solved for 0.4.5.

@Vezzra Vezzra added the category:bug The Issue/PR describes or solves a perceived malfunction within the game. label Aug 16, 2015
@Vezzra Vezzra added this to the v0.4.5 milestone Aug 16, 2015
@Morlic-fo
Copy link
Contributor

I would expect the following to be the issue:
We pass a string as seed which then is hashed in some way which generally is platform dependent.

The solution in that case would be to use an integer seed instead.

@Vezzra
Copy link
Member Author

Vezzra commented Aug 16, 2015

The code section in question is:

// Initialize RNG with provided seed to get reproducible universes
int seed = 0;
try {
    seed = boost::lexical_cast<unsigned int>(GetGalaxySetupData().m_seed);
} catch (...) {
    try {
        boost::hash<std::string> string_hash;
        std::size_t h = string_hash(GetGalaxySetupData().m_seed);
        seed = static_cast<unsigned int>(h);
    } catch (...) {}
}

Does that really yield different hashes on different platforms? I thought this code is supposed to provide platform independent results. And even if, apparently the problem already arises with seed 0, which is an integer seed anyway?

@MatGB
Copy link
Member

MatGB commented Aug 16, 2015

I've had a really busy weekend and am exhausted, but I thought I'd just check in and answer the basic question.

As far as I can see, and haven't had time to test on Windows, I get the same layout of systems and placements, but the starting positions for all the empires are completely different. I need to check and confirm this but the pictures posted by both you and @Deepsloth look to be the same map, but I start near the top (where Enif Alpha is on your pic), and there's an AI (Etty) that starts at Grotto. The systems definitely have different names. Polaris has a toxic world in, and the system on your map that's deep space two jumps to the right towards Cursa Alpha has a Sentinel guarding an Ancient Ruins.

So we're getting the same basic system layout, but different names, placements and similar.

@raptor
Copy link

raptor commented Aug 16, 2015

32/64 bit differences occur in boost::hash. See here:

https://stackoverflow.com/questions/17426493/get-32-bit-hash-value-from-boosthash

(Sorry for the drive-by comment)

@Vezzra
Copy link
Member Author

Vezzra commented Aug 17, 2015

Created a PR with an attemped fix, please test: #297

@Vezzra
Copy link
Member Author

Vezzra commented Aug 18, 2015

Created a PR in another attempt to fix the issue: #298. Pls test.

@Vezzra
Copy link
Member Author

Vezzra commented Aug 18, 2015

As mentioned in the discussion on PR #297, apparently some galaxy shapes do give identical maps across platforms, but not all. Elliptical seems to be fine, while spiral gives different maps. I've looked at the code for these two, and the only difference as far as use of rng functions are concerned is that spiral uses a function for gauss distribution, which elliptical does not.

Another shape that uses this function for gauss distribution is ring. Here is a screenshot of seed 0 ring galaxy with all other settings on default (OSX):

seed0_ring

Please compare that to the map you get on your systems (Linux particularly).

@Vezzra Vezzra modified the milestones: Next release, v0.4.5 Aug 18, 2015
@geoffthemedio
Copy link
Member

With the latest master, MSVC2013:

ring0_galaxy

@Vezzra
Copy link
Member Author

Vezzra commented Sep 18, 2015

Seems to be identical, but IIRC Mac and Win have always been. It's on Linux where we get different results... can someone of our Liinux folks provide a screeshot (seed 0, ring, all other settings on default) for comparison?

@raptor
Copy link

raptor commented Sep 18, 2015

Linux (openSUSE 13.2 x86_64) screenshot with those settings at commit cb7b5c0:
snapshot6

@Vezzra
Copy link
Member Author

Vezzra commented Sep 20, 2015

Yep, that further confirms my suspicion - it's the function for gauss distribution used in the C++ code that apparently yields different results on Linux. Well, I'm going to migrate the other galaxy map generator functions to Python, that should take care of the issue.

@Vezzra
Copy link
Member Author

Vezzra commented Sep 20, 2015

After porting the rest of the galaxy shapes to Python, a seed 0 ring galaxy with all other settings on default looks like this on OSX (commit a1b8973):

seed0_ring

Please post screenshots from other platforms (especially Linux) for the same settings.

@Vezzra Vezzra self-assigned this Sep 20, 2015
@raptor
Copy link

raptor commented Sep 20, 2015

Same Linux system, commit efaf3cf:

snapshot7

@geoffthemedio
Copy link
Member

ring150

@Vezzra
Copy link
Member Author

Vezzra commented Sep 21, 2015

Very good. So, I consider the problem solved so far and will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game.
Projects
None yet
Development

No branches or pull requests

5 participants