BF Lite
Jump to navigation
Jump to search
BF Lite
BF Lite (or Brain**** Lite) is BF without input, output and arrays..
BF Lite is based off of Brainfuck
It was created by User:Yante
If you are making a BF Lite interpreter, Always start from the first cell!
| Command | Info |
|---|---|
| > | Moves the pointer 1 cell further. |
| < | Moves the pointer 1 cell farther. |
| + | Adds 1 to the cell the pointer is on. |
| - | Subtracts 1 from the cell the pointer is on. |
Example
+++>+++>+++>+++>+++ After you run this, the first 5 cells should be: 3,3,3,3,3
Interpreters
Python interpreter (Made on 3.9.4) by User:Yante
import time # Imports time module for displaying how long the program took to run.
code = "" # Your program. Do not change this to multiline! May break the interpreter
memory_size = 20 # How many cells to generate?
pointer = 0 # Where should the pointer be when program is run?
class BF: # The BF Lite class (responsible for running code)
def __init__(self,code,size,pointer): # Save stuff to self variable on init
self.code = list(code) # Your program
self.size = size # Memory size
self.pointer = pointer # Pointer location
self.memory = [0] * size # Generates empty cells
def run(self): # Run function (runs code)
for i in self.code: # For every item (stored as i) in self.code (the program)
if i == '>': # If item is >
self.pointer+=1 # Go 1 cell further
if i == '<': # If item is <
self.pointer-=1 # Go 1 cell farther
if i == '+': # If item is +
self.memory[self.pointer]+=1 # Add 1 to cell
if i == '-': # If item is -
self.memory[self.pointer]-=1 # Subtract 1 from cell
bfthing = BF(code,memory_size,pointer) # initalize the BF runner
print("Initalized.")
start_time = time.time() # Start time
bfthing.run() # Run the code! (The rest of the code will run after the program is finished.)
print(f"Code was ran! Took {start_time - time.time()}s")
print("Pointer Location:", bfthing.pointer)
print("Memory:", bfthing.memory)