Discuss Scratch

PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

Welcome to the second Advanced Topics Challenge! The winner of the challenge, as per (recently begun) tradition, will be allowed to place this beautiful Round 2 medal in their signature:



The winner of the challenge will then be able to either create the next challenge or select someone else to do it for them. (For more details about the way these challenges are run, see the ATC#1 Topic.)

ATC#2:
The goal: Create a Branflakes* interpreter without using any data blocks.

Rules:
- The project should be used like this:
1) Project asks user to enter a program (via ask & wait)
2) Project asks user for program input (via ask & wait)
3) Project runs Branflakes program (using the input data from the user where appropriate) and displays the output using a think block (if the program is still running) or a say block (if the program is finished)
- No hacked blocks allowed (must be able to be recreated in regular editor)
- Error handling is not needed
- . and , commands should work with ASCII characters 32 through 126 (having 10 print a newline is not required)
- User input must be case-sensitive
- Cells should be bound to values an 8-bit system could store (0 to 255) and loop after that (*hint:* mod 256 every value)
- There should be an infinite number of cells in either direction (left/right)
- No data blocks are allowed to be used

This is a challenge for programmers, not lawyers. If you find a loophole, let me know. Nobody will have fun if you exploit it.

The first person to create and submit project which meets the criteria will be declared the winner. The winner will then be “passed the torch” to create the next ATC.

Trial Branflakes programs:
Hello world:
Code ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Input [no input]
Expected output Hello World!

Cell Size:
Code ++++++++[>++++++++<-]>[<++++>-]+<[>-<[>++++<-]>[<++++++++>-]<[>++++++++<-]+>[>++++++++++[>+++++<-]>+.-.[-]<<[-]<->]<[>>+++++++[>+++++++<-]>.+++++.[-]<<<-]]>[>++++++++[>+++++++<-]>.[-]<<-]<+++++++++++[>+++>+++++++++>+++++++++>+<<<<-]>-.>-.+++++++.+++++++++++.<.>>.++.+++++++..<-.>>-[[-]<]
Input [no input]
Expected output 8 bit cells

Fibonacci:
Code +++++++++++>+>>>>++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<+>>[-]]<<<<<<<]>>>>>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++++++++++++++++++++++++++++++++++++++++++++++.[-]<<<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]
Input [no input]
Expected output 1, 1, 2, 3, 5, 8, ... etc

Copy-cat:
Code ,[.,]
Input This will copy whatever you input into the output.
Expected output This will copy whatever you input into the output.

Good luck and have fun!

* I'm sure most of you know this, but in case not: The actual name of the language is not appropriate for Scratch, so we use the phrase “Branflakes” as a replacement. Googling “bf language” will get you to the right place, but be warned that the title isn't Scratch-safe.

Last edited by PullJosh (July 10, 2016 13:00:32)

lugga
Scratcher
500+ posts

[ATC#2] Branflakes

So no lists?

If that's the case then, well, umm, I can't do it…
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

Darn - half hour late! Oh well, by cell, you mean place in memory? And it needs to store an ASCII char? Sounds easy! So you are allowed to use blocks that remember things, just not data blocks? And also, the implementation can't possibly be required to be infinite either way, that would cause an overflow error at some point, no? Well anyway, sounds fun!

I will read up on BF and try to win this.
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

If I use recursion to do some stuff (which might cause a depth error at some point (due to Scratch's lack of tail-recursion thing - maybe impemented?) does that count as limiting memory?
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

Wait, so negative pointers exist right?
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

What do I do for values > 126 but < 256
?
Please - respond - I really want to win!
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

jokebookservice1 wrote:

If I use recursion to do some stuff (which might cause a depth error at some point (due to Scratch's lack of tail-recursion thing - maybe impemented?) does that count as limiting memory?
As long as it could work indefinitely in theory, it's fine. All of the example programs I listed are small enough to work in projects using lots of recursion.

jokebookservice1 wrote:

Wait, so negative pointers exist right?
It depends on the implementation, but in this case, yes:

First Post wrote:

- There should be an infinite number of cells in either direction (left/right)

jokebookservice1 wrote:

What do I do for values > 126 but < 256
?
Please - respond - I really want to win!
I'm not sure what you mean… If I had this program:
+[++]   this just counts up in the first cell forever
It should count like this:
0 (initially), 1, 2, 3, 4, 5, 6, …, 124, 125, 126, 127, 128, 129, …, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, …

If I were to count down instead, it would go like this:
0 (initially), 255, 254, 253, …, 3, 2, 1, 0, 255, 254, 253, …
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

Am I storing ASCII or numbers then?
NickyNouse
Scratcher
1000+ posts

[ATC#2] Branflakes

For brackets, since Scratch's recursion doesn't actually work can we use a list as a stack?
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

jokebookservice1 wrote:

Am I storing ASCII or numbers then?
You might need to do a bit of research to find out.
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

NickyNouse wrote:

For brackets, since Scratch's recursion doesn't actually work can we use a list as a stack?
I've created a project which can run all of the bf programs listed in the original post without using any data blocks. Some longer programs may cause the stack to explode, but don't worry about them. As long as all of the programs listed above are working (and you aren't just using a bunch of if blocks to see which one of the four listed is being run), you're all set.
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

PullJosh wrote:

jokebookservice1 wrote:

Am I storing ASCII or numbers then?
You might need to do a bit of research to find out.
Well your last example shows ASCII as output, so I suppose the answer must be ASCII? It is really confusing though…
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

jokebookservice1 wrote:

Well your last example shows ASCII as output, so I suppose the answer must be ASCII? It is really confusing though…
If I run this program:
+++++++++++++++++++++++++++++++++.
It will output the 33rd ascii character, which is an exclamation point. (There are 33 plus signs in that program.) If I run this program:
+++++++++++++++++++++++++++++++++ ---- ++++ -+ +- --++.
it will output the exact same thing (!). The program begins with 33 plus signs and then has some plus and minus signs which even each other out. The period (full stop) will still end up printing the 33rd ascii character.

Infer as necessary.
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

It has been over 2 hours, I really hope nobody is finishing

So far I have implemented <>. and have plans for all of them. I am using recursion. I am also using the (size) for a return value. I am adding 100 to the result because Scratch does not like tiny sizes.

Just in case anybody needs inspiration.
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

PullJosh wrote:

jokebookservice1 wrote:

Well your last example shows ASCII as output, so I suppose the answer must be ASCII? It is really confusing though…
If I run this program:
+++++++++++++++++++++++++++++++++.
It will output the 33rd ascii character, which is an exclamation point. (There are 33 plus signs in that program.) If I run this program:
+++++++++++++++++++++++++++++++++ ---- ++++ -+ +- --++.
it will output the exact same thing (!). The program begins with 33 plus signs and then has some plus and minus signs which even each other out. The period (full stop) will still end up printing the 33rd ascii character.

Infer as necessary.
What about:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. (132nd ACII Character does not exist; so what happens?)
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

jokebookservice1 wrote:

What about:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. (132nd ACII Character does not exist; so what happens?)
Those characters do exist (in this case it's this guy: ト). There are bf interpreters online which you can use to test out different behaviours and see what happens. In the instructions I said you only had to support 32 to 126, so I don't really care what happens with the others.
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

PullJosh wrote:

jokebookservice1 wrote:

What about:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. (132nd ACII Character does not exist; so what happens?)
Those characters do exist (in this case it's this guy: ト). There are bf interpreters online which you can use to test out different behaviours and see what happens. In the instructions I said you only had to support 32 to 126, so I don't really care what happens with the others.
Ok, mine currently outputs a ¬. So that means the Fibonacci is accessing the characters 0-9 not the values?
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

jokebookservice1 wrote:

PullJosh wrote:

jokebookservice1 wrote:

What about:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. (132nd ACII Character does not exist; so what happens?)
Those characters do exist (in this case it's this guy: ト). There are bf interpreters online which you can use to test out different behaviours and see what happens. In the instructions I said you only had to support 32 to 126, so I don't really care what happens with the others.
Ok, mine currently outputs a ¬. So that means the Fibonacci is accessing the characters 0-9 not the values?
Correct.
jokebookservice1
Scratcher
1000+ posts

[ATC#2] Branflakes

PullJosh wrote:

jokebookservice1 wrote:

PullJosh wrote:

jokebookservice1 wrote:

What about:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. (132nd ACII Character does not exist; so what happens?)
Those characters do exist (in this case it's this guy: ト). There are bf interpreters online which you can use to test out different behaviours and see what happens. In the instructions I said you only had to support 32 to 126, so I don't really care what happens with the others.
Ok, mine currently outputs a ¬. So that means the Fibonacci is accessing the characters 0-9 not the values?
Correct.
Ok.

I'm going to pretend to be a blogger and say what I have so far:

I have tested my character swapper that uses no data blocks, it works, but for it to work it has to be a part of the main thingy so I have no choice but to add even more args, including a bool flag that says whether it is swapping or not.

It seems to be going quite nicely, but I have another question: Do I have to account for comments?
PullJosh
Scratcher
1000+ posts

[ATC#2] Branflakes

jokebookservice1 wrote:

It seems to be going quite nicely, but I have another question: Do I have to account for comments?
It sounds like you might need to do a bit more research on how bf works. The answer to this one will not be difficult at all to find online.

Powered by DjangoBB