Better-machine

From Esolang
Jump to navigation Jump to search

A Better-machine is a derivative of the Truth-machine program type. It was devised from User:ZachMadeAnAltBecauseHeLostThePassword (aka me!) to be a test to see if an esolang is humanly usable. It tests the following capabilities:

  • Addition and Subtraction
  • I/O
  • Control Flow
  • Arrays
  • Bounded and Unbounded Repetition
  • Termination

The format of a Better-machine is like this (made using pseudo-code)

array = [getInput(), getInput()]
difference = array[1] - array[2]
if (array[1] == array[2]) {
  repeat array[1] + array[2] times {
    outputToConsole("0")
  }
  endProg
} else {
  repeat forever {
    outputToConsole("1")
  }
}

In languages without array capabilities, a better-machine may use 2 variables in place. In esolangs without input, a better-machine may use a predetermined value in place. If an esolang does not have output, it may fill in memory with 1s. The essence of a better-machine is, similar to it's ancestor, the truth-machine, that some part of it, whether in the memory the program is using or in the program's code, uses a group of variables to decide whether A or B performs, and the program contains the capacity (namely, program code) to do either of two possible things: in case of A the machine/program will perform a varied repetition, in case of B it will run without termination.

Implementations

C++

#include<bits/stdc++.h>
using namespace std;

int a[2];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> a[0] >> a[1];
    int h = a[0] - a[1];
    if (h == 0) {for(int i = 0; i < (a[0] + a[1]); i++){cout << 0;}}
    else {while (1){cout << 1;}}
    return 0;
}

Harmonity

x@aexp <- stdinout; y@aexp <- stdinout;
if x = y then do for i in range 1 (x + y) 1 do stdinout <- 0 end else do while True do stdinout <- 1 end end

Java

import java.util.Scanner

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] array = {input.nextInt(), input.nextInt()};
        int difference = array[1] - array[2]
        if (difference == 0) {
            for (int i = 1, i <= array[1] + array[2], i++) {
                System.out.print("0")
            }
        } else {
            while (True) {
                System.out.print("1")
            }
    }
}

Python

a, b = int(input()), int(input())
if (a - b) == 0:
    for i in range(a + b):
        print(0)
else:
    while True:
        print(1)

Raymond

x@②←⎕;y@②←⎕;x=y?{[i∈ρ1 (x+y) 1]`{⎕←0}}:{(!)↘{⎕←1}↖}

Rizzlang

Sigma 1 asks chat what is their rizz level as a gyatt size.
Sigma 2 asks chat what is their rizz level as a gyatt size.
Nah, sigma 3 literally has sigma 1's rizz rn
Sigma 3 aint got no sigma 2's rizz rn
Nah, sigma 4 literally has Rizzler-Level Rizz rn
Nah, sigma 4 legit has more Rizzler-Level Rizz rn
Nah, sigma 4 legit has more Rizzler-Level Rizz rn
I'ma fanum tax to the oh shit skibidi if sigma 3 has more rizz than sigma 6
Nah, sigma 5 literally has sigma 1's rizz rn
Nah, sigma 5 legit has more sigma 2's rizz rn
Yo lemme declare this position loopin time skibidi
I'ma let sigma 6 start rizzin' rn
Sigma 5 aint got no Rizz rn
I'ma fanum tax to the last skibidi if sigma 5 has more rizz than sigma 6
Alr I'm done fanum taxing these sigmas
Yo lemme declare this position oh shit skibidi
Nah, sigma 6 literally has Rizz rn
I'ma let sigma 6 start rizzin' rn
I'ma fanum tax to the last skibidi

SletScript

\#a:\#b:?=+a-b 0{\#s+a b~"+1+s 1 1i.0}'1.1