Watnoxt

From Esolang
Jump to navigation Jump to search

Watnoxt is an interpreted/compiled/transpiled, binary, 2D-ish, wanna-be Turing tarpit, created by User:Vallee152 in 2022. It only has 3 reserved characters and it was initially inspired by brainfuck. This program's Turing completeness is currently unknown. Its name is based off of the expression, "whatnot," and the nature of how this language operates ("not" is mixed with the word, "next"). Watnoxt programs use the file extension of .wn.

Overview of the language

There are only 3 reserved characters. The 3 of those are !, >, and ?, while the rest of the characters are used as NOPs/comments. Each instruction (including NOPs) causes the program pointer to move 1 to the right. If the program pointer reaches the end of a line, it will typically go to the beginning of that same line, although this depends on the mode. A mode is tied to the line-number, it defines what each character does and what happens at the end of the line. In total, there are 5 modes.

Each mode

Declaration mode

Line 1 of a Watnoxt program is the Declaration Mode. It is the most different from any other mode, as the 3 instruction characters work differently from anywhere else. This line sets up the size of the data tape, the initial values, and the initial position of the data pointer. This is only ran once because its only use is to create the array. Below is what each character does in this mode. The rest of the lines will have the characters act as shown for teh Termination Mode. Once the program pointer reaches the end of this line, it goes to the start of line 2.

Command Description
> Increase the length of the tape by 1 and move the data pointer to the right.
If n1 of these are used, the data tape will be a single cell.
! Set the current data cell to 1.
? Set the data pointer's position to this cell when line 2 is first ran.
If this isn't used, the data pointer will start on cell 0.

Termination mode

Line 2 of a Watnoxt program is the Termination Mode. If the program pointer gets to the end of this line, the program terminates. All the other modes will loop back around to themselves and, because of this, all programs must end on line 2. This mode uses the instructions shown below.

Command Description
> move the data pointer right by 1. Wraps around to cell 0 when at the end of the data tape.
! Invert the current cell on the data tape.
? If the current cell on the data tape is equal to 1,
then move to the next line (program pointer still moves right by 1)

Output mode

Line 3 of a Watnoxt program is the Output Mode. If the program pointer gets to the end of this line, the program outputs the first 7 bits of the tape as an ASCII value. The ASCII value is laid out with cell 0 as the highest bit and cell 6 as the lowest. There is no specific process for a tape smaller than 7 bits, but it could output an (unsigned) integer value if the interpreter/compiler/transpiler is made that way. This mode uses the instructions shown for Termination Mode.

Input mode

Line 4 of a Watnoxt program use Input Mode. If the program pointer gets to the end of this line, the program takes an input of a 7-bit ASCII value and stores it in the first 7 bits of the array, then it loops to the beginning of this line. Once again, there is no specific process for a tape smaller than 7 bits, but it could e set up to take an (unsigned) integer value. This mode uses the instructions shown for Termination Mode.

N-act mode

All lines numbered 5 and up in a Watnoxt program use N-act Mode (No Action Mode). If the program pointer gets to the end of this line, all it does is it loops to the start of the current line. This mode uses the instructions shown for Termination Mode.

Program examples

There isn't a Hello World program here because I didn't want to make one.

Hi program

When ran, this program will output hi.

!>!>>!>>>!?
?
?!

Cutie program

When ran, this program will output cutie.

!>!>>>>!>!>!?
.......................................................?
>>>?>.................?>!............?!>>>...........?
....>>>>?>>>>!>!>!>>!>?>>>>>>>>!>!>>>?!>>>>>>!>>!>!>>??
.........>>>>>>>>!>...................................??

Truth machine

Your standard Truth Machine. When fed a 1, it outputs 1 forever. When fed a 0, it outputs a 0 and then terminates. Run program, input either a 0 or a 1, and let it run.

>>>>>>>!?
.?.!.?
!??!>.!>>>>>>>
..?!?

Addition program

This program takes an input of two single-digit numbers, adds them together, and gives the output. Do note that any outputs that should be double-digit come out as a single ASCII character.

>>>>>>>>>>>>>!?>
?..............>??
?...............??
>?>>>>>>>>>>>>>>?
..?..............>>>>>>>>?>>>>>>>.?
...?......................>>>>>?!>>................?
....?...........................!>>>>>>>>>>>>>>?!>>>................?
.....?..........................................!>>>>>>>>>>>>>>?!>>>>................?
......?.........................................................!>>>>>>>>>>>>>>?!>>>>>...............?
.................?..............................................................!>>>>>>>>>>>>>>!>>>>>>?
>>>>>>>?>>>>>>>>.?................?
........>>>>>?!>>>................?................?
..............!>>>>>>>>>>>>>>?!>>>>................?...............?
?.............................!>>>>>>>>>>>>>>?!>>>>>...............?
.................?............................!>>>>>>>>>>>>>>!>>>>>>?
>>>>>>?>>>>>>>>>.?................?
.......>>>>>?!>>>>................?...............?
?...........?!>>>>>>>>>>>>>>?!>>>>>...............?
.................?...........!>>>>>>>>>>>>>>!>>>>>>?
>>>>>?>>>>>>>>>>.?...............?
?.....>>>>>?!>>>>>...............?
....?.......!>>>>>>>>>>>>>>!>>>>>>?
..?!??.............................>>>>>>>>>>>>>?>>>>>>>>>>
?!?..?....................?......................>>>>>>>>>>
...!..!>>>>?>>>>>>>>>>..?!??
....?.......>>>>>>>>>>?!?..?
..?!??...................!..!>>>>?>>>>>>>>>>
?!?..?....................?.......>>>>>>>>>>
...!..!>>>>?>>>>>>>>>>..?!??
............>>>>>>>>>>?!?..?......................?
?........................!..!>>>>?>>>>>>>>>>....?!?
................?.................>>>>>>>>!>!>?!??.?
..!>>>>>>>>>>!?>??.............................!..!

3-state busy beavers

Here is the conversion of two 3-state, Busy Beaver programs. To help with changing states, each cell used by the beaver has a gap. The code has been commented to show you what does what. Do note that because of Watnoxt's nature, you will get a few characters outputted while running these programs, because the program pointer will loop around on line 3. With how it is possible to translate Turing machine code to Watnoxt, can this language be considered Turing complete? This is a question instead of a statement because of the fixed memory.

14-step busy beaver

.>.>.>.>.>.>!?>.>.>.>.>.>.>. 3-state busy beaver program
.?....the part all the way to the right are paths from state to state...!.??
>!!state 1?if 0, then set 1, move right, and goto state 2!>...........!?...?!
...........if 1, then set 1, move left,  and goto state 3.>>>>>>>>>>>.!??...?
>..state 2?if 0, then set 1, move left,  and goto state 1!>>>>>>>>>>>.!??!..!!
...........if 1, then set 1, move right, and goto state 2.>...........!???
>..state 3?if 0, then set 1, move left,  and goto state 2!>>>>>>>>>>>.!???!
...........if 1, then set 1, move right, and goto state 0.>...........!?.??

21-step busy beaver

.>.>!?>.>.>.>.>.>.>.
.?the part all the way to the right are paths from state to state...?...!
>!!state 1?if 0, then set 1, move right, and goto state 2!>.......!?.!
...........if 1, then set 1, move right, and goto state 0.>.......!?.?
>..state 2?if 0, then set 1, move left,  and goto state 2!>>>>>>>...?!!
...........if 1, then set 0, move right, and goto state 3!>.......!?.?
>..state 3?if 0, then set 1, move left,  and goto state 3!>>>>>>>..!!.?
...........if 1, then set 1, move left,  and goto state 1.>>>>>>>.!?...?

Implementations

There is currently one implementation of this language in the form of a transpiler. It is written in VB.NET and it transpiles into VB.NET. Feel free to make your own interpreters, compilers, and transpilers.

Module Module1
    Sub Main()
        Dim SourceFile As String : Dim DestFile As String : Dim SFileContent As String : Dim SFileSplit() As String
        Dim DFileContent As String : Dim Bell As Boolean = True : Dim TmpInt As Integer : Dim JumpTo As String
        Dim LineNum As Integer
        While Bell
            Console.Write("Source file?" & vbNewLine & ">")
            SourceFile = Console.ReadLine()
            SFileContent = My.Computer.FileSystem.ReadAllText(SourceFile)
            Console.Write(SFileContent & vbNewLine)
            Console.Write("Is this correct? (Y if correct)" & vbNewLine & ">")
            Bell = Not Console.ReadLine() = "Y"
        End While
        Console.Write("Destination file?" & vbNewLine & ">")
        DestFile = Console.ReadLine()
        SFileSplit = Split(SFileContent, vbNewLine)
        DFileContent = Line0(SFileSplit(0)) & vbNewLine
        LineNum = SFileSplit.Length - 1
        For i = 1 To LineNum
            TmpInt = i Mod LineNum + 1
            JumpTo = TmpInt & "-" & (Len(SFileSplit(TmpInt)) - 1)
            DFileContent = DFileContent & LineOth(SFileSplit(i), i, JumpTo)
        Next
        My.Computer.FileSystem.WriteAllText(DestFile, DFileContent, False)
        Console.Write("DONE!" & vbNewLine & ">")
        Console.ReadLine()
    End Sub
    Function Line0(Line As String)
        Line0 = "Dim OnCell As Integer = " & CTOnCell(Line) & vbNewLine &
            "Dim Conversion As Integer = 0" & vbNewLine &
            "Dim Cells() As Boolean = " & GiveArray(Line) & vbNewLine
    End Function
    Function CTOnCell(Line As String)
        CTOnCell = 0
        For j = 0 To Len(Line) - 1
            If Line(j) = ">" Then
                CTOnCell += 1
            ElseIf Line(j) = "?" Then
                Exit Function
            End If
        Next
        CTOnCell = 0
    End Function
    Function CountStr(Large As String, Small As String)
        CountStr = Len(Large) - Len(Replace(Large, Small, ""))
    End Function
    Function GiveArray(Line As String)
        Dim ConstructArray(0) As Boolean
        Dim TmpStr As String
        Dim CellCount As Integer = 0
        For j = 0 To Len(Line) - 1
            TmpStr = Line(j)
            If TmpStr = ">" Then
                CellCount += 1
                ReDim Preserve ConstructArray(CellCount)
            ElseIf TmpStr = "!" Then
                ConstructArray(CellCount) = True
            End If
        Next
        GiveArray = "{"
        For j = 0 To ConstructArray.Length - 2
            GiveArray = GiveArray & CStr(ConstructArray(j)) & ", "
        Next
        GiveArray = GiveArray & CStr(ConstructArray(ConstructArray.Length - 1)) & "}"
    End Function
    Function LineOth(Line As String, LineNum As Integer, NextEnd As String)
        Dim NextLine As Integer = CInt(Split(NextEnd, "-")(0))
        Dim EndColumn As Integer = CInt(Split(NextEnd, "-")(1))
        For j = 0 To (Len(Line) - 1)
            LineOth = LineOth &
                  "a" & LineNum & "a" & j & ":" & vbNewLine
            If Line(j) = ">" Then
                LineOth = LineOth &
                      "OnCell = (OnCell + 1) Mod Cells.Length" & vbNewLine
            ElseIf Line(j) = "!" Then
                LineOth = LineOth &
                      "Cells(OnCell) = Not Cells(OnCell)" & vbNewLine
            ElseIf Line(j) = "?" Then
                LineOth = LineOth &
                      "If Cells(OnCell) Then " & GtJmpLctn(j, NextLine, EndColumn) & vbNewLine
            End If
        Next
        LineOth = LineOth &
              EndLine(LineNum) & vbNewLine
    End Function
    Function GtJmpLctn(CrrntCol As Integer, NxtLn As Integer, EndCol As Integer)
        If CrrntCol >= EndCol Then
            GtJmpLctn = "GoTo a" & NxtLn & "aEnd"
        Else
            GtJmpLctn = "GoTo a" & NxtLn & "a" & (CrrntCol + 1)
        End If
    End Function
    Function EndLine(LineNo As Integer)
        EndLine = "a" & LineNo & "aEnd:" & vbNewLine
        If LineNo = 1 Then
            EndLine = EndLine &
                  "Console.WriteLine(vbNewLine & ""Program Ended"")" & vbNewLine &
                  "Console.ReadLine()" & vbNewLine &
                  "Exit Sub" & vbNewLine
        ElseIf LineNo = 2 Then
            EndLine = EndLine &
                  "Conversion = 0" & vbNewLine &
                  "For i = 0 To 6" & vbNewLine &
                  "Conversion *= 2" & vbNewLine &
                  "Conversion += Convert.ToInt16(Cells(i))" & vbNewLine &
                  "Next" & vbNewLine &
                  "Console.Write(Chr(Conversion))" & vbNewLine &
                  "GoTo a2a0" & vbNewLine
        ElseIf LineNo = 3 Then
            EndLine = EndLine &
                  "Conversion = Asc(Console.ReadKey().KeyChar)" & vbNewLine &
                  "For i = 0 To 6" & vbNewLine &
                  "Cells(6 - i) = Conversion Mod 2 = 1" & vbNewLine &
                  "Conversion = Conversion >> 1" & vbNewLine &
                  "Next" & vbNewLine &
                  "GoTo a3a0" & vbNewLine
        Else
            EndLine = EndLine &
                  "GoTo a" & LineNo & "a0" & vbNewLine
        End If
    End Function
End Module