Morshu

From Esolang
Jump to navigation Jump to search

Morshu is an esolang based on the voice lines of Morshu.

Context

There is a game called Link: The Faces of Evil. In this game, there is a character called Morshu.

This character has been used as a meme where people get this character to say absurd things.

The character calls his money "rubies" instead of "rupees" because that is what the currency is called in that game.

Specification

Each line of text is separated by a newline.

Commands
Text Function Example
Sorry, Variable. way of putting the variable before other sentences without doing anything to it Sorry, Link. I can't give credit! (indicates that what "I can't give credit" does now applies to the variable "Link")
It's yours, Variable. increments variable based on "one plus the number of commas" in the first sentence of the line Lamp oil, rope, bombs. It's yours, my friend. (increments value of "my friend" by 3)
It's yours, Variable, as long as you have enough rubies. decrements variable based on "one plus the number of commas" in the first sentence of the line Lamp oil, rope, bombs. It's yours, my friend, as long as you have enough rubies. (decrements value of "my friend" by 3)
text which contains a variable or is split into commas. You want it? prints the value of the last variable in the line before this sentence if it is one of the sentences above, otherwise prints a value equivalent to one plus the number of commas in the previous line Lamp oil, rope, bombs. You want it? (prints the value "3")
Sorry, Link. You want it? (prints the value in the variable "Link")
Come back when you're a little... some number of m's... richer! every time the last variable in the line before this sentence hits that number of m's exactly from some other value, the thread at that line starts executing the line under this statement / these statements; works with zero m's as well Sorry, Link. Come back when you're a little... mmm... richer! (indicates the code should resume from the line under this line once the value of "Link" is exactly three)
I can't give credit! takes a number from input and puts the value into the variable in the sentence before, and if the input is not a number, adds the ASCII values of the input together and puts them in the variable Sorry, Link. I can't give credit! (indicates that the value of "Link" is now dependent on input)
Any other sentence No-op / comment It will bring health to your body and nourishment to your bones. (does nothing, doesn't throw an error)

Variables are instantiated when they are first mentioned and cannot be deleted and re-instantiated afterwards. Assuming the variable x is first mentioned in the sentence Sorry, x., the sentence would instantiate the variable x with the value 0 the first time it is read and do nothing on any subsequent pass. Meanwhile, if it was first mentioned in a sentence like Lamp oil. It's yours, x., that would be equivalent to assigning the value 1 to x the first time it is read and would increment x by 1 on any subsequent passes.

Multiple operations can happen on a single line, where they happen sequentially.

The sentences have to end with punctuation to be valid sentences.

Any other sentences are taken to be comments. It is impossible to turn a sentence which would be a valid Morshu command into a comment except by rewording it so it's no longer a valid Morshu command.

Clarification

To be clear, these are what specific lines do in paragraphs on their own.

  • It's yours, Variable. - increments variable twice (two pieces of text separated by comma)
  • It's yours, Variable, as long as you have enough rubies. - decrements variable three times (three pieces of text separated by commas)
  • Sorry, Variable. It's yours, Variable. - increments variable twice (two pieces of text separated by comma)

Multithreading

The "come back when" operation can result in multiple lines being executed "at the same time". In any instance of this, the command earliest in the program runs first, and any threads pointing at the same line merge into the same thread.

For example, the following program starts at line 1, then immediately jumps to both lines 4 and 7 (under lines 3 and 6).

It's yours, Link.
This line won't be read.
Sorry, Link. Come back when you're a little... mm... richer!
These lines will be read "at the same time".
Sorry, Link, I can't give credit!
Sorry, Link. Come back when you're a little... mm... richer!
These lines will be read "at the same time".
It's yours, Link. You want it?

In any instance of this, the command earliest in the program runs first. So command 4 would run, then 7. Then on the next step, when both threads move to the next line, the thread at line 5 takes input. Now, if the user doesn't enter zero, the code adds two to the variable "Link" and outputs it, at which point the first command ends. Then the code once again adds two to "Link" and outputs it. If the user enters two, this doesn't change the value of the variable.

However, if the user enters zero, then the value of the variable is zero. Because two is added before the variable can be output, nothing is output, but now the execution at line 8 goes to 4 and 7 (again) because the variable "Link" has gone from being two the first time to being zero to being two again. At the same time, the line which was previously at line 5 goes to line 6. Therefore, lines 4, 6, and 7 are being executed in that order, collectively doing nothing. In the next step, line 5 takes input. The options now are to enter zero or a nonzero number n.

If the nonzero number is entered, n+2 will be printed on this step. On the next step, n+4 will be printed on the next step, and n+6 will be printed last, two steps later.

However, if zero is entered, the thread previously at line 8 goes to 4 and 7. At the same time, the thread previously at line 7 goes to line 8 and the one previously at line 5 goes to line 6. Now lines 4, 6, 7, and 8 execute at the same time, so 2 is printed once. In the next step, 5, 7, and 8 run. If a nonzero number is entered, see the first paragraph. If zero is entered, see this paragraph.

To be clear, the language can create actual infinite loops, and this is more so a cautionary example about the dangers of taking user input in this language. On the other hand, there's probably an upside to this.

Programs

Morshu's Dialogue

Sadly, Morshu's dialogue doesn't make very exciting Morshu code.

The individual lines are:

Lamp oil, rope, bombs. You want it? It's yours, my friend, as long as you have enough rubies. - prints out 3 and assigns the value of negative 3 to the variable "my friend".

Sorry, Link. I can't give credit! Come back when you're a little... mmm... richer! - puts a value from input into "Link".

Concatenating these in the order Morshu says them doesn't change the behavior of the individual lines in any meaningful way. All of the following things basically do the exact same thing in the exact same way.

Way 1: All on the same line

Lamp oil, rope, bombs. You want it? It's yours, my friend, as long as you have enough rubies. Sorry, Link. I can't give credit! Come back when you're a little... mmm... richer!

Way 2: Two separate lines (one for each variable

Lamp oil, rope, bombs. You want it? It's yours, my friend, as long as you have enough rubies.

Sorry, Link. I can't give credit! Come back when you're a little... mmm... richer!

I don't think there are any other grammatical ways to arrange these lines in Morshu.

Infinite Loop

Lamp oil. It's yours, Link. Come back when you're a little... m... richer!
Lamp oil. It's yours, Link.
Lamp oil. It's yours, Link, as long as you have enough rubies.

Sets "Link" to 1, then 2, then 1, and repeats this indefinitely.

Prints 1 to 9

Sorry, looping variable. Come back when you're a little... ... richer!
Begin for loop. It's yours, looping variable.
Additional data. It's yours, Link. You want it?
End for loop. It's yours, looping variable, as long as you have enough rubies.
Sorry, Link. Come back when you're a little... mmmmmmmmmm... richer!

This prints the integers from 1 to 9. It goes to the statement at the end before printing anything.

I guess this is more similar to an infinite loop where you can break out of the loop.