RoundAbout

From Esolang
(Redirected from Roundabout)
Jump to navigation Jump to search
RoundAbout
Designed by User:AndrewToasterr
Appeared in 2022
Memory system stack and heap-based
Dimensions Two-dimensional
Computational class Unknown
Reference implementation Created, testing
File extension(s) .rbout

This page is still being worked on!

RoundAbout is a two-dimensional esoteric programming language. Code is placed on a two-dimensional grid, called Map.

Language overview

A RoundAbout program consists of a size definition and the actual program code inside. Each cell in the map consists of a single UTF-8 character. The program code is then executed by looking at the current symbol below the cursor, and then executing an instruction based on the selected mode. Any empty spaces should be considered a space (U+0020). At the start of execution the cursor is positioned on the top-left corner (at 0,0) and the direction is set to right. The following example is a CAT program

//21,2
$?; =+1; &^; @v; $-+;
              ~

Instructions

Due to the fact that RoundAbout has multiple execution modes, each symbol can have different meanings in different contexts.

Contextless

These instructions can be used regardless of mode

Cmd Name Condition Description
~ Halt None Halts the program execution
; Reset None Sets the mode to Traversal

Traversal

Cmd Name Condition Description
@ Set-conditionaltraversal None Sets the mode to Conditional Traversal
? Set-compare None Sets the mode to Comparison
& Set-flags None Sets the mode to Comparison
% Set-operation None Sets the mode to Operation
= Set-stack None Sets the mode to Stack
[ Set-heap None Sets the mode to Heap
$ Set-io None Sets the nice to IO
# Set-map None Sets the mode to Map
> Flow-right None Sets the direction to right
< Flow-left None Sets the direction to left
v Flow-down None Sets the direction to down
^ Flow-up None Sets the direction to up
/ Flow-fsreflect (forward slash reflect) None When direction is up or right, set direction to right-up. When direction is down or left, set direction to left-down. When direction is right-down, set direction to left-up. When direction is left-up, set direction to right-down. Otherwise preserve direction
\ Flow-bsreflect (back slash reflect) None When direction is up or left, set direction to left-up. When direction is down or right, set direction to right-down. When direction is left-down, set direction to right-up. When direction is right-up, set direction to left-down. Otherwise preserve direction
| Flow-vreflect (vertical reflect) None When direction is right, set direction to left. When direction is left, set direction to right. When direction is right-down or left-down, set direction to down. When direction is right-up or left-up, set direction to up. Otherwise preserve direction
- Flow-hreflect (horizontal reflect) None When direction is down, set direction to up. When direction is up, set direction to down. When direction is right-down or right-up, set direction to down. When direction is left-down or left-up, set to left. Otherwise preserve direction
+ Flow-preflect (plus reflect) None Set direction randomly to either right, left, up, or down
x Flow-xreflect (cross reflect) None Set direction randomly to either right-down, right-up, left-down, left-up
* Flow-sreflect (star reflect) None Set direction randomly to either right, right-down, right-up, left, left-down, left-up, down, or up

Conditional traversal

This is an extension to the basic traversal mode where any instructions are only executed if ResultFlag is set to true.

Comparison

This mode is used to compare values on the stack, therefore to execute such an instruction the stack has to have at least two values.

Cmd Name Condition Description
> Compare-greaterthan At least two values on the stack Compares the two top most values (a, b) on the stack using b > a and sets ResultFlag to the result
< Compare-lessthan At least two values on the stack Compares the two top most values (a, b) on the stack using b < a and sets ResultFlag to the result
= Compare-equal At least two values on the stack Compares the two top most values (a, b) on the stack using b == a and sets ResultFlag to the result
! Compare-notequal At least two values on the stack Compares the two top most values (a, b) on the stack using b != a and sets ResultFlag to the result

Flags

This mode is used to track results of certain instructions. The flags values are stored in a binary number that is arbitrarily large. Right now only six bits are used, but sixteen bits are reserved for runtime usage. This means when using custom you should either use bit 0 or use values above 65535 (2^16 - 1)

Reserved Bits Table
Name Description
Bit 0 ResultFlag This is a general flag that represent whether some action succeeded or not
Bit 1 ComplexRoot Set when taking a root results in a complex value
Bit 2 DivisionByZero Set when any division/modulo by zero is performed. Currently there are 3 scenarios: Division, Modulo, and 0th Root
Bit 3 ResultTruncated Set when division had a remainder
Bit 4 ReadNoDigits Set when Stack-read read no digits
Bit 5 InvalidValue Set when an invalid was passed to an instruction
Bit 6 Utf8Error Set when encoding/decoing values using UTF-8 codec failed
Bit 7 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 8 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 9 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 10 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 11 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 12 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 13 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 14 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Bit 15 Reserved Bit This is a reserved bit, but as of now has yet no functionality
Instructions
Cmd Name Condition Description
| Flags-true At least one value on the stack Reads a number, if non-negative then performs flags = flags | value. If read number is negative, set InvalidValue flag to TRUE
& Flags-false At least one value on the stack Reads a number, if non-negative then performs flags = flags & ~value. If read number is negative, set InvalidValue flag to TRUE
^ Flags-invert At least one value on the stack Reads a number, if non-negative then performs flags = flags ^ value. If read number is negative, set InvalidValue flag to TRUE
> Flags-push None Pushes the Flags' value onto the stack
? Flags-push At least one value on the stack Pops a value off the stack, if non-negative then performs (flags & value) == value and saves the result to ResultFlag. If value is negative, set InvalidValue flag to TRUE

Operation

This mode is used for operating with values on the stack.

Cmd Name Condition Description
+ Operation-add At least two values on the stack Pops two values of the stack and adds them together using b + a
- Operation-sub At least two values on the stack Pops two values of the stack and subtracts them from each other and pushes the result onto the stack using b - a
* Operation-mul At least two values on the stack Pops two values of the stack and multiplies them together and pushes the result onto the stack using b * a
/ Operation-div At least two values on the stack Pops two values of the stack and performs integer division and pushes the result onto the stack using b / a
^ Operation-pow At least two values on the stack Pops two values of the stack and calculates the power and pushes it onto the stack using b ^ a
\ Operation-root At least two values on the stack Pops two values of the stack and calculate the nth root and push the truncated result onto the stack using b√a
% Operation-mod At least two values on the stack Pops two values of the stack and performs integer division and pushes the remainder onto the stack them using b % a
| Operation-or At least two values on the stack a
& Operation-and At least two values on the stack Pops two values of the stack and performs bitwise AND and pushes the result onto the stack them using b & a
v Operation-xor At least two values on the stack Pops two values of the stack and performs bitwise XOR and pushes the result onto the stack them using b ^ a
> Operation-rshift At least two values on the stack Pops two values of the stack and performs bitwise right shift and pushes the result onto the stack them using b >> a
< Operation-lshift At least two values on the stack Pops two values of the stack and performs bitwise left shift and pushes the result onto the stack them using b << a
! Operation-invert At least one value on the stack Applies bitwise inversion to the topmost item on the stack

Stack

Cmd Name Condition Description
+ Stack-push None Read digits until a non-digit character is encountered and push read value onto the stack. If no digits were read, push 0
- Stack-pop At least one value on the stack Pops a value off the stack
* Stack-swap At least two values on the stack Swaps the two topmost values on the stack
> Stack-save At least one value on the stack Pop a value off the stack and set it to the current cell in the heap
< Stack-load None Push a value equal to the current cell in the heap
? Stack-any None Set ResultFlag to true if stack is not empty, otherwise set to false
: Stack-dupe At least one value on the stack Duplicates the top value on the stack
& Stack-clear None Clears the stack

Heap

Cmd Name Condition Description
> Heap-rshift None Moves cell pointer right
< Heap-lshift None Moves cell pointer left
# Heap-jump At least one value on the stack Pops a value off the stack and moves pointer to such place
* Heap-home None Move cell pointer to 0
+ Heap-increment None Increment value in current cell by one
- Heap-decrement None Decrement value in current cell by one
0 Heap-null None Set value in current cell to 0
& Heap-clear None Set all cells to 0

IO

Cmd Name Condition Description
+ IO-write At least one value on the stack Pop a value off the stack and write it to STDOUT using UTF-8 encoding
- IO-read None Read a UTF-8 character from STDIN and push it's value onto the stack. If no character is read, push -1
? IO-any None If a character can be read from STDIN set ResultFlag to true, otherwise set to false

Map

Cmd Name Condition Description
+ Map-read None Advance cursor, read a UTF-8 character from the map at current location and push it's value onto stack
- Map-write At least one value on the stack Advance cursor, pop a value off the stack, convert it to a UTF-8 character and set write it to the current location on the map
* Map-null None Advance cursor, set the character at current location to a space (U+0020)
# Map-jump At least two values on the stack Pop two values off the stack (y, x) and then set cursor location to (x, y). If out-of-bound, wrap around
> Map-wincrement (width increment) None Increase the map's width by one
< Map-wdecrement (width decrement) Map width greater than 1 Decrease the map's width by one
v Map-hincrement (height increment) None Increase the map's height by one
^ Map-hdecrement (height decrement) Map height greater than 1 Decrease the map's height by one
W Map-readwidth None Push a value onto the stack equal to the map's width
H Map-readheight None Push a value onto the stack equal to the map's height
X Map-readx None Push a value onto the stack equal to the cursor's X coordinate
Y Map-ready None Push a value onto the stack equal to the cursor's Y coordinate