Snake Shit

From Esolang
Jump to navigation Jump to search

Language Overview

Snake Shit is an esoteric programming language where a snake is simulated moving around a grid. Each step, the snake moves in the direction that it is set to. If it's head is on any of the commands below, it will execute that command. Any other characters are ignored, though using _s for places that the snake would go is good practice. The snake can not crash into itself, but if the snake ever moves onto a space without a character, it will quit the program.

Instructions

Some commands take arguments. Arguments are found to the right of the current command.

Command Arguments Description
$ Direction : ^, <, v, or > Start : The snake starts here, and starts moving in the direction specified.
+ Number : Any number 0 or greater. Increase Length : Increase the snake's tail length by the number given.
- Number : Any number 0 or greater. Decrease Length : Decrease the snake's tail length by the number given (The tail length can not go below 0).
= Number : Any number 0 or greater. Set Length : Set the snake's tail length to the number given.
^ Set Direction Up : Change the snake's moving direction to up.
> Set Direction Right : Change the snake's moving direction to right.
v Set Direction Down : Change the snake's moving direction to down.
< Set Direction Left : Change the snake's moving direction to left.
@ Character : Escape codes are allowed for \n, \t, and \\. Save Length : Write the snake's length to a variable with the name specified.
% Character : Escape codes are allowed for \n, \t, and \\. Load Length : Set the snake's length to the value stored in a variable with the name specified.
~ Command : Another command. If : If the snake's length is not 0, run the command specified.
& Number Input : Wait until a number has been entered into the console and set the snake length to the user input.
? Number : Any number 0 or greater. Random Length : Set the snake length to a random number between 0 (inclusive), and the number specified (exclusive).
# Character : Escape codes are allowed for \n, \t, and \\. Print : Print the specified character to the console (without trailing newline).
* Print Length : Print the length of the snake tail to the console (without trailing newline).

Examples

Hello World

A simple program that prints Hello World!\n

$>#H#e#l#l#o# #W#o#r#l#d#!#\n

The snake starts at the $ and moves right because of the >. It then travels over the #s and prints the characters the right of them.

Test x10

This program prints test\n 10 times, then prints \nlol\n.

#\n
#!
#l
#o
#l  $v
#\n =10
~>__-1v
_   v_<
#\n #t
#t  #e
^#s_<

The snake start at the $ at moves downwards. It then sets its length to 10. It moves downwards and around the loop printing test\n before getting to the ?. Since the snake length is greater than 0, it will turn right, reduce it's length by one, and repeat it over again. Once the tail length is 0, it will not turn right, and instead print \nlol\n before quitting.

Number Guessing Game

This program will give you 7 tries to guess a number from 5 to 94, and will tell you whether your answer is too big or too small for each wrong answer.

>___%A_#Y#o#u# #L#o#s#e#!#\n#T#h#e# #C#o#r#r#e#c#t# #A#n#s#w#e#r# #W#a#s# *#.#\n
_
_ $>_#\n#W#e#l#c#o#m#e# #T#o# #T#h#e# #N#u#m#b#e#r# #G#u#e#s#s#i#n#g# #G#a#m#e#.#\n#\n_v
_  v___________________________________________________________________________________<
_  =7
_  @T                                        _ >_%A-1@D_v
_  ?90                                       _ _   >__%D_~vv
_  +5                                        _ _   @I   v_<>v
_  @A                                        _ _   -1   -1  %I
~>_>__%T_*# #T#r#i#e#s# #L#e#f#t#.#\n________v _   ^%I@D<   >~vv
@T v_________________________________________< _              _>__#T#o#o# #S#m#a#l#l#.#\n_v
-1 >_____#E#n#t#e#r# #A# #N#u#m#b#e#r#:# &@I___^              -1                          _
%T                                                            ~>__#T#o#o# #B#i#g#.#\n_____v
_  v______________________________________________________________________________________<
_  _                                                          _
_  _                                                          >#Y#o#u# #W#i#n#!#\n
_  >_____#I#n#c#o#r#r#e#c#t#!#\n#\n__________v
_                                            _
^____________________________________________<

Sample output:

Welcome To The Number Guessing Game.

7 Tries Left.
Enter A Number: 50
Too Small.
Incorrect!

6 Tries Left.
Enter A Number: 75
Too Big.
Incorrect!

5 Tries Left.
Enter A Number: 62
Too Small.
Incorrect!

4 Tries Left.
Enter A Number: 69
Too Big.
Incorrect!

3 Tries Left.
Enter A Number: 65
Too Small.
Incorrect!

2 Tries Left.
Enter A Number: 67
You Win!

Mirror-Machine

This approximation of a mirror-machine is restricted to unsigned non-negative integer inputs, and, as a corollary, not perfectly compliant to the specification:

$>_&@a_&@b_%av
             ~>_*_#\n_=0_@a_v   // If a not 0, print a, set to 0.
             v______________<
             %b
             @t
             ~>_-1_@t_~vv      // If b is not 1, print b.
             v_________<_
             %b         _
             *          _
             #\n        _
             v__________<
             %b
             v______________<  
             ~>_*_#\n_-1_@b_^  // While b is not 0, print b, decrement b.
   v_@b&_@a&_<                 // Input a, b.
   v_________________<
   %b                _
   ~>_-1_@b_%a_-1_@a_^         // Decrement a by b.
   %a                          // Print a - b.
   *
   #\n
   #A
   #B
   #C

Truth-Machine

$>_&_~v*
    >_v
    __*
    ^_<

Interpreter

  • Common Lisp implementation of the Snake Shit programming language.