Author Topic: Brainfuck Programs  (Read 16702 times)

0 Members and 1 Guest are viewing this topic.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Brainfuck Programs
« on: August 16, 2010, 12:40:17 am »
Brainfuck has become my new hobby. my average number of migraines per minute has skyrocketed. anyway, i decided i'd share some of my programs if anyone's interested. i'll edit in more as i go. if you program in brainfuck and want to add in a few, i'd gladly post them and give credit.

Addition
Code: [Select]
adds the first memory slot to the second
,>,<[>+<-]

Addition
Code: [Select]
adds the first memory slot to the second outputs the answer
,>,<[>+<-]>>++++++[<-------->-]<.

Subtraction
Code: [Select]
subtracts the second memory slot from the first
,>,[<->-]<.


i'll definitely add more later as i become familiar with the language


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Brainfuck Programs
« Reply #1 on: August 16, 2010, 01:37:53 am »
I remember checking this language before once, I sure would get confused a lot at it x.x

Can games be done with this language, by the way?
* DJ Omnimaga also hopes that Brainfuck becoming Nemo's new hobby doesn't mean the end of his calculator hobby D:

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: Brainfuck Programs
« Reply #2 on: August 16, 2010, 02:34:09 am »
I am fairly certain there are errors in this program but there is no freaking way I am going to debug it. anyway it is a xp calculator for stick adventures online written in brainfuck. It takes lvl for input and outputs the answer as an ascii character (or at least thats what it would do if it actually worked)

>+++++++++++++++[>>>>>+>+<<<<<<-]>>>>>
>[<<<<<<+>>>>>>-]+++++<<[-]<[-]<[-]<,----------
-------------------------------------->[<->++++++++++][<
+>-]<>,------------------------------------------------[<+>-]
<[>+>+<<-]>>[<<+>>-]<<[>>>>[<<<+>>>-]<<<[
>>>>[<<<+>+>>-]<<[>>+<<-]<[>+<<-[>>-<<]>>[
<-[>>-<<[-]]+>-]<-]>>+<<<]>>>>>[<<<<<+>>>>>
-]<<<<<[>>>>>+>+<<<<<<-]>>>>>>[<<<<<<+>>
>>>>-]+++++<<<<<-]+++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++
+++++++.>.

thats the most complex bf program I have ever written.

@DJ:
http://www.49-6-dev.net/takingovertheworlden.htm
http://jonripley.com/brainfuck/games/

« Last Edit: August 16, 2010, 02:51:43 am by miotatsu »

_player1537

  • Guest
Re: Brainfuck Programs
« Reply #3 on: August 16, 2010, 03:23:25 am »
Oooh, I love BrainFuck :D  Try this one on for size (routine sucks probably >.>)
Code: [Select]
->[->+>+>+<<<]>>>
[-<<<+>>>]<<<<
[->>[-<+>]>[->+<<+>]>[-<+>]<<<<]>,
Multiplies the first number by the second number, and leaves the result in the... 2nd slot I think... Line breaks were added for readability :D

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Brainfuck Programs
« Reply #4 on: August 17, 2010, 02:07:55 pm »
* DJ Omnimaga also hopes that Brainfuck becoming Nemo's new hobby doesn't mean the end of his calculator hobby D:

Worry no more. Now you can combine brainfuck with your calculator.

prgmBRAINFCK
Language is exactly like the real thing, ignores formatting and illegal characters. $0A is even new line. On compile, it only includes the subroutine that you need, the text input is like 50 bytes so you don't always want that.

Here are the specifics to make a source file. The first two characters must be "BF". Then there is an optional comma indicating safe mode (more info later). Finally the name of your program followed by an enter. That's it! Now go program to your heart's content.

Then to get it to compile. Store your source name in string 1. Then just run prgmBRAINFCK. It even warns you if you have different amounts of ['s and ]'s.

The safe mode I added is so that your programs will never clear ram. It puts a little subroutine before every ] that checks for ON presses.

Enjoy.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Brainfuck Programs
« Reply #5 on: August 17, 2010, 02:14:12 pm »
Haha, nice. Where does the memory pointer start, so we can be sure not to corrupt RAM?
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Brainfuck Programs
« Reply #6 on: August 17, 2010, 04:01:56 pm »
It uses appBackUpScreen. So as long as you don't do +[>[-]+]. You shouldn't have any problems.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Brainfuck Programs
« Reply #7 on: August 17, 2010, 04:05:39 pm »
Nice to know. :)
How hard (and how large in the generated program) would it be to support more characters? (Right now I'm thinking of the language's own []<>+-,. so I can run a self-interpreter ;D)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Brainfuck Programs
« Reply #8 on: August 17, 2010, 04:07:22 pm »
Does it start at the beginning or in the middle?  Like if we move back 1, are we out of the appBackUpScreen?  Oh and epic program ;D

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Brainfuck Programs
« Reply #9 on: August 17, 2010, 04:09:26 pm »
Interpreters normally don't define what happens if you go back beyond the zero cell, and I assume thepenguin77 would do the same. I'd guess that it starts at appBackupScreen, then.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Brainfuck Programs
« Reply #10 on: August 17, 2010, 04:25:17 pm »
Silly fix. You couldn't turn your calculator off if you used the key input.

Supporting extra characters is super easy. I currently have a big list of (cp xx \ jr nz, next)'s that I use. The finished product is output in pure assembly so it's size all varies with what you want. Very unoptimized assembly I might add. (32 straight inc (hl)'s in some cases)

The program starts right at the beginning of appBackUpScreen. If you need more space, use a whole bunch of >'s.

Here is a program that takes a 1 digit input, squares it, and outputs the 2 digit result.
Code: [Select]
:BF,AA
:,----- ----- ----- ----- ----- ----- ----- ----- ----- ---
:[
:>+
:>+
:<<-
:]
:>
:[
:>
:[>+>+<<-]
:>
:[<+>-]
:<<-
:]
:>>+++++ +++++.
:>[>+<-]     ;hex to decimal starts here (after the >), give it the number in (current) and it will output the result
:>
:>+++++ +++++
:<
:[
:>
:[>+>+<<-]
:>
:[-<<-[>]>]
:>
:[<<+>>-]
:>+
:<<<<
:]
:+++++ +++++
:>[<->-]<
:[>+<-]
:+++++ +++++ +++++ +++++ +++++ +++++ +++++ +++++ +++++ +++
:[>+>>>>+<<<<<-]
:>>>>>.<<<<.
:>+++++ +++++.

There's a hex to decimal converter in there. It just can't accept numbers that end in 0. 20 is 1:.

Edit:
   Forgot to attach program. Source's there too if you want it.
« Last Edit: August 17, 2010, 04:26:33 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Brainfuck Programs
« Reply #11 on: August 18, 2010, 12:17:44 pm »
lol nice program ThePenguin77 ;D

I remember juju2143 made one a few months ago but it was in BASIC and interpreted, so some stuff probably took an insane amount of time to execute. It was still cool, though.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Brainfuck Programs
« Reply #12 on: August 18, 2010, 12:25:28 pm »
Wow, that's neat.  Excellent job The Penguin! ;D

Offline patriotsfan

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 118
  • Rating: +2/-0
  • Go Pats!
    • View Profile
Re: Brainfuck Programs
« Reply #13 on: August 18, 2010, 09:00:18 pm »
Brainfuck on the calculator? That is pretty impressive to say the least. Awesome job! :D


Doomsday: 12/21/2012 6:11 AM EST 11:11 AM GMT

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Brainfuck Programs
« Reply #14 on: August 21, 2010, 12:22:50 pm »
* DJ Omnimaga wonders if Ztrumpet could write Starcraft in brainfuck