7 Billion Humans - Code Blocks - Magic Game World

7 Billion Humans – Code Blocks

1 33

Code Blocks

About the Execution Time: Execution times as listed are only estimates and are often variable.

 

 

  • -Brief – Nearly instantaneous.

 

  • -Short – This is the minimum delay for instructions that require the worker to notice the world around them. Those same instructions may be faster without noticing the world.

 

  • -Medium – Most actions involving movement fall into this broad category. Thinking is normally fast, but doing takes time.

 

  • -Long – Indicates an action that takes significantly longer than walking one tile.

 

 

 

<memory> = calc <value> <operation> <value>

Execution time: Long. “Math is hard”.

This is perhaps the slowest thing a worker can do.

This will set the indicated memory register to the result of the math operation.

 

 

 

drop

Execution time: Medium

If the worker is carrying a data cube, they will drop it on their current position.

If the worker is not carrying a data cube, they will complain.

 

 

 

end
Execution time: Infinite

Causes the worker to stop all work, the same as if the program finished executing the final statement. The worker will automatically walk towards anyone walking on their current tile so as to not impede movement, and objects can still be given to/taken from them.

 

 

 

forEachDir <directions> as <memory>

Execution Time: Short

Requires the worker to notice their surroundings, thus this has a delay similar to that of an ‘if’ or ‘set’ that notices the worker’s surroundings.

Unlike other functions that take a directional input, this cannot target the tile the worker is standing on, it can only observe selected adjacent tiles. Which adjacent tiles is configurable.

This will loop over the nested instructions, once per direction. At the start of each iteration, it sets the selected memory register to what can be observed in one of the selected adjacent tiles at the start of that iteration.

Order of observing the adjacent tiles is in a clockwise direction starting form the nw corner. That is, they are observed in the order of nw, n, ne, e, se, s, sw, w.

If you are creative, you can move once per loop, and the next observed adjacent cell will be based upon your new position at the start of that loop.

Advice to aspiring new programmers: “Just because you can do a thing, doesn’t mean you should.” Move the worker from inside a forEachDir loop at your own risk. Lost or misplaced body parts are your responsibility.

 

 

 

giveto <direction|object>

Execution time: Medium. Can trigger movement.

This causes the worker to give their held datacube to someone or something else.

If a machine is targeted, it is given to that machine, with the worker moving to the machine’s north side to give the object.

If a worker is targeted, the datacube is given to the targeted worker. The targeted worker will pause all work until they receive the cube – this will stop them even if the worker giving the datacube is across the room.

 

 

 

if <arg1> <condition> <arg2> [<operator> <arg3> <condition> <arg4> [<operator>…]]

Execution time: Brief/short

Execution time is brief if there are no positional references (n/s/e/w/etc). If any positional references are used, the worker has to look at the world around them, taking extra time.

The if statement takes the form of ‘If/Then/Else’

The else clause, if present, will count for a single instruction of program size, but paradoxically, does not count as a program line.

Unlike other commands, the ‘if’ statement counts as 2 ‘program lines’, regardless of any ‘else’ block, regardless of how many conditional clauses the if statement has.

An example of an if statement:

 

1 43

 

Up to 8 conditional clauses may be used with a single if statement. The conditions are checked in order (there is no evaluation priority scheme), top to bottom (aka left to right). The boolean operator used to join them may be either ‘and’ or ‘or’. The condition may be ==, ≠, >, <, >=, <=

 

2 5

 

If you are evaluating a tile with a datacube, you can evaluate the value of that datacube.

If you are evaluating a tile with a worker holding a data cube, you can evaluate the value of the held datacube.

If you are evaluating a tile with a worker standing on a datacube, while holding a datacube, there are two datacubes you are looking at in the single evaluation. The value of the datacube on the ground takes precedence. The held datacube will be ignored.

 

 

jump

Execution time: Brief/Nil

This causes execution to jump to the indicated point – it is this language’s form of a ‘GOTO’ statement from BASIC.

This is one of two ways to implement loops, the other being ForEachDir. It also allows you to create subroutines, or otherwise shift flow between blocks of logic.

A jump statement counts as one instruction, but two lines.

Tip to aspiring programmers: The use of jump/goto in programming languages with more advanced flow control is normally strongly discouraged! These are discouraged for very good reasons. While you will need to use them in most levels to complete the required tasks, please do not learn bad habits.

 

 

 

listen <message>

Execution time: Variable.

The worker will stop and wait until they hear the selected message.

The tell/listen messaging functions as little more than an implemenetation of ‘sleep’/’wake’ functions. The actual messaging bandwidth of these functions allows the transfer of exactly 0 bytes of information – Despite the instruction names, you cannot transfer information between workers this way.

 

 

 

<memory> = nearest <object type>

Execution time: Brief

This sets the selected memory ‘register’ to the nearest instance of the selected type of object, or ‘nothing’ if no instances of that object type exist..

Desired objects can include workers, walls, printers, shredders, holes, and datacubes.

 

 

 

pickup

pickup <direction|object>

Execution time: Medium, can require longer for movement.

This command comes in two forms. One form, used in the early levels, does not accept an argument and will act on the worker’s location. The other form accepts either a direction or an object as an argument.

If a worker is supplied as the argument, the worker complains.

If a datacube is supplied as the argument, the worker walks onto the tile with the datacube and picks it up.

If a compass direction is supplied, the worker picks up the object at that location, without moving. This means that the worker may pick up data cubes without standing on their tile, if picking them up with compass directions, but will always stand on a datacube to pick it up if picking it up by reference.

Picking up things that are not datacubes is discouraged.

 

 

 

<memory> = set <value>

Execution time: Brief/short

If the set requires the worker to look at their surroundings, the worker will require more time to complete a set operation.

This sets the selected memory ‘register’ to the indicated value.

 

 

 

tell <direction|worker|everyone> <message>

Execution time: Short

Tell the selected message to the indicated recipient(s). Distance has no effect on this command. Workers listening for the message they hear will resume work.

 

 

 

step <direction>

step <directions|object>

Execution time: ~Medium – Will vary based on distance covered and obstacles encountered, which can make this brief or infinite.

This command takes two forms. One accepts a single direction, the other accepts multiple directions and values from memory registers.

This causes the worker to move. If a compass direction is given, the worker will step in that direction. If an object is given, the worker will step to that object, however close or distant it may be.

If multiple directions are given, the worker will select one unblocked direction at random.

 

Obstacles:

1

 

If the worker is directed to walk into another worker, the execution of this command will halt until the occupied floor tile is clear, as in the example to the right. Our walking worker in the example may need to wait a while, it looks like our math expert may be caught in a loop.

If the worker is directed to walk into a stationary obstacle, for example, a wall, the worker will not move and the command will promptly finish.

If walking to a distant object, the worker will select a free path at the time the step command is issued, and will not divert from their path if another worker then blocks one of the intermediate floor tiles – this can be a problem if you specifically park a worker on a tile in an infinite loop.

Workers that have stopped executing the program, either at an end statement, or by finishing the final line of code, will automatically step towards any workers trying to step on their tile, swapping places, so as to not be an obstacle to other workers still working their assigned tasks.

 

 

Walking in loops:

2

 

If multiple workers all want to step onto each other’s tiles, such that they will all step in a loop, this loop movement will be allowed. This works with any number of workers, whether it’s two workers that each walk towards the other to merely swap places, or 20 workers all walking in a giant loop. The advantage here is that workers cannot deadwalk. Ahem, workers cannot deadlock from simply trying to walk around. They can still get stuck in other ways, but the inability to get stuck simply by walking around is convenient.

Mixing diagonal and cardinal travel can in some contexts introduce slight delays.

 

 

 

takefrom <direction|object>

Duration: Medium. Will take longer if movement is involved

When taking things from machines, the worker will move to the north side of that machine.

If taking things from other workers, the worker will walk towards that other worker. The worker being taken from will stop all work until the data cube is taken from them.

 

 

 

write <value>

Duration: Medium

Write the indicated value onto the currently held data cube.

The value is recorded on the data-cube at the end of the operation.

 

  • 1 5

    He is the founder and editor of Magic Game World. He loved gaming from the moment he got a PlayStation 1 with Gran Turismo on his 7th birthday.

    View all posts
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x