Watnoxt

From Esolang
Jump to navigation Jump to search

Watnoxt is a 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. It's a wanna-be Turing tarpit, because it can only ever have a predefined amount of memory and the code has to change with the addition of more bits. It would otherwise be turing complete. Its name is based off of the expression, "what not," and the nature of how this language operates, "what? 1? next line!" 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 array, 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. Once the program pointer reaches the end of this line, it goes to the start of line 2.

Command Description
> append a zero to the array.
If none of these are used, the data array will be a single cell.
! Set the ending data cell to 1.
? Start with the data pointerat this cell's position.
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 and all the following modes use the instructions shown below.

Command Description
> Increment the data pointer by 1.
The pointer will wrap back around to the first cell of the array.
! Invert the value of the selected data cell.
? If the selected cell is equal to 1,
then move the program pointer down a line (it 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 array as an ASCII value. The ASCII value is outputted with cell 0 as the highest bit and cell 6 as the lowest. There is no specific process for an array smaller than 7 bits, but it could output an integer value if the interpreter/compiler/transpiler is made that way.

Input mode

Line 4 of a Watnoxt program is the 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 be set up to take an integer value.

Regular mode

All lines numbered 5 and up in a Watnoxt program use Regular 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.

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. Do note that to make this program compatible with the implementation in VB on this page, you need to replace the first line with >>>>>>!?.

!
?..?.?
?..?!?!
.?!?.!?

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 with Watnoxt's nature, you will get a few characters outputted while running these programs, because the program pointer will loop around on line 3. This sadly doesn't prove turing completeness, since they are stuck with very limited 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