LottoScript
Jump to navigation
Jump to search
Commands
LottoScript is an esolang with five randomized commands:
Command | Name | Function |
---|---|---|
Add | [ADD] | Add 1, or 10 (see later at EXR) to the cell |
Subtract | [SUB] | Remove 1, or 10 (ditto) from the cell |
Append | [APP] | Append the cell (as chr value) to the current string and reset the cell |
Extra | [EXR] | Increase the affect of ADD and SUB (comes after) |
Output | [OUT] | Output the current string and reset it |
Available characters for the commands:
1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?
There's also an option for a space, a tab, or a newline.
This means if you try to make a program with random operators, there is a ~0.000000011645049% chance it will work. Probably a higher chance if you use less commands, but that's the number if you use all 5.
Example
Example program:
+<+<+<+<+<+<+<++>+<+<+<+<+<+<+<+<+<+<+++++>+<+<+<+++>+<+<+<++> +<+<+<+<+<+<+<+++>+<+<+<++>+<+<+<+<+<+<+<+<+<+<+<+<->+<+<+<+<+<+<+<+<+<+<+<+>+<+<+<+<+<+<+<+<+<+<+<>+<+<+<+++>!
Output:
Hi! I won!
This uses:
Command | Symbol |
---|---|
[ADD] | + |
[SUB] | - |
[APP] | > |
[EXR] | < |
[OUT] | ! |
Interpreter
import random import contextlib chars="`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>? \t\n" addCMD = chars[random.randint(0, len(chars)-1)] subCMD = chars[random.randint(0, len(chars)-1)] appCMD = chars[random.randint(0, len(chars)-1)] exrCMD = chars[random.randint(0, len(chars)-1)] outCMD = chars[random.randint(0, len(chars)-1)] with open("main.lotto") as raw: con = raw.read() with contextlib.suppress(Exception): curstring = "" curcell = 0 lines = con.split("\n") for line in lines: for chariter in range(len(line)): curchar = line[chariter] if curchar == appCMD: curstring += chr(curcell) curcell = 0 elif curchar == outCMD: print(curstring) curstring = "" with contextlib.suppress(Exception): nextchar = line[chariter+1] editor = 1 if nextchar == exrCMD: editor = 10 if curchar == "+": curcell += editor elif curchar == "-": curcell -= editor
If you want to change the commands and not make it impossible to use, just change the CMD variables (addCMD, subCMD, etc.)