Rooms

From Esolang
Jump to navigation Jump to search

Rooms is a programming language that uses Rooms and 2d stuff

Stuff to know

Rooms

Define rooms by writing <name>**= (“**=“ because it would make it rare in rooms)

A**=
nothing

Note: the first defined room is the start room and when entering a room or starting the program, it starts at top-left corner, also all lowercase letters are just letters and do nothing like the space character “ “, so the “nothing” does nothing

Add # after the = and a better name, unused in program

N**= #not gate

Doors

Doors to move to other rooms <name>

A**=
B
B**=
nothing

Note: doors just lead to a copy of the defined room that the door leads to, so multiple doors to the same place is possible, so is a room containing a door to that room

^><v

Arrows

A**=
>  v

^  <

Pickup

Pickup the next command “*” or 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or lowercase letters (also brings through doors), if the next command is a comment, don’t pick up anything

A**=
>*B
B**=

Note: the pickup is like a stack so multiple pickups is possible

A**=
>*0*1*2*3*4*5*l*o*w*e*r*c*a*s*e

Place

Place the thing being held behind the command, if none, do nothing “+”

A**=
>*1 +v
   *
   ^ <

Note: the one to put the held thing in front of the command is "-"

A**=
>*v- 
    *
    0

Note: also stack

A**=
>*0*1 + +

Delete

Delete the thing being held “~”

A**=
>*1~

Skip

Skips the next command "!"

A**=
>*!Q
Q**=
>- v*0
   *
   1

Split

Split the current pointer in two pointers turned right and normal, the right one contains the first one in the stack, the normal one contains the rest ":"

A**=
v
>*0*1:-!1
     -
     !
     0

Return

Result of room “@“

A**=
>*B@

Note: when code pointer goes on @, it goes to the room it came from to get there (going to the door it came from) facing the direction it entered the door and now the code pointer is holding the result, if it did not come from any door, it prints the thing it’s holding and the program stops

Run With Args

run the currently held thing with the thing to the right of it "&"

A**=
>*B&@
   B
B**=
>&@
 B
#recursion

No Args

A**=
>*B&@
B**=
>~*0@

Condition

If the result of the room you are holding is 1 (or if the thing picked up a 1), turn right, else left, normal left 0 right 1 “?”, opposite left 1 right 0 “¿”

T**= #test
>*0N@
N**= #not gate
>v@
  1
  *
 >?
  *
  0
  @

Rooms act like functions

Rooms act like zero or one input functions, unless you include currying (a term in lambda calculus), then infinite

T**= #test
    @
>*0A +v
    1
    *
    ^ <
N**= #not
>  v
@0*?*1@
A**= #and
>  v
@I*?*0@
I**= #identity
>@

The result is the AND gate applied to the inputs 0 and 1, which results in 0

Auto Run what you are holding

R**= #run
v@
> +v
 ^ <

Data

D**= #data
>  %*0D
D0*?*1D

% makes you turn right if you are holding anything

Print

A**=
>**&**&**&**&**&**&@
   h  e  l  l  o  !

Pickup Pickup

A**=
**- 0@

Output: 0

Delete pointer

Use "#" to remove pointer

A**=
>#

Examples

Hello world

A**=
>*h*e*l*l*o* *w*o*r*l*d*!@

Run on run

A**=
>*I*1R@
R**=
v @  
>: +#
 v
 >^
I**=
>@

! detector

Q**=

>- v*!@
   *
    
   @