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

Day 260 of 365 · Pro · Month 9: Logistics and greenhouse

Planning food

How long will the food last? Count the stock, project the harvest per hour from game data, subtract the demand and show the range.

Lesson 18 min Week 38

What you learn today

  • Demand per person
  • Project the harvest
  • Show the stock

Three people on Mars, five trays of potatoes and a half full fridge. Is that enough? Instead of guessing, a chip works it out for you – and warns before the last plate is empty.

Demand per person

How much a human eats in the game depends on the food and the save. Measure it yourself: count how many potatoes your crew uses in one hour of game time and enter that as a define. With the number of people from a dial you get the demand per hour:

lbn people DIAL HASH("Personen") Setting Average
mul balance people DEMAND      # demand per hour

Projecting the harvest

The game data gives the growth time at full efficiency and the maximum harvest amount for every plant. For the potato that is about 3000 seconds and up to 2 pieces per harvest. Per tray and hour that is at most:

2 · 3600 / 3000 = 2.4 potatoes

The number of planted trays comes from Occupied with Sum. Times 2.4 gives the harvest per hour, in the best case:

lbns harvest TRAY HASH("Beet") 0 Occupied Sum
mul harvest harvest YIELD
mul harvest harvest 3600
div harvest harvest GROWTIME     # pieces per hour
Note

This is an upper bound. If the plants grow at half Efficiency, every stage takes twice as long. If you want to be more precise, also multiply by the average efficiency of the planted trays.

Balance and range

Harvest minus demand is the balance per hour. If it is positive, the stock grows and the range is unlimited – the display then shows 999. If it is negative, the stock lasts stock / loss hours:

sub balance harvest balance       # harvest minus demand
sub tmp 0 balance              # loss per hour
div range stock tmp
floor range range
sgez tmp balance
select range tmp 999 range

floor rounds down: 27.3 hours are 27 full hours, not 28.

Warning

If you divide by a balance of exactly 0, you get infinity. The sgez check before the select covers this case too, because 0 counts as “the stock does not grow any more, but it does not shrink either”.

Exercise

Task

Build the food plan:

  • display “Vorrat”: sum of all potatoes in the 15 slots of “Vorrat”
  • display “Ernte”: planted trays “Beet” times YIELD times 3600 divided by GROWTIME
  • display “Reichweite”: full hours the stock lasts for the people from the dial “Personen”; 999 if the balance is not negative; −1 without the dial
  • light “Hunger” on when the range is below 24 hours

Hints

Hint 1

You count the stock as yesterday, with a loop over 15 slots and lbns … Quantity Sum.

Hint 2

Range: loss = 0 − balance, then div and floor.

Hint 3

Two select at the end: first 999 with sgez, then −1 with snan people.

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