Algorithm BF-生成伪随机数

Algorithm BF-生成伪随机数,algorithm,random,brainfuck,esoteric-languages,Algorithm,Random,Brainfuck,Esoteric Languages,我正在寻找一种代码,用深奥的语言brainf***将一个伪随机数分配给一个记忆单元。我发现了,但觉得有点混乱。据我所知,这是一个“需要一些组装”(没有双关语意图?)的样本。运行它会产生一个近乎无限的循环。我也看过维基百科的文章,但仍然有些困惑 我正在寻找一个可以运行的简单代码段。我不在乎它是否影响周围的细胞。我只要求对示例进行良好的评论。我使用了您提到的页面上的算法,为我正在编写的brainfuck编译器实现了RNG。那里的代码不难使用。将所有变量名(如temp0、temp1、randomh、r

我正在寻找一种代码,用深奥的语言brainf***将一个伪随机数分配给一个记忆单元。我发现了,但觉得有点混乱。据我所知,这是一个“需要一些组装”(没有双关语意图?)的样本。运行它会产生一个近乎无限的循环。我也看过维基百科的文章,但仍然有些困惑


我正在寻找一个可以运行的简单代码段。我不在乎它是否影响周围的细胞。我只要求对示例进行良好的评论。

我使用了您提到的页面上的算法,为我正在编写的brainfuck编译器实现了RNG。那里的代码不难使用。将所有变量名(如temp0、temp1、randomh、randoml等)放入其中,并给它们一个数字。这将是该变量的单元格编号。然后,只需为变量插入必要的>和<符号。这是第一部分的一个例子。temp0到temp5的单元格编号为0到5,randomh为6,randoml为7:

pointer starts at 0

pointer is at 0 and need to go to temp0 (cell 0) so do nothing
temp0         [-]
pointer is at 0 and need to go to temp1 (at cell 1) so move one position to the right
temp1        >[-]
pointer is at 1 and need to go to temp2 (at cell 2) so move another position to the right
temp2        >[-]
pointer at 2 and needs to go to 3 so move another position to the right
temp3        >[-]
pointer at 3 and needs to go to 4 so move another position to the right
temp4        >[-]
pointer at 4 and needs to go to 5 so move another position to the right
temp5        >[-]

pointer at 5 and needs to go to 6 so move one to the right
randomh   >[
    pointer at 6 and needs to go to 0 so move 6 to the left
    temp0    <<<<<<+
    pointer at 0 and needs to go to 6 so move 6 to the right
    randomh  >>>>>>-]
指针从0开始
指针位于0,需要转到temp0(单元格0),因此不执行任何操作
temp0[-]
指针位于0,需要转到temp1(单元格1),因此向右移动一个位置
temp1>[-]
指针位于1,需要转到temp2(单元格2),因此向右移动另一个位置
temp2>[-]
指针指向2,需要转到3,因此向右移动另一个位置
temp3>[-]
指针指向3,需要转到4,因此向右移动另一个位置
temp4>[-]
指针指向4,需要转到5,因此向右移动另一个位置
temp5>[-]
指针指向5,需要转到6,所以向右移动一个
随机H>[
指针指向6,需要转到0,因此向左移动6
temp0-]

对代码中的每个变量都要这样做。此算法的重要之处在于,分配给randomh和randoml的单元格不会被任何其他代码触及,因为它们包含随机数种子(每次运行此代码时都会更改)

BrainfuckMachine IDE附带的此代码示例对我来说效果良好

>>>++[
    <++++++++[
        <[<++>-]>>[>>]+>>+[
            -[->>+<<<[<[<<]<+>]>[>[>>]]]
            <[>>[-]]>[>[-<<]>[<+<]]+<<
        ]<[>+<-]>>-
    ]<.[-]>>
]
"Random" byte generator using the Rule 30 automaton.
Doesn't terminate; you will have to kill it.
To get x bytes you need 32x+4 cells.
>++[
[>>]+>>+[
-[->>+[>[-