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

Planet density #5592

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Planet density #5592

merged 1 commit into from
Oct 9, 2023

Conversation

zonkmachine
Copy link
Member

@zonkmachine zonkmachine commented Jun 24, 2023

planetinfo

Randomize radius

* Randomize radius to +/- 20% to give the bodies some difference in surface gravity.
* Set an absolute limit of 5 g for habitability.
* Advice on gravity.
* Always build an orbiting station on inhabited worlds with a larger gravity (large
  currently being defined as over 1.07 g.
* New Planet info posts: 'Escape velocity' and 'Mean density'.
* Search and Rescue - Flavour 4 has extra text on dialogue when target planet is more
  than 1.2 g.

Addresses #5581. A quick way to alleviate the issue with planets between 1 and 200 earth masses all having 1.0g surface gravity.

@zonkmachine zonkmachine marked this pull request as draft June 24, 2023 16:42
@zonkmachine
Copy link
Member Author

I still don't fly spacecraft so this hasn't been tested in that regard.

@Zireael07
Copy link

Offtop: I <3 the planet name <3

@zonkmachine
Copy link
Member Author

Offtop: I <3 the planet name <3

I had to google that. You're into football?

@zonkmachine zonkmachine marked this pull request as ready for review June 25, 2023 16:02
@Zireael07
Copy link

@zonkmachine Yep! (Pretty much any sport, tbh)

@sturnclaw
Copy link
Member

I still don't fly spacecraft so this hasn't been tested in that regard.

Regarding spaceflight, there is a bit of an implicit dependency on planets with landing zones having <= 1.0g surface gravity in the gameplay balance currently. Increasing the mean gravity of planets with spaceports (and thus mission targets) does mean that several ships currently present in the game will be unable to land or complete missions on some worlds when fully laden.

Ideally, we'd want to follow-up on this effort by introducing some sort of common information display to the BBS interface which notifies the player when a mission would take place on a high-gravity world, or at the very least warn the player if they're flying a space-only craft and the mission involves landing on any planet.

I don't think that's a matter that needs to be solved in this PR however, and I'd definitely prefer to tackle it alongside an attempt to redesign the BBS mission dialog interface to follow some of @nozmajner's concepts.

@zonkmachine
Copy link
Member Author

As I understand it, since I'm calling rand, the universe now changes. I haven't found a good way around this that isn't hacky beyond what I can stomach. And I can stomach quite a lot. Maybe cheat a bit instead and just modulate the presented gravity for now? Just let the planets size 1 - 200 earth masses stay 1.0 g under the hood but do the computations in system-view-ui.lua and present some variation to the user?

@impaktor
Copy link
Member

impaktor commented Jul 1, 2023

If we're about to change the universe, then we might as well put in some condition that guarantees any High-G planet to have an orbital. It even makes sense, since colonizing a high-G planet might require supporting also low thrust craft, or some other hand waivey thingy.

(we do similar if-conditions, to improve playability, with Hydrogen, no station can have 0.)

@zonkmachine
Copy link
Member Author

A comment on the 'Escape Velocity' and ̈́Mean Density' values. I put them in there to aid in trouble shooting but I think they're good for immersion. I simply like the bling of it. Gravity is pretty unintuitive and this aids in getting a feeling for the body in front of you.

Should the computations maybe go in c++ functions like next to SystemBody::CalcSurfaceGravity() instead of system-view-ui.lua?

@sturnclaw
Copy link
Member

As I understand it, since I'm calling rand, the universe now changes.

This is expected behavior. In the ideal situation, you add new random rolls after all existing rolls to avoid disrupting other existing values, but it's not required (nor feasible in some cases). The only thing that needs to be done is to have this PR marked as a savegame bump, as it will not have galaxy-level compatibility with the game from before this PR. I'm quite happy to bump for this, and if I'm able to land some of my outstanding branches we'll definitely need a savegame bump anyways.

Should the computations maybe go in c++ functions like next to SystemBody::CalcSurfaceGravity() instead of system-view-ui.lua?

I'd be fine with that, escape velocity at the very least would be useful to have for autopilot-planning code.

Regarding station generation - you should only add an orbital around a high-gravity world which has a surface starport. Adding an orbital to every high-gravity world is probably not a good idea. 😄

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 2, 2023

Regarding station generation - you should only add an orbital around a high-gravity world which has a surface starport. Adding an orbital to every high-gravity world is probably not a good idea. 😄

Right, I actually did it general on purpose in order to get bases all over the place while coding this but apparently this part of the code seem to only be concerned with inhabited places so I was a bit disappointed at no bases on the largest planets. Also I selected for g when the value given is m/s2. Oopsie! Anyway, now it seem to work.
Anyway, bases only seem to pop up around already inhabited worlds. The high g worlds should have lesser population.
Edit: Now orbital stations are generated for populated worlds over 10.5 m/s2 (1,07 g).
high-g-planet4
high-g-planet

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 3, 2023

The high g worlds should have lesser population.

I'm looking at fixing this here but I should probably try and limit the PR as the topic could easily be all over the codebase. Maybe the span of the density can be tweaked a bit but it looks like it's pretty much useful as it is right now. On the low end I've seen planets presented as 'rocky planet' with a mean density of ~2ton/m3 and that is similar to Ganymede and Callisto and probably a good low for a rocky planet.

I'm looking at altering the Search and Rescue code to include gravity but not touching any of the other modules right now, for brevity.

Only simple dialogue changes this time like:
Q - "What type of help is needed?"
A - "We request the delivery of {unit} tons of {cargo} to the ship" + "The planet is {gravity}. Both ship and pilot need to be able to handle this.

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 3, 2023

Example mission dialog:

Low - Mid gravity planet
highgravity21

High gravity planet
highgravity20

@sturnclaw
Copy link
Member

I'm looking at altering the Search and Rescue code to include gravity but not touching any of the other modules right now, for brevity.

That's fine, my original thought was to introduce a "mission parameters" UI element into the chat form which would display "legal disclaimers" e.g. warnings to the player that they should expect combat or high-gravity worlds. This concept however is definitely a task for another PR, and if you can fit the gravity warning in naturally then go for it!

@zonkmachine zonkmachine force-pushed the density branch 2 times, most recently from 9b902a4 to 5ffad94 Compare July 3, 2023 19:50
@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 3, 2023

English help! Which line is best?
1 "The gravity on {planet} is {gravity} so please take this into consideration."
2 "The gravity on {planet} is {gravity}, please take this into consideration."
3 "The gravity on {planet} is {gravity}. Please take this into consideration."

Time for flight testing?

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 4, 2023

OK. I've added some strings on gravity theme to the Search and Rescue module. It's only on flavour four which is a scenario with a landed spacecraft. Flavour one to three are also landed but on a local planet so the pilot should know the gravity already.

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 4, 2023

I was thinking a message in the Advice module could be motivated. How about the Jimmy Cliff themed "The harder the g, the harder the fall", "Make sure you know the surface gravity of a planet before you even think of landing on it." ?

@impaktor
Copy link
Member

impaktor commented Jul 4, 2023

English help! Which line is best?

2 or 3. Not 1.

Btw, you could look at how "Set as navigation target" is implemented, as it's added to all missions by default, without touching the mission modules, if I remember correctly.

@zonkmachine
Copy link
Member Author

2 or 3. Not 1.

OK. I settled for 3.

look at how "Set as navigation target" is implemented, as it's added to all missions by default,

OK, something like "Show object info"? Showing the object info from the 'System Map/System Overview'?

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 4, 2023

Edit: This feature has been removed in this PR. May be implemented later.

targetinfo1

@impaktor Is this something like what you had in mind? (rudimentary implementation)

Edit: Where I've used 'Gravity' before I should say 'Surface gravity'. The example above is just a sketch. I don't know what data would be wanted here.

@impaktor
Copy link
Member

impaktor commented Jul 4, 2023

@impaktor Is this something like what you had in mind? (rudimentary implementation)

I wasn't thinking of anything in particular, beyond "avoid adding strings to every module".

@zonkmachine
Copy link
Member Author

@impaktor Is this something like what you had in mind? (rudimentary implementation)

I wasn't thinking of anything in particular, beyond "avoid adding strings to every module".

OK, I understand, but In reference to you could look at how "Set as navigation target" is implemented.
I tried it out above and wonder if it's heading in the right direction?

@zonkmachine
Copy link
Member Author

No population over 5 g
I looked around the net and there seem to be a consensus that over 5 g is not something we can live in. Technology a thousand years from now not taken into account. I don't know if there are any planets over 5 g that aren't gas giants though. Anyway, there is a hard limit now from population at 5 g.
I think the population should drop on planets after 1.2 g until there is only a few mining machine repair guys, scientists, and perhaps military, left at maybe 3 g.
Maybe add 'grav suits' and 'advanced grav suites' as commodities and perhaps you could buy them for the ship and crew to allow some well paying missions in higher gravity, although I think the gravity stuff should just be something to spice up the game so if references to 'g' becomes overpowering you just bump up the limits a bit and that should be enough.

I'm going to await further review now before continuing on this PR.

@zonkmachine
Copy link
Member Author

I added the info button embryo to the Cargo Run and Deliver Package modules for easier testing. The info is mostly not showing the right body though and the data shown is more or less random planet data. Feedback needed! Maybe drop for a later PR?

@zonkmachine
Copy link
Member Author

I don't know if there are any planets over 5 g that aren't gas giants though.

No. With the current model with +/-20% radius I can change Earth surface gravity between 0.69 and 1.56 g.
Incidentally that may not be totally wrong scientifically: Surface gravity on many exoplanets similar to that of Earth, study finds
The rocky exoplanet with the highest known surface gravity is K2-38b with maybe over 3 g. The margin of error of the examples I've seen is huge though but 5 g doesn't seem unrealistic, just uncommon.

With +/- 30% the surface gravity would be 0.59 - 2.03 g. That would work if the distribution would have a distribution centering more around 1 g. Like the snippet below calling rand twice. Testing it now and it looks promising.

	sbody->m_radius = fixed::FromDouble(sbody->GetRadiusAsFixed().ToDouble() * ( 1.3 - (0.3 * (
          rand.Double() + rand.Double())))); // +/-30% radius

@zonkmachine
Copy link
Member Author

zonkmachine commented Jul 10, 2023

Ready for review and test. Please note. There are quite a few custom systems in the game and they still have the issue with an overabundance of 1.0 g planets. These needs to be fixed manually and this is out of scoop for this PR.

I removed the info button as I deemed it also out of scoop.

@sturnclaw
Copy link
Member

I'm working on a visual editor for custom systems in my available Pioneer time and noticed some issues and inconsistencies with how custom systems are loaded and handled. Unless this branch is a blocker for other efforts of your own, I'll most likely combine efforts and merge this and my branch on similar timeframes to take advantage of the fact that both will require savegame bumps. I'm expecting it to take anywhere between a week to a month to land that branch.

@zonkmachine
Copy link
Member Author

Unless this branch is a blocker for other efforts of your own, I'll most likely combine efforts and merge this and my branch on similar timeframes to take advantage of the fact that both will require savegame bumps. I'm expecting it to take anywhere between a week to a month to land that branch.

Sounds good. It blocks nothing on my side.

@sturnclaw
Copy link
Member

I'm expecting it to take anywhere between a week to a month to land that branch.

Exactly one month later, the editor part of the system editor is finished. I have a few outstanding issues in #5622 before I can merge it, but once those are complete I'll be merging this PR as well. 🎉

@sturnclaw
Copy link
Member

@zonkmachine if you're able to rebase on master and give this a quick playtest, this PR should be good for merge.

* Randomize radius to +/- 20% to give the bodies some difference in surface gravity.
* Set an absolute limit of 5 g for habitability.
* Advice on gravity.
* Always build an orbiting station on inhabited worlds with a larger gravity (large
  currently being defined as over 1.07 g.
* New Planet info posts: 'Escape velocity' and 'Mean density'.
* Search and Rescue - Flavour 4 has extra text on dialogue when target planet is more
  than 1.2 g.
@zonkmachine
Copy link
Member Author

@zonkmachine if you're able to rebase on master and give this a quick playtest, this PR should be good for merge.

OK. Rebased without any problems and I've done a very quick playtest.

@sturnclaw sturnclaw merged commit 65bb3b8 into pioneerspacesim:master Oct 9, 2023
4 checks passed
@zonkmachine zonkmachine deleted the density branch October 9, 2023 16:06
@sturnclaw sturnclaw mentioned this pull request Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants