7 Billion Humans

7 Billion Humans

50 ratings
The language of 7 Billion Humans
By Gergely
In this guide I write a detailed description of every command's usage and the special "politeness" behaviors that I discovered. No speed related stuff.
   
Award
Favorite
Favorited
Unfavorite
Basic concepts
Tiles
  • Empty tile - Does nothing special
  • Printer - Data cubes with a random number between 0 and 99 can be taken from the printer.
  • Shredder - Shreds anything given to it.
  • Wall - Stops worker movement.
  • Hole - Workers can fall into it when trying to step on it.
  • Plants / Furnitures - Act like walls, but workers can't detect them.
  • Boss - Your boss acts like a Furniture occupying 4 tiles.
  • Sensor - Scans it's tile
  • Button - When stepped on, activates all sensors and sends their data to the Counting Machine Display.
  • Counting Machine Display (as officially named) - A furniture that displays an integer in base 10. Cannot be read by workers.
Neighbouring tiles
Most commands interact with the 8 neighbouring tiles that are next to the worker vertically, horizontally, and diagonally.
Scanning
When a worker is told to check a neighbouring tile then the tile needs to be scanned which takes time. However, multiple tiles can be scanned simultaneously.
Politeness behaviour: Workers may wait for workers doing their thing while scanning their tile.
Memory slots
From year 25, the workers now have accessible memory consisting of 4 slots that can be written and read, and used as a parameter in nearly every command. Memory slots use all data types and are initialized to the integer "0".
Data types
The programming language in 7 Billion Humans uses the following data types:
  • Nothing (Note that "nothing" == "nothing" and "0" == "something")
  • 32 bit signed integer ranging from -2147483648 to 2147483647
  • Data cube reference - This is a reference to the data cube itself, (like in object oriented programming) not a snapshot of the data cube. If someone changes the number on the data cube, this memory slot will also change. If the data cube is destroyed, it is replaced with "nothing".
  • Worker reference - Like with data cubes, workers can also be remembered. This can be used to remotely read the data cube they are holding.
  • Worker/Data cube dual reference - When a worker scans a tile that has a data cube on it, but also another worker, it memorizes both. Read operations interact with the Data Cube reference, except that the slot is also "== a worker"
  • Printer - The data cube on top of the printer cannot be read.
  • Shredder
  • Sensor
  • Button
Pathfinding
If a memory slot is used as a parameter for a physical command, pathfinding will be used. All physical commands except write and drop support pathfinding. Workers prefer to avoid other workers while pathfinding.
Code blocks
Code blocks are the main components of the code. They have 4 variants.

Physical operations
Physical operations are the most important operations. Without them, workers do nothing.

Steps onto a neighbouring tile. If the targeted tile is occupied by a worker then this command will wait until the tile is free. Trying to step on a wall tile or office appliance has no effect.
  • As of Year 29, memory slots can be used to pathfind to a memorized object. Pathfinding to a wall, another worker, or office appliances will try to go as near them as possible.
  • As of Year 30, multiple neighbouring tiles can be specified to make the worker chose one randomly.
Politeness behaviour: If two workers try to walk to eachother's tile, they will swap. Workers who finished executing their code always swap with workers trying to step on their tile.

Picks up something from the tile the worker is standing on. Throws soft exception if there is nothing to pick up.
  • As of Year 7, workers can also pick up something from a neighbouring tile.
  • As of Year 25, memory slots can be used to pathfind to an object and pick it up. (This also steps on the object.)
    Politeness behaviour: If the NEAREST command was used to find the data cube, the worker may switch target (to another data cube) if said cube is taken while walking to it.
Note that "PICKUP MEMX" is always equivalent to "STEP MEMX; PICKUP C" except for the additional politeness behavior and different soft exceptions.

Drops the data cube the worker is holding onto the tile the worker is standing on. Throws a soft exception if there is nothing to drop, or if there is already a data cube on the tile.

Gives whatever the worker has to a neighbouring office appliance or another worker. Giving to a worker will temporarily pause their execution. If a direction is specified, it needs to be scanned for an object first. This throws a soft exception if trying to give nothing to a worker or printer, or if a targeted worker is already holding something.
  • As of Year 25, memory slots can be used to pathfind to an object and give to it.

Attempts to acquire a data cube from a neighbouring office appliance or another worker. Taking from a worker will temporarily pause their execution. If a direction is specified, it needs to be scanned for an object first. Throws a soft exception if the worker already has a datacube.
  • As of Year 25, memory slots can be used to pathfind to an object and take from it.

Writes a specified memory value to the data cube the worker is holding. If the memory slot does not contain a number then 0 is written. Throws a soft exception if the worker does not hold anything.

Threading operations
Threading operations affect the way each worker reads the code

Jumps to a specified line in the code. Can be used to jump forward to skip sections, or backwards to create loops.

The IF block is the only way to branch the code. Commands in the IF block will only be executed IF the conditions specified on the IF command are true. When a worker executes an IF block, it first scans all necessary tiles, then evaluates the conditions. If no tiles need to be scanned, the IF command takes no time to execute. Within the same IF command, multiple conditions can be specified and it will still count as one command towards the size challenge. Each condition can have the following mathematical operations on a given reachable tile:
  • == equal
  • ≠ not equal
  • > greater than
  • >= greater than or equal
  • < smaller than
  • <= smaller than or equal
With multiple conditions, logical operations must be used:
  • AND - The previous conditions AND the next line must be true.
  • OR - The previous conditions OR the next line must be true
Note that operations don't have priority over each other, so they will always be evaluated in order from top to bottom. So A AND B OR C AND D is simply ( ( (A AND B) OR C) AND D).
After the IF block, an optional ELSE block can be created. The else block is executed IF the condition was evaluated to false. This however does count as another command.
Using JUMP to jump into a block does not check the condition for the block.
  • As of year 21, the data cube the worker is holding can be queried.
  • As of year 25, memory slots can be queried.

Ends the execution of the worker.
The ForEachDir loop runs for every specified direction placing the object at that direction into the specified memory slot as if it was read by SET. The directions are iterated in clockwise order as the image shows on the right. Note that JUMPing into a ForEachDir block from the outside will start the loop and sets the specified memory slot to the first object.

Memory operations
Memory operations are performed on memory slots. A specified memory slot can be set to the value they return.

Can be set to...
  • ...return a specific value.
  • ...return the value of a specific memory slot.
  • ...scan a reachable tile and return the result.

Returns an object of a given type that requires the least walking to get to. (Diagonal steps are considered slightly longer than horizontal and vertical steps.)

Performs an arithmetic operation on two values. Since the workers can not do mental arithmetic, they use a calculator that is very slow. They can add, subtract, multiply and divide.

Synchronization
These code blocks deal with synchronization, that is, help workers time certain tasks together.

Tells a specified message to the specified co-worker(s). A neighbouring tile can be specified, everyone" can be specified, or a memory slot can be specified that holds a worker.

A worker executing this command waits until the specified message gets told to the worker. The specified message must be the parameter of the tell command, and this worker must be one of the workers targeted. If it does work out, then the workers exit their respective synchronization command at the same time.
Politeness behaviours
Politeness behaviours (as officially called )are undocumented behaviors of code blocks. These are there because in 7 Billion Humans, you control humans, not computers. Here are the few politeness behaviors that I discovered:
Step wait
If a worker tries to step to another worker's tile, they will wait until the tile is free.
Step swap
If two workers try to step on eachother's tile, they will swap. Workers who have terminated their execution always swap with other workers.
Target swap
If "PICKUP MEMX" is used directly after "MEMX = NEAREST DATACUBE" then the worker may switch target to another data cube in the room if the one previously targeted was taken already by another worker.
Avoidance
If possible, workers try to avoid eachother while pathfinding.
Scan wait
If a worker is scanning a tile another worker is standing on, it will block until that worker has finished whatever they were doing at the moment. This is a bit inconsistent, say if the worker who is being scanned has a DROP operation coming up, the scan will also wait for that.

If you happen to discover another of these hidden mechanisms, please write in the comments. Help me make this guide complete!
15 Comments
KingOfJacks 2 Feb, 2023 @ 2:36pm 
what time does every instruction take to do?
gfossati 19 Dec, 2020 @ 2:21pm 
How do you join the game on iPad
Gergely  [author] 4 Jan, 2019 @ 1:30am 
Thanks @Peristarkawan.

I was aware of this but I forgot to add it.
NightFlyer 3 Jan, 2019 @ 10:43pm 
Also, this might only happen on puzzle #20, because I tried it on #38 as well and couldn't duplicate the behavior there.
NightFlyer 3 Jan, 2019 @ 10:31pm 
There's some sort of cycle detection in play as well. If you have two people checking each other's tiles, they just unblock and proceed.
NightFlyer 3 Jan, 2019 @ 10:30pm 
I found another politeness behavior. It's a bit esoteric, and I'm not 100% certain my explanation is correct, so bear with me.

You have two workers, A and B, on neighboring tiles. A is checking the contents of B's tile, and B is also checking something. A will block at the if until B's own if command is complete. The timing of unblocking A depends on what B does next.

If B does a step, pickUp, or jump, then A unblocks immediately, and A and B will act simultaneously.

However, if B's next operation is drop, then A will continue blocking until B finishes dropping.

To see this in action, load up puzzle #20 and run this program:

pickup s
if w == nothing or
w != nothing:
step n
endif
if w == nothing or
w != nothing:
drop
endif

Everybody picks up their cube at once. Then, everbody steps north at once. Then, they drop their cubes in order from left to right. The last person waits for seven other people to finish dropping in sequence, instead of dropping immediately.
annick.charlebois 29 Oct, 2018 @ 9:05am 
I don't understand the working solution of year 13 regarding one of the IF commands:
IF
e = worker AND
s = datacube OR
w = worker
step se
else
step s.

How come someone who has nothing to the e (not complying with the first "if" condition) does step se?
I dont get it...

Gergely  [author] 31 Aug, 2018 @ 5:09am 
I purposefully did not make it clear. "Whatever the worker has" refers to the worker itself if there is nothing else at hand. Correct me if I'm wrong.
dholland 31 Aug, 2018 @ 1:17am 
Giveto a shredder with no held item -- the worker obligingly jumps into the shredder! An above and beyond politeness behaviour which, for example, could help with size optimization (omit an end statement). It's also quite funny.
Gergely  [author] 30 Aug, 2018 @ 12:37am 
I knew about that. Just modified it to be more clear.