Skip to content

Conversation

@BenjaminAmos
Copy link
Contributor

@BenjaminAmos BenjaminAmos commented Feb 12, 2022

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::getSubtypesOf is 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 generic List<T> in GalaxyBuilder, 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

  • Start the game application
  • Create a new game.
  • Open the map to get a rough view of the system layout.
  • Exit the game application completely through the main menu.
  • Start the game application again.
  • Continue from your previous save.
  • Open the map and ensure that it contains an identical system layout to before.

Notes

  • With these changes, you will have to start a new game to have any new system/feature generators added subsequent to the world's creation included in the world generation process. The game should log an error if any generators are removed.

This change updates WorldConfig to contain the system generators and feature generators that were used to generate the system. The world configuration was changed to be held centrally in SolGame and is now used as the authoritive source of truth for world generation.

Also updated some occurences of publicly-facing ArrayList<T> methods to the more generic List<T>.
@BenjaminAmos BenjaminAmos force-pushed the deterministic-new-world-gen branch from 50cbf8c to acdfeae Compare June 22, 2022 20:01
@BenjaminAmos
Copy link
Contributor Author

@IsaiahBlanks, would you be interested in verifying this change? I'm not very familiar with the new world generation, so I might have made some mistakes somewhere.

@BenjaminAmos BenjaminAmos mentioned this pull request Jul 7, 2022
@BenjaminAmos
Copy link
Contributor Author

These changes appear to work and are an improvement over the previous behaviour, so I see no issues in merging this right away.

@BenjaminAmos BenjaminAmos merged commit 1c469bb into MovingBlocks:develop Oct 16, 2022
@BenjaminAmos BenjaminAmos deleted the deterministic-new-world-gen branch October 16, 2022 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant