stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 312

Day 312 of 365 · Expert · Month 11: Optimisation and debugging

Debugging in the simulator

Debugging in the IC10 coder's simulator: breakpoints, single step and tick, watching registers over time and recreating scenarios with Δ/tick and couplings.

Lesson 18 min Week 45

What you learn today

  • Set breakpoints
  • Watch registers
  • Recreate scenarios

Some errors only show over time. The pantry cooler switches, just far too often – and in the game you only notice that after half an hour from the power use. In the IC10 coder's simulator you fast-forward that half hour in seconds.

Stopping where it gets interesting

  • Breakpoint: click a line number. “Run” stops before that line.
  • Step runs exactly one line, Tick a whole tick – up to the next yield, a sleep or the 128 instructions.
  • Stop on error halts on the line that raises a runtime error.
  • Strict mode only allows LogicTypes that are entered on the device – just as real devices do not know every value.

Watching registers

The register table shows every value with its alias name. With the curve button you add a register to the history and see how it changes over many ticks. Under writes you find which line wrote which value into which device. If the chip writes something you do not expect, you find the line there.

Recreating scenarios

Devices in the simulator have no physics. You add it yourself:

ToolEffectExample
Δ/tickvalue changes every tickpantry warms up: Temperature +0.5
Couplingtarget += factor × source, every tickcooler cools: Temperature += −1.5 × cooler.On

With both together the pantry swings like in the game: it gets warm, the cooler starts, it cools down. In the history of on you see straight away whether the hysteresis is right. Here it is the wrong way round:

sgt tmp temp AUS     # bug: this should be EIN
or on on tmp
sge tmp temp EIN     # bug: this should be AUS
and on on tmp

With swapped limits the cooler switches on at 6 °C and off again just below 6 °C. The history shows twitching instead of long cooling phases.

Warning

The simulator is not the game. It only knows the values and couplings you enter. A test in the simulator shows that your logic is right – whether the device reacts the same way in the game only the build shows.

Diagram

Ticks and yield on a timeline tick 0 · 0.0 s tick 1 · 0.5 s tick 2 · 1.0 s tick 3 · 1.5 s 5 instr. yield 5 instr. yield 5 instr. yield 128 instr. no yield: limit hit Device values only change between two ticks.
“Step” runs one line, “Tick” a whole tick up to the yield. A breakpoint stops “Run” before its line.

Exercise

Task

The pantry cooling twitches. Recreate the scenario in the simulator (sensor Temperature Δ/tick +0.5, coupling Temperature += −1.5 × cooler.On) and watch on in the history. Then fix the hysteresis: the cooler “Kammer” turns on above 6 °C and only turns off again below 3 °C. If the sensor is missing, it keeps cooling.

Hints

Hint 1

Switching on belongs to the upper limit EIN, switching off to the lower limit AUS.

Hint 2

Swap AUS and EIN in the two comparisons – nothing else.

Hint 3

Test with 5 °C after switching on: the cooler has to keep running.

Quiz

4 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed the simulator exercise
  • Passed the quiz with at least 60 %

Without an account progress is saved in this browser only.

Report a mistake in this lesson

Please sign in to report. Sign in

Esc
↑ ↓ selectEnter open/ opens search anywhere