Randwork
Randwork is a nondeterministic programming language created by User:Marcsances. The program's finality is to execute a random instruction from one of the instruction set.
There are four versions of Randwork: Randwork, RandworkH, Randwork+, Randwork#. Randwork is the "normal" implementation of the language, Randwork+ adds more instructions and then is more controlable, and RandworkH displays Hello World... if you are lucky.
Variables
Randwork and Randwork+ work with variables.
In Randwork there are 2 variables, and their types are bytes.
In Randwork+ and Randwork# there are 4 byte variables.
RandworkH has no variables.
Statements
Randwork and RandworkH have only one instruction allowed in his applications:
Do anything - Execute a random command from the instruction set
Everything that it's not that statement is interpreted as a comment.
Randwork+ and Randwork#
Randwork+ is a more constructive version of Randwork. These are the instructions allowed:
Do anything - Execute a random command from the instruction set Do whatever you want - Execute random commands from the instruction set for unknown times (each time, a command is run, until the application decides to stop) If something is empty {instruction} - If a randomly chosen variable is empty, executes the instruction If something isn't empty {instruction} - If a randomly chosen variable isn't empty, executes the instruction If you want {instruction} - Executes a statement in a 50% possibility Jump to a line - Jumps to a randomly chosen line Jump to a line up - Jumps to a randomly chosen line above the statement Jump to a line down - Jumps to a randomly chosen line below the statement Go out if you want - In a 50% of probability, exits the application
Instruction sets
When Randwork has to do anything or whatever he wants, he executes a command from the instruction sets.
Instruction sets are the things Randwork can do. Each version has different instruction sets:
Randwork
Standard Randwork will run (with Do anything) one of these instructions:
Nop
Write the ASCII equivalence of a random byte
Beep
Set value of byte 1 to a random value
Set value of byte 2 to a random value
Clear byte 1
Clear byte 2
Sum byte 1 with byte 2 and store result in byte 1. If result exceeds 255, compute the modulo so it forms a valid byte.
Write the ASCII equivalence of byte 1
Write the ASCII equivalence of byte 2
Randwork+
Randwork+ has the same instructions as Randwork, but it adds the following:
Set value of byte 3 to a random value
Set value of byte 4 to a random value
Clear byte 3
Clear byte 4
Write the ASCII equivalence of byte 3
Write the ASCII equivalence of byte 4
Display the Hello World message
Ask the user to input a byte and stores it to a random variable
Randwork#
Working on the notes of giargiano in the talk page (thanks) Randwork# removes the non sense of making Randwork+ displaying the Hello World message too much.
The instruction set is identical to Randwork+ except "Display the Hello World message" which is replaced by:
Print bytes 1 to 4
RandworkH
It only has two instructions:
Display the Hello World message
Nop
Examples
Hello World
Although RandworkH has been designed specifically to show Hello World in a more probable condition than Randwork and Randwork+, I can't still guarantee that this example will show Hello World, maybe you're unlucky.
Do anything Do anything Do anything Do anything Do anything Do anything Do anything Do anything
Example
Don't know what will happen if you run this example. USE IT BY YOUR OWN RISK.
(Language: Randwork)
Do anything Do anything Do anything Do anything Do anything Do anything Do anything Do anything
Example 2
Don't know what will happen if you run this example. USE IT BY YOUR OWN RISK.
(Language: Randwork+)
Do whatever you want Go out if you want Do anything If you want Jump to a line up Do anything If something isn't empty Jump to a line up
99 bottles of beer
It is really easy to print a program that (some millennium) will print the 99 bottles of beer text. (Randwork+)
Do anything Jump to a line up
Yes, that is an infinite loop. But you know what is the infinite monkey theorem, right? Think of Randwork+ like a monkey. Storing random values, suming them, displaying them... in a infinite lapse of time, 99 bottles of beer full text will appear on your screen. But sometimes I really want to add a "Format the whole hard disk" instruction between the instructions in Randwork+ instruction set, if there's no action, you don't enjoy the language.