Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Space station atmosphere simulator  (Read 11876 times)

Starver

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #15 on: November 10, 2018, 12:26:44 pm »

The latter looks a bit 'cellular automata'y. Too much alone, it dies (spreads to empty neighbours, which, not being too much, 'picks up' new life if there's enough previous 'live' neighbours.)

As an experiment, what if you do the latter but 'smudge' the amounts for display. Part-tone (or some other proxy) each 'display cell' according to sum of gas in self plus immediate neighbours.

Alternately, keep the display the 'same', but underlie it with half-sized/quarter-areaed (or third/ninth?) simulation cells, to a similar (though subtly different) end result.

It increases your memory requirements for the base sim (compared with the visible array, or blockify the interface w.r.t. the same back-end - not including if you relied upon the peek'n'poke of the visual array and pressure array to be 'the same thing', already) but it might produce more (NPI!) fluid results. Or not. That's just my instincts, and could be wrong
Logged

moneyl

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #16 on: November 16, 2018, 12:44:46 am »

I'm releasing a new version with a variety of changes. Some simulation features, and some quality of life:
- Added gas mixtures / types.
- As a result the pressure sim is semi broken. A room of uniform pressure starts off stable, but changing the temperature or pressure by a small bit sets off the pressure sim and all gas moves to one side of the room. There is still a direction bias on gas flow. I'll aim to fix both of these as I experiment with different ways to sim gas flow.
- Added options to activate 2-step atmos sim, and visual smoothing of the pressure overlay. Also added an option to skip tiles in the pressure sim which makes the atmos sim slightly more stable in 2-step mode.
- The 2 step sim has no direction bias but is too chaotic and doesn't flow in a reasonable manner, I left it so people could play around with the values.
- Added heat simulation, still needs some tweaks. Heat flow only occurs through gas of a sufficient amount and walls.
- There is now a definitions folder, which describes each of the gases, tiles, and gas mixtures.
- You can now click and drag with mouse controls.
- Added heat controls for mouse. See help menu (F1 to open).
- Added description for each render mode in the top left overlay.
- Many other small things I've forgotten.

0.02 Download (Windows 64bit)

Adding mixtures broke the heat and pressure sims initially, and though I managed to fix many of the bugs from that there is still some oddness. So let me know if you see anything that doesn't seem right. The pressure sim is still broken so expect to see that behave oddly.

The latter looks a bit 'cellular automata'y. Too much alone, it dies (spreads to empty neighbours, which, not being too much, 'picks up' new life if there's enough previous 'live' neighbours.)

As an experiment, what if you do the latter but 'smudge' the amounts for display. Part-tone (or some other proxy) each 'display cell' according to sum of gas in self plus immediate neighbours.

Alternately, keep the display the 'same', but underlie it with half-sized/quarter-areaed (or third/ninth?) simulation cells, to a similar (though subtly different) end result.

It increases your memory requirements for the base sim (compared with the visible array, or blockify the interface w.r.t. the same back-end - not including if you relied upon the peek'n'poke of the visual array and pressure array to be 'the same thing', already) but it might produce more (NPI!) fluid results. Or not. That's just my instincts, and could be wrong

I tried averaging pressure (that's what you meant with "part-tone"?) both visually only and then also affecting the grid values. When I tried averaging pressure values across the grid I ended up with buggy behavior so I left it out for now (probably a conservation of mass issue, it was a quick test). I left in the visual only option as it can make the 2-step sim option look less chaotic. I also added in an option to skip tiles in the 2-step sim, so if it's set to 1 the sim should be skipping every other tile. Setting it to 1 makes the 2-step sim less chaotic, anything above that seemingly does nothing different. I haven't tried breaking the grid down into smaller cells yet. One problem I could see with that is that it would increase performance requirements since it would be equivalent to increasing the grid size if I understood what you meant.

Edit: I shortened up the initial post and updated the download link.  I put the original post into a spoiler. Also, note that the property values for the gases and tiles are temporary. I'll tweak them to be more meaningful or accurate in the future. Also, I disabled logging for this release. All it did was fill a text file with useless info, and could grow quite large after many uses. Should have a better logging system next release.
« Last Edit: November 16, 2018, 01:19:20 am by moneyl »
Logged

moneyl

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #17 on: December 04, 2018, 09:15:20 pm »

I'll be tabling this for a few months or longer as I'm moving over to a modding project for another game. I usually cycle between projects every 4-6 months, so I will certainly come back to this. Once I have something worth showing on my other project I will post it in this forum. Hopefully in 3-5 weeks. Thanks again for the interest shown, I'm still happy to discuss this project even as I work on others.
Logged

Starver

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #18 on: December 04, 2018, 09:52:09 pm »

I like what I've seen, and hope your modding project is as interesting to that other audience. Fare thee well, and don't forget to get back to this eventually, if you can still bare it.

I also wanted to post this: https://english.stackexchange.com/questions/96961/tabled-us-vs-uk
;)
Logged

moneyl

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #19 on: December 08, 2018, 12:23:48 am »

I like what I've seen, and hope your modding project is as interesting to that other audience. Fare thee well, and don't forget to get back to this eventually, if you can still bare it.

I also wanted to post this: https://english.stackexchange.com/questions/96961/tabled-us-vs-uk
;)
Huh, that's pretty interesting. I've always used it in the manner commonly used in the US, though come to think of it the UK definition makes more sense to me. Since you are "putting it on the table" for consideration. I'll definitely come back to this project. I cycle to keep things interesting. I was actually working on this project last winter/spring as well. Just in a more primitive form while I was learning openGL. Then I had moved to a different project during the summer and back to this during this fall.
Logged

TWO CATATA

  • Bay Watcher
  • twin kavat
    • View Profile
Re: Space station atmosphere simulator
« Reply #20 on: December 23, 2018, 01:33:18 pm »

If you manage to make a game that's as customisable (the ridiculous variety of servers) as space station 13 yet doesn't need the awful BYOND system to play together with large amounts of people, quite a LOT of people on the internet will love you as a sort of internet god after having so many failed remakes, so keep at it :D Though I guess once you've got the first part done then you'd want to look for people who can do net code and stuff, if your seed of a game is good enough people will flock to wanting to help!
Logged

moneyl

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #21 on: December 30, 2018, 12:14:47 pm »

If you manage to make a game that's as customisable (the ridiculous variety of servers) as space station 13 yet doesn't need the awful BYOND system to play together with large amounts of people, quite a LOT of people on the internet will love you as a sort of internet god after having so many failed remakes, so keep at it :D Though I guess once you've got the first part done then you'd want to look for people who can do net code and stuff, if your seed of a game is good enough people will flock to wanting to help!

While it'd be great to make a c++ SS13 clone, that isn't my goal. I mentioned that in the original post but forgot to put it in the updated one. I took inspiration from SS13 with the aim of having a similar atmos system, but in a singleplayer game. I think that all the systems in play in SS13 (atmos, electrical, chemistry, etc) combine to create some really fun emergent behavior and would like to see that in a sp game. Though when it comes to SS13 remakes it seems that Space Station 14 is fairly active. Regular commits and they are active on their discord. Slowly but steadily making progress. There's also Unity Station, but I haven't been following that one as closely. It's on steam.
Logged

Griffork

  • Escaped Lunatic
    • View Profile
Re: Space station atmosphere simulator
« Reply #22 on: July 19, 2020, 12:51:40 am »


Did you end up coming back to this?

I'm working on something very similar to this (visually) inspired by SS13 and haven't implemented atmospherics yet (and honestly have no idea how to go about doing it).
Logged

Moeteru

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #23 on: August 12, 2020, 06:17:40 pm »

This is a really hard problem, and I don't think I'd try building a one-size-fits-all fluid dynamics solver.
There are a few different situations which each benefit from their own modelling approach:
  • Slow diffusion of different gasses within a room, all at the same pressure. Imagine throwing a smoke grenade into the middle of a room, or a slow poison gas leak in the absence of any air currents.
    This is where the OP's solution works best. As long as the diffusion rate is low you can get accurate results with fairly long time steps, and therefore low CPU cost. The quantities transferred in each step have to be kept low in order to avoid numerical instability.

  • Slow changes in air pressure, while keeping the composition constant. This covers situations like pressurising an airlock or losing atmosphere through a very small hull breach.
    The most efficient solution in this case is to model each compartment as a homogeneous volume of gas. Rather than solving on a tile-by-tile basis, the whole compartment gains/loses pressure at a uniform rate. The program can automatically identify separate compartments at the start of the game using a flood-fill algorithm, and merging/splitting them as walls are built/removed is also possible in a fairly efficient way.

  • Sudden changes in pressure/composition from explosions or large hull breaches.
    In this case you're mainly interested in the force from the blast wave or escaping air. For a blast wave you use a flood-fill algorithm which only visits each tile once to calculate the force at that instant. For escaping air you can use a modified path-finding algorithm to work out how much air will flow through each tile as the compartment depressurises. You don't need to go through any step-by-step shuffling of air from one tile to the next because you're only interested in the physical forces. The pressure change can be treated as uniform throughout the whole compartment without any significant loss of realism simply because these events happen so fast.

You could then extend these three basic models with more interactions. For example, when there's a small hull breach you can run a single path-finding pass to calculate the forces produced by it and then use those to adjust your diffusion model so that smoke appears to be sucked towards it.
Logged

moneyl

  • Bay Watcher
    • View Profile
Re: Space station atmosphere simulator
« Reply #24 on: August 16, 2020, 10:18:00 pm »


Did you end up coming back to this?

I'm working on something very similar to this (visually) inspired by SS13 and haven't implemented atmospherics yet (and honestly have no idea how to go about doing it).
I didn't, though it's an idea I keep coming back to. I have a game idea where an atmos system would be a good fit so maybe I'll give it another try then. It's been almost two years since I've worked on this so I can't vouch for all the math / ideas I wrote previously here lol. Looking back the code is pretty horrendous and the simulation is very broken in the version I have (it was never quite right). I think I'd start by researching fluid/gas simulation again. I know I did some research last time but I don't think I went too deep. Do you have any good resources on fluid simulation you'd suggest looking at Moeteru? It sounds like you have some experience in it.
Logged
Pages: 1 [2]