Feedfish

From Esolang
Jump to navigation Jump to search

Feedfish is an esolang invented by User:None1, inspired by Deadfish and Mazerunner. It simulates how hard it is to feed a fish: A fish can't know if it is full or not, so if you give it more food when it is full, it will still eat the food.

Memory

Like deadfish, there is an accumulator, but the accumulator has two properties: value and energy. The energy is initially 3, if the energy becomes more than 3 or less than 1, the program will error.

Commands

It has one more command than deadfish: f, it increases the energy of the accumulator by 1. For every non-f command starting from the first command, the accumulator's energy is decreased by 1 after the command is executed.

Examples

XKCD Random Number

iififfio

Interpreters

Python 3

"""
Modified from the Deadfish Python interpreter by User:Tux1
"""
accumulator,energy = 0,3

while True:
    command = input(">> ")

    if accumulator == 256 or accumulator == -1:
        accumulator = 0

    if command == "i":
        accumulator += 1
        energy-=1
    elif command == "d":
        accumulator -= 1
        energy-=1
    elif command == "s":
        accumulator **= 2
        energy-=1
    elif command == "o":
        print(accumulator)
        energy-=1
    elif command == "f":
        energy+=1
    if energy<1 or energy>3:
        raise RuntimeError('Your fish is dead!')