Skip to content

Commit

Permalink
hardsuit 1.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
zkxs committed Aug 6, 2022
1 parent 57dc68d commit 9fd16e2
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 97 deletions.
9 changes: 5 additions & 4 deletions generic/hardsuit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Changelog

## Unreleased
## 1.1.0 2022-08-06

### Added
- Safety check to make sure the suit is not pressurized beyond safe limits

### Changed
- Program now continues the rest of its logic each tick even while closing your helmet
- Previously, the program would not run for two ticks while auto-closing your helmet. This is no longer the case, and the program now runs every tick.
- Oxygen levels are now kept as low as possible to minimize the moles metabolized

### Fixed
- Toxin detection now matches how the game actually checks for toxins
- Release toggle no longer lags behind filtering start by one tick
- Release toggling off no longer lags one tick behind filters starting

## 1.0.0
## 1.0.0 2022-08-04

### Added
- Initial functionality
11 changes: 8 additions & 3 deletions generic/hardsuit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Slap this into any old hardsuit and it'll manage things for you.

## Features

1. If your suit needs flushing, it will beep at you while autoflushing. An autoflush is slower, but more precise, than a manual flush. Feel free to manually flush too!
1. If your suit needs flushing, it will beep at you while autoflushing. An autoflush is slower, but more precise, than a manual flush. Feel free to manually flush too!
2. If the environment is appears unsafe, it closes and locks your helmet. Not all types of unsafe environment can be detected. Keeping your helmet closed is on you!
3. It will micromanage your filter, greatly prolonging its lifespan. Filtering will temporarily fuck with release and pressure settings to avoid dumping O2 to waste due to a stationeers bug.
3. It will micromanage your filter, greatly prolonging its lifespan. Filtering will temporarily fuck with release and pressure settings to avoid dumping O2 to waste due to a Stationeers bug.
4. It will turn the AC off if the external temperature is safe. Otherwise, it will set your AC to the most extreme but still safe value.
5. It will turn off air flow when your helmet is open.
6. It will minimize the moles of oxygen you consume.

## Assumptions

Expand Down Expand Up @@ -42,6 +43,10 @@ If any of these are false, the hardsuit controller program may behave in undesir

## Suit Trivia

### Breathing

Below an oxygen partial pressure of 24 kPa, moles of oxygen your consume are related linearly to the partial pressure. This means that if oxygen is kept at the absolute minimum of 16 kPa vs anything above 24 kPa, you actually consume 1.5 times less oxygen. In other words, this IC will make your oxygen tank last ~50% longer than you're used to.

### Helmet

- The light uses 5 W per tick, or 10 W per second from the equipped suit's battery.
Expand All @@ -51,7 +56,7 @@ If any of these are false, the hardsuit controller program may behave in undesir
### IC Power Cost

- The IC uses 2.5 W per tick, or 5 W per second.
- Does it still use power if the suit is not equipped?
- They still use power even if the suit is not equipped.

### Air Release

Expand Down
2 changes: 1 addition & 1 deletion generic/hardsuit/hardsuit.header.ic10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# runtime's hardsuit manager
# version 1.0.0
# version ?.?.?
# transpiled with icX
# source: https://bit.ly/3zDNjBW
21 changes: 17 additions & 4 deletions generic/hardsuit/hardsuit.icX
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ const MINIMUM_SAFE_PRESSURE = 20 + MINIMUM_SAFE_PRESSURE_FUDGE_FACTOR
# if we drop below 16 kPa, we start suffocating. Used for safety checks.
const MINIMUM_OXYGEN_PARTIAL_PRESSURE = 16
# extra kPa of O2 to keep around so that we aren't EXACTLY on the edge of suffocation
const MINIMUM_OXYGEN_FUDGE_FACTOR = 0.95
const MINIMUM_OXYGEN_FUDGE_FACTOR = 1.1
# how much O2 partial pressure we want to keep in the helmet
const TARGET_OXYGEN_PARTIAL_PRESSURE = MINIMUM_OXYGEN_PARTIAL_PRESSURE + MINIMUM_OXYGEN_FUDGE_FACTOR
# if we have more than this total internal pressure, we should start filtering. We'll keep 10 kPa in reserve in case weird thermal expansion stuff happens.
const TARGET_TOTAL_PRESSURE = MAXIMUM_RELEASE_PRESSURE_SETTING - 10
# extra oxygen partial pressure kPa to inject briefly before filtering
const PRE_FILTER_EXTRA_OXYGEN = 2
# oxygen partial pressure kPa to target briefly before filtering
const PRE_FILTER_OXYGEN_PARTIAL_PRESSURE = TARGET_OXYGEN_PARTIAL_PRESSURE + PRE_FILTER_EXTRA_OXYGEN
# point at which to inject the PRE_FILTER_EXTRA_OXYGEN
const PRE_FILTER_THRESHOLD = TARGET_TOTAL_PRESSURE - PRE_FILTER_EXTRA_OXYGEN
# if we have less than this partial pressure of CO2, we're good to stop filtering
const TARGET_CARBON_DIOXIDE_PARTIAL_PRESSURE = 5
# Expected minimum oxygen ratio you'll encounter
Expand All @@ -69,7 +75,7 @@ const MAXIMUM_ENVIRONMENT_PRESSURE = ONE_ATMOSPHERE * 2
# how much guaranteed kPa of room for CO2 do I want to have? If this is too low the filters could get stuck on.
const CARBON_DIOXIDE_WORKING_PRESSURE = 20
# how much non-O2 non-C02 gas do we allow?
const MAXIMUM_MYSTERY_GAS_PARTIAL_PRESSURE = TARGET_TOTAL_PRESSURE - TARGET_OXYGEN_PARTIAL_PRESSURE - CARBON_DIOXIDE_WORKING_PRESSURE
const MAXIMUM_MYSTERY_GAS_PARTIAL_PRESSURE = TARGET_TOTAL_PRESSURE - PRE_FILTER_OXYGEN_PARTIAL_PRESSURE - CARBON_DIOXIDE_WORKING_PRESSURE
# maximum toxin partial pressure in kPa before things are bad for humans
const MAXIMUM_TOXIN_PARTIAL_PRESSURE = 0.5
# maximum nitrous oxide partial pressure before we start getting stunned
Expand Down Expand Up @@ -252,9 +258,16 @@ nor r15 unsafe flushing
and r15 r15 helmetOpen
helmet.Open = r15

# calculate target O2 partial pressure
# if internalPressure > PRE_FILTER_THRESHOLD
# targetOxygenPartialPressure = PRE_FILTER_OXYGEN_PARTIAL_PRESSURE
# else
# targetOxygenPartialPressure = TARGET_OXYGEN_PARTIAL_PRESSURE
sgt r15 internalPressure PRE_FILTER_THRESHOLD
select r15 r15 PRE_FILTER_OXYGEN_PARTIAL_PRESSURE TARGET_OXYGEN_PARTIAL_PRESSURE
# if not filtering or flushing, the default pressure setting should be:
# suit.PressureSetting = max((TARGET_OXYGEN_PARTIAL_PRESSURE - oxygenPartialPressure) + internalPressure, MINIMUM_SAFE_PRESSURE)
r15 = TARGET_OXYGEN_PARTIAL_PRESSURE - oxygenPartialPressure
# suit.PressureSetting = max((targetOxygenPartialPressure - oxygenPartialPressure) + internalPressure, MINIMUM_SAFE_PRESSURE)
r15 = r15 - oxygenPartialPressure
r15 = r15 + internalPressure
max r15 r15 MINIMUM_SAFE_PRESSURE
# r15 = targetPressure, done with r14
Expand Down
125 changes: 40 additions & 85 deletions generic/hardsuit/hardsuit.release.ic10
Original file line number Diff line number Diff line change
@@ -1,58 +1,8 @@
########################################
# runtime's Hardsuit controller v1.0.0 #
########################################

############
# FEATURES #
############
# 1. If your suit needs flushing, it will beep at
# you while autoflushing. An autoflush is
# slower, but more precise, than a manual flush.
# Feel free to manually flush too!
# 2. If the environment is appears unsafe, it closes
# and locks your helmet. Not all types of unsafe
# environment can be detected. Keeping your
# helmet closed is on you!
# 3. It will micromanage your filter, greatly
# prolonging its lifespan. Filtering will
# temporarily fuck with release and pressure
# settings to avoid dumping O2 to waste due to a
# stationeers bug.
# 4. It will turn the AC off if the external
# temperature is safe. Otherwise, it will set
# your AC to the most extreme but still safe
# value.
# 5. It will turn off air flow when your helmet is
# open.

###############
# ASSUMPTIONS #
###############
# 1. Your tank is 100% oxygen
# 2. You inhale oxygen
# 3. You exhale CO2
# 4. Your suit is loaded exclusively with CO2
# filters
# 5. CO2 is not toxic in any concentration (the
# devs may change this soon)
# 6. O2 is not tooxic in any concentration (the
# devs may change this soon)
# 7. You pressurize your breathable rooms between 1
# and 2 atmospheres
# 8. A 1 atmosphere breathable room contains at
# least 22% oxygen
# 9. You won't use a normal helmet with your
# hardsuit
# 10. You would prefer a brief stint in vacuum to
# being poisoned
# 11. You won't open your helmet in a bad
# atmosphere, even if it's unlocked

bdse d0 55
s db Filtration 0
s db AirRelease 0
s db On 0
j 123
bdse d0 5 # runtime's hardsuit manager
s db Filtration 0 # version 1.1.0
s db AirRelease 0 # transpiled with icX
s db On 0 # source: https://bit.ly/3zDNjBW
j 78
l r2 db Filtration
l r3 d0 Open
seqz r4 r3
Expand All @@ -63,18 +13,16 @@ l r7 d0 RatioCarbonDioxide
mul r7 r7 r5
add r15 r6 r7
sub r15 r5 r15
l r13 d0 RatioNitrousOxide
mul r13 r13 r5
sge r14 r13 0.010132500000000001
l r13 d0 RatioPollutant
l r14 d0 RatioVolatiles
add r13 r13 r14
mul r13 r13 r5
sge r13 r13 0.010132500000000001
or r14 r14 r13
l r13 d0 RatioVolatiles
sge r14 r13 0.5
l r13 d0 RatioNitrousOxide
mul r13 r13 r5
sge r13 r13 0.506625
sge r13 r13 5
or r14 r14 r13
sgt r0 r15 81.325
sgt r0 r15 153.55
and r0 r0 r4
or r0 r0 r14
l r15 db Error
Expand All @@ -85,41 +33,48 @@ l r9 db PressureExternal
slt r15 r9 1
l r14 db TemperatureExternal
select r8 r15 0 r14
slt r15 r8 274.15
select r8 r15 274.15 r8
slt r15 r8 273.65
select r8 r15 273.65 r8
move r1 r15
sgt r14 r8 312.15
select r8 r14 312.15 r8
sgt r14 r8 312.65
select r8 r14 312.65 r8
or r1 r1 r14
or r13 r14 r15
s db On r13
s db TemperatureSetting r8
slt r15 r9 90.9090909090909
slt r15 r9 72.72727272727273
sgt r14 r9 202.65
or r13 r15 r14
or r1 r1 r13
slt r13 r6 20
sgt r14 r7 3
and r14 r14 r2
or r15 r13 r14
sgt r15 r5 23
sgt r14 r7 5
and r15 r15 r14
and r15 r15 r2
sgt r14 r5 192.65
or r15 r14 r15
and r2 r15 r4
or r15 r0 r2
sgt r15 r5 202.65
or r15 r15 r0
or r15 r15 r2
s db Filtration r15
or r15 r1 r0
and r15 r1 r4
s d0 Lock r15
nor r15 r1 r0
and r15 r15 r3
beqz r15 114
s d0 Lock 0
yield
s d0 Open 0
yield
s d0 Lock r1
select r15 r2 202.65 101.325
select r15 r13 101.325 r15
select r15 r0 0 r15
s db PressureSetting r15
s d0 Open r15
sgt r15 r5 190.65
select r15 r15 19.1 17.1
sub r15 r15 r6
add r15 r15 r5
max r15 r15 23
select r14 r2 202.65 r15
slt r13 r6 16
select r14 r13 r15 r14
select r14 r0 0 r14
s db PressureSetting r14
seqz r15 r2
or r15 r15 r13
and r15 r15 r4
s db AirRelease r15
yield
j 50
j 0

0 comments on commit 9fd16e2

Please sign in to comment.