fix(world): make new world generation deterministic #647
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When #607 was merged, it broke the determinism of world generation. This means that continuing an existing save would often end-up generating a completely different system than the one that was present when the game was saved. The precise reason for this issue is because the ordering of types returned by
ModuleEnvionment::getSubtypesOfis undefined. I often found that the exact ordering of types in the returned list changed every time the game was run. The galaxy generation code is very sensitive to the ordering of these lists.A simple solution to this problem would be to sort the lists by type name. This would not help though if additional feature generators were added later-on, since they could change the list ordering and size again. Because of this, I decided to save the generators used with the world configuration instead. This does mean that you will have to start a new game to see any new system/feature generators in use though.
I also updated some occurences of publicly-facing
ArrayList<T>methods to the more genericList<T>inGalaxyBuilder, since I was modifying that code anyway.It appears that some world generation tests were commented-out in #622. This pull request also restores those stubbed tests with working implementations again.
Testing
Notes