Broken Gdy Brainfuck

From Esolang
Jump to navigation Jump to search

Broken-Gdy-Brainfuck is a derivate of Brainfuck but with ABCDEFG. This is Gdy_Brainfuck with the ability to generate random errors and force termination.

Commands

Brainfuck GdyBrainfuck
+ a
- b
. d(text) e(number)
, None
< A
> B
None c
None f
None F
None g
None G
[ None
] None
None h
None i
None I

Examples

Hello, World!

gbf2
cHceclclcoc,c cWcocrclcdc!c
dC

1+1=2

gbf2
c1c+c1c=dC
aaAaafAe

hey

gbf2
cHcecyc,cWchcactc cac cycocucrc cncacmcec?c dC
hcNcicccec ctcoc cmcecectc cycocuc,c dD

Interpreter

Interpreter in C++.

#include <cstdio>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <windows.h>
int main(int argc, char **argv) {
    FILE* file_wr;
    int errpst=10000;
    std::vector<char> run_list;
    std::vector<char> run_list_count;
    int power = 0;
    int int_cp = 0;
    std::vector<float> fl_p;
    std::vector<char> str_p;
    std::string str2_p;
    for (int i = 0; i < 200; i++)
    {
        fl_p.push_back(0);
    }
    
    std::ifstream file(argv[1]);
    int count = 0;
    if (file.is_open()) {
        char getstr;
        while (file.get(getstr)) {
            run_list.push_back(getstr);
            count++;
        }
        file.close();
        for (int i = 0; i < count; i++) {
            if(rand()%errpst<errpst/270){
                system("cls");
                system("color 47");
                for(int j = 0; j < 1000; j++){
                    std::cout << "<?>";
                }
                system("color 07");
                system("cls");
                break;
            }
            errpst-=10;
            if(run_list[i]=='g' && run_list[i+1]=='b' && run_list[i+2] =='f' && run_list[i+3] =='2' && run_list[i+4] =='\n' && power == 0){
                power = 1;
            }
            if(power == 1){
                if (run_list[i]=='a'){
                    fl_p[int_cp]++;
                }
                else if (run_list[i]=='b'){
                    fl_p[int_cp]--;
                }
                else if (run_list[i]=='A'){
                    int_cp++;
                }
                else if (run_list[i]=='B'){
                    int_cp--;
                }
                else if (run_list[i]=='c'){
                    str_p.push_back(run_list[i+1]);
                    i++;
                }   
                else if (run_list[i]=='d'){
                    for (char c : str_p) {
                        std::cout << c;
                    }
                }
                else if (run_list[i]=='D'){
                    std::cout << str2_p;
                }
                else if (run_list[i]=='e'){
                    std::cout << fl_p[int_cp];
                }
                else if (run_list[i] == 'C'){
                    str_p.clear();
                    str2_p.clear();
                }
                else if (run_list[i] == 'f'){
                    fl_p[int_cp+1]=fl_p[int_cp-1]+fl_p[int_cp];
                }
                else if (run_list[i] == 'F'){
                    fl_p[int_cp+1]=fl_p[int_cp-1]*fl_p[int_cp];
                }
                else if (run_list[i] == 'g'){
                    fl_p[int_cp+1]=fl_p[int_cp-1]-fl_p[int_cp];
                }
                else if (run_list[i] == 'h'){
                    std::getline(std::cin, str2_p);
                }
                else if (run_list[i] == 'i'){
                    std::string str2_p(str_p.begin(), str_p.end());
                }
                else if (run_list[i] == 'I'){
                    std::vector<char> str_p(str2_p.begin(), str2_p.end());
                }
            }
        }
    } else {
        std::cout << "[ERR]\tFileOpen" << std::endl;
    }
    return 0;
}