# mix volatiles and another gas (usually oxygen) to a target ratio, compensating for differences in temperature between the two inputs, and tweaking the ratio to correct for small deviations in the output mix (so it will get more accurate over time) alias ingas1 d0 alias ingas2 d1 alias outgas1 d2 alias mixer d3 alias readout d4 alias h2frac d5 alias targeth2frac r15 alias mixerratio r14 alias molespertick r13 alias outreagents r12 alias outh2frac r11 alias pipe1h2frac r10 alias pipe2h2frac r9 alias pipe1temp r8 alias pipe2temp r9 define molespertick 26.144 define MAXOUT 400 start: yield s ingas1 On 1 s ingas2 On 1 s outgas1 On 1 move targeth2frac 0.5 bdns h2frac notarget l targeth2frac h2frac Setting notarget: l outreagents outgas1 TotalMoles l outh2frac outgas1 RatioVolatiles select outh2frac outreagents outh2frac 0 l pipe1h2frac ingas1 RatioVolatiles l pipe2h2frac ingas2 RatioVolatiles l r0 outgas1 Pressure bge r0 MAXOUT high max r0 1 r0 mul r1 outreagents 101.325 div molespertick r1 r0 s db Setting molespertick add r1 outreagents molespertick mul r0 targeth2frac r1 mul r1 outreagents outh2frac sub r0 r0 r1 mul r1 molespertick pipe2h2frac sub r0 r0 r1 sub r1 pipe1h2frac pipe2h2frac mul r1 r1 molespertick div mixerratio r0 r1 # ^^ # (target*(moles+43.8)-moles*h2_frac - 43.8*p2_h2)/(43.8*(p1_h2-p2_h2)) l pipe1temp ingas1 Temperature l pipe2temp ingas2 Temperature mul r0 pipe1temp mixerratio sub r1 1 mixerratio mul r1 r1 pipe2temp add r3 r0 r1 #r0 = mixerratio*temp1 + (1-mixerratio)*temp2 div r4 r0 r3 mul r2 r4 100 max r2 r2 0 min r2 r2 100 s mixer Setting r2 bdns readout over l r0 outgas1 RatioVolatiles mul r0 r0 100 s readout Setting r0 over: j start high: s mixer On 0 j start |
MIPS is the programming language used by IC (integrated circuits) in the game Stationeers. Stationeering web site has a MIPS emulator with syntax highlighting and error detection.