3switchBF

From Esolang
Jump to navigation Jump to search

3switchBF is yet another brainfuck equivalent, in the form of a Turing tarpit, conceived then neglected by User:Bataais in August of 2013. Because of this, information beyond the general idea may not be accurate.

Instructions

Each BF command is represented with 3 switches: A, B, and C. Each switch can be toggled on or off. All 8 possibilities of the 3 switches represent the 8 BF commands. E is then used to run the switch configuration as a BF command.

A B C BF Equivalent
OFF OFF OFF >
OFF OFF ON <
OFF ON OFF +
OFF ON ON -
ON OFF OFF .
ON OFF ON ,
ON ON OFF [
ON ON ON ]
Instruction Action
A Toggles the A switch.
B Toggles the B switch.
C Toggles the C switch.
E Executes the BF instruction the switches represent.

Examples

Cat

ABEBEBCEBE

Translator to brainfuck

Written in Python.

def translate(code):
  d = "><+-.,[]"
  r = ""
  a, b, c = 0, 0, 0
  for c in code:
    if c == "A": a = 1 - a
    elif c == "B": b = 1 - b
    elif c == "C": c = 1 - c
    elif c == "E": r += d[a & (b << 1) & (c << 2)]
  return r