Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Fewest amount of blocks technically needed to use Scratch
- PkmnQ
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Here's my list:If you only need the turing-completeness, then you can use just these:
-snip-
when [ v] > ()
when I receive [ v]
broadcast [ v]
repeat until <>
end
(() - ())
<[] > []>
([ v] of () :: operators)
(one normal variable)
set [ v] to []
define one custom block (with one input)
- TheSmartGuy1234
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
(() - (0))
forever
end
replace item ( v) of [list v] with [thing]
if <> then
<(item ( v) of [list v] :: list) = []>
end
i think
- ideapad-320
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Here's my list for Turing Completeness.
foreverI have a demo project that emulated a subtract and branch if equal to zero here.
(()-())
replace item () of [list v] with [thing]
(item () of [list v] :: list)
- caftingdead261
-
Scratcher
100+ posts
Fewest amount of blocks technically needed to use Scratch
Here's my list for Turing Completeness.please don't necro postforeverI have a demo project that emulated a subtract and branch if equal to zero here.
(()-())
replace item () of [list v] with [thing]
(item () of [list v] :: list)
- ideapad-320
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Not all responses to old topics are neroposts.Here's my list for Turing Completeness.please don't necro postforeverI have a demo project that emulated a subtract and branch if equal to zero here.
(()-())
replace item () of [list v] with [thing]
(item () of [list v] :: list)
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
These blocks are not required:
In fact, the turtle extension only requires:
Anyway…
showsince they can be replicated with stamping, with the sprite always being hidden.
hide
set [ v] to []can be replicated with stamping and lists too.
show variable [ v]
hide variable [ v]
show list [ v]
hide list [ v]
(variable reporter)
In fact, the turtle extension only requires:
stampsince the other turtle blocks can be replicated with circle costumes.
clear
Anyway…
repeat until <>can be replicated with broadcasts and the join block:
end
broadcast (join [condition 1 ] <condition>) // Replace with the name of your condition.which unlike Jonathon50's idea, does not have the chance of crashing Scratch from extremely large stack sizes, unless the code already does it (in which case it shouldn't matter whether it's runnable)
// The continuation is in another script
when I receive [condition 1 false v]
... // Whatever would be in the repeat until block.
broadcast (join [condition 1 ] <condition>)
when I receive [condition 1 true v]
... // Continues the script.
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
2. I got rid of “or” and “>” so you kinda need “not”
<not <boolean :: grey>>can be workarounded with:
<((1) - <boolean :: grey>) = [1]>
- breakfast_for_dinner
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
i don't know if anybody else has brought this up, but variables can be removed entirely
edit: this is wrong, you can cram variables and lists into a single variable block :3
add [foo] to [var names v]to access variable:
add [bar] to [var values v]
(item (item # of [foo] in [var names v] :: list) of [var values v] :: list)
edit: this is wrong, you can cram variables and lists into a single variable block :3
Last edited by breakfast_for_dinner (July 31, 2024 21:41:53)
- BigNate469
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Technically speaking, you only need
when green flag clickedfor Scratch to be Turing-complete (tell me if I'm missing anything)
if <> then
else
end
<not <>>
<<> or <>>
set [ v] to []
(foo)
(() + (0))
Last edited by BigNate469 (Aug. 1, 2024 00:59:06)
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Technically speaking, you only needHow will looping be implemented?when green flag clickedfor Scratch to be Turing-complete (tell me if I'm missing anything)
if <> then
else
end
<not <>>
<<> or <>>
set [ v] to []
(foo)
(() + (0))
Last edited by TheCreatorOfUnTV (Aug. 1, 2024 01:55:32)
- BigNate469
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
The old-fashioned way- manually duplicating the codeTechnically speaking, you only needHow will looping be implemented?when green flag clickedfor Scratch to be Turing-complete (tell me if I'm missing anything)
if <> then
else
end
<not <>>
<<> or <>>
set [ v] to []
(foo)
(() + (0))
- Jonathan50
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
The old-fashioned way- manually duplicating the codeWell, then you could have a script that uses if/else to “loop” up to n times but it would break at n + 1. Also you'd definitely need at least <. (also I'm not sure why you'd call that the old-fashioned way)
With if/else you don't need OR, though
Last edited by Jonathan50 (Aug. 3, 2024 01:25:19)
- Jonathan50
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Well, then you could have a script that uses if/else to “loop” up to n times but it would break at n + 1. Also you'd definitely need at least <. (also I'm not sure why you'd call that the old-fashioned way)With just those plus REPEAT UNTIL (but not lists), it gets interesting. So I thought I remembered everyone thinking that Scratch 1.2 (before lists) was not Turing complete. Then I started doubting a bit, since it must be possible to encode any list as a number. But the problem is of course numbers in Scratch have limited precision. So this subset, I'm pretty certain, isn't Turing complete.
With if/else you don't need OR, though
I was going to say the same thing about Scratch 1.2, but while writing I remembered Scratch 1.x does have infinite precision integers. So…Scratch 1.2 may be Turing complete after all, perhaps you can do compound data and recursive processes… cue *dumdumdum*
This topic, however, is about being able to recreate (or maybe at least approximate) any project, so graphics are kept
Last edited by Jonathan50 (Aug. 3, 2024 01:39:25)
- dynamicsofscratch
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
(#9)Very comprehensive list! I would say that clones can be replaced by not making a clone and just making a new sprite.
Full list of what's required and what needs workarounds
~snippity snip snip~
If you see anything required that you have a reasonable workaround for (eg, using e^ and log for multiplication and division is not acceptable because of accuracy issues) let me know
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
You could just use a large number of variables to do that, since Scratch 3 lists have a limit of 200000, and in many cases it can be lowered down to something smaller like 20.Well, then you could have a script that uses if/else to “loop” up to n times but it would break at n + 1. Also you'd definitely need at least <. (also I'm not sure why you'd call that the old-fashioned way)With just those plus REPEAT UNTIL (but not lists), it gets interesting. So I thought I remembered everyone thinking that Scratch 1.2 (before lists) was not Turing complete. Then I started doubting a bit, since it must be possible to encode any list as a number. But the problem is of course numbers in Scratch have limited precision. So this subset, I'm pretty certain, isn't Turing complete.
With if/else you don't need OR, though
I was going to say the same thing about Scratch 1.2, but while writing I remembered Scratch 1.x does have infinite precision integers. So…Scratch 1.2 may be Turing complete after all, perhaps you can do compound data and recursive processes… cue *dumdumdum*
This topic, however, is about being able to recreate (or maybe at least approximate) any project, so graphics are kept
Last edited by TheCreatorOfUnTV (Aug. 3, 2024 04:42:39)
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
The old-fashioned way- manually duplicating the codeThen how will this:
foreverbe recreated?
end
Or even better, stamping and lists.(#9)Very comprehensive list! I would say that clones can be replaced by not making a clone and just making a new sprite.
Full list of what's required and what needs workarounds
~snippity snip snip~
If you see anything required that you have a reasonable workaround for (eg, using e^ and log for multiplication and division is not acceptable because of accuracy issues) let me know
- dynamicsofscratch
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
(#436)but that requires blocks and extensions, whilst this reduces amount of blocksOr even better, stamping and lists.(#9)Very comprehensive list! I would say that clones can be replaced by not making a clone and just making a new sprite.
Full list of what's required and what needs workarounds
~snippity snip snip~
If you see anything required that you have a reasonable workaround for (eg, using e^ and log for multiplication and division is not acceptable because of accuracy issues) let me know
- Jonathan50
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
You could just use a large number of variables to do that, since Scratch 3 lists have a limit of 200000, and in many cases it can be lowered down to something smaller like 20.Just considering Turing-completeness, putting aside whether Scratch 3 is Turing complete (also turning recursive processes into something loopable)
Last edited by Jonathan50 (Aug. 3, 2024 06:04:36)
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Wouldn't Scratch crash after the number gets larger than 500 digits or so? I'm pretty sure Squeak crashes after the amount of data stored gets too large.Well, then you could have a script that uses if/else to “loop” up to n times but it would break at n + 1. Also you'd definitely need at least <. (also I'm not sure why you'd call that the old-fashioned way)With just those plus REPEAT UNTIL (but not lists), it gets interesting. So I thought I remembered everyone thinking that Scratch 1.2 (before lists) was not Turing complete. Then I started doubting a bit, since it must be possible to encode any list as a number. But the problem is of course numbers in Scratch have limited precision. So this subset, I'm pretty certain, isn't Turing complete.
With if/else you don't need OR, though
I was going to say the same thing about Scratch 1.2, but while writing I remembered Scratch 1.x does have infinite precision integers. So…Scratch 1.2 may be Turing complete after all, perhaps you can do compound data and recursive processes… cue *dumdumdum*
This topic, however, is about being able to recreate (or maybe at least approximate) any project, so graphics are kept
- TheCreatorOfUnTV
-
Scratcher
1000+ posts
Fewest amount of blocks technically needed to use Scratch
Alright then, here's the final list of necessary blocks (for 2.0, the list for 3.0 is a bit different since you can just pre-make lists, at the cost that Scratch 3 has more required I/O blocks):
WORKAROUNDS
We could work around variables easily with one-item lists. (This doesn't replicate watchers, but we will get to that later)
NOT can be replicated by <<boolean> = false> and AND can be replicated by <(<boolean 1> - ((0) - <boolean 2>)) = 2>.
Addition can be replicated by subtracting the first number given from the number which is 0 subtracted by the second number given, so basically (a - (0 - b)).
Here are the conditionals and loops in Scratch implemented (quote and press Preview to see the whole thing):
Anyway, to make any progress from here, we need to render the data. This is possible via three blocks - stamp, switch costume to , go to x: y:
Anyway, you need to have 8 costumes - transparent versions of the colors black, red, yellow, green, cyan, blue, magenta, and white (which you must make using an external paint editor.) Then, you need to use the loops and stamps to stamp the colors onto the screen.
Anyway, then you can abstract everything away from there by printing letters, and once abstracted you can start working on everything else, like multiplication, division, exponents, etc. by not always treating numbers as “numbers” and instead treating them as a representation of data.
EDIT LOG
EDIT: Removed NOT and AND due to the workarounds <<boolean> = false> and <(<boolean 1> + <boolean 2>) = 2>
EDIT 2: Replaced + with - since subtraction is more versatile than addition. You can replicate addition with (a - (0 - b)). Also added an explanation to how everything works.
EDIT 3: Edited to work with the new 3.0 blocks and added cloud variables.
go to x: () y: ()
switch costume to [ v]
play sound [ v]
stamp
when green flag clicked
when [ v] key pressed // For mouse scrolling
repeat until <>
end
ask [] and wait // For keys that Scratch can't detect without.
(answer)
<key [ v] pressed?>
<mouse down?>
(mouse x)
(mouse y)
(loudness)
(video [ v] on [Stage v] :: sensing)
(days since 2000)
<[] = []>
(() - ())
(☁ score)
set [☁ score v] to []
insert [] at (1 v) of [list v]
delete ( v) of [list v]
(item ( v) of [list v] :: list)
That's 24 blocks! (including run without screen refresh)define run without screen refresh
WORKAROUNDS
We could work around variables easily with one-item lists. (This doesn't replicate watchers, but we will get to that later)
NOT can be replicated by <<boolean> = false> and AND can be replicated by <(<boolean 1> - ((0) - <boolean 2>)) = 2>.
Addition can be replicated by subtracting the first number given from the number which is 0 subtracted by the second number given, so basically (a - (0 - b)).
Here are the conditionals and loops in Scratch implemented (quote and press Preview to see the whole thing):
// If block
delete (1 v) of [done? v]
insert [false] at (1 v) of [done? v]
repeat until <<(<<condition :: grey> = [false]> - ((0) - <<(item (1 v) of [done? v]) = [true]> = [false]>)) = [2]> = [false]>
code :: grey
delete (1 v) of [done? v]
insert [true] at (1 v) of [done? v]
end
// If Else block
delete (1 v) of [done? v]
insert [false] at (1 v) of [done? v]
repeat until <<(<<condition :: grey> = [false]> - ((0) - <<(item (1 v) of [done? v]) = [true]> = [false]>)) = [2]> = [false]>
code :: grey
delete (1 v) of [done? v]
insert [true] at (1 v) of [done? v]
end
repeat until <(item (1 v) of [done? v]) = [true]>
other code :: grey
delete (1 v) of [done? v]
insert [true] at (1 v) of [done? v]
end
// Repeat block
delete (1 v) of [times v]
insert (times :: grey) at (1 v) of [times v]
repeat until <(item (1 v) of [times v]) = [0]>
code :: grey
insert ((item (1 v) of [times v]) - (1)) at (1 v) of [times v]
delete (2 v) of [times v]
end
// Forever block
repeat until <>
code :: grey
end
Anyway, to make any progress from here, we need to render the data. This is possible via three blocks - stamp, switch costume to , go to x: y:
Anyway, you need to have 8 costumes - transparent versions of the colors black, red, yellow, green, cyan, blue, magenta, and white (which you must make using an external paint editor.) Then, you need to use the loops and stamps to stamp the colors onto the screen.
Anyway, then you can abstract everything away from there by printing letters, and once abstracted you can start working on everything else, like multiplication, division, exponents, etc. by not always treating numbers as “numbers” and instead treating them as a representation of data.
EDIT LOG
EDIT: Removed NOT and AND due to the workarounds <<boolean> = false> and <(<boolean 1> + <boolean 2>) = 2>
EDIT 2: Replaced + with - since subtraction is more versatile than addition. You can replicate addition with (a - (0 - b)). Also added an explanation to how everything works.
EDIT 3: Edited to work with the new 3.0 blocks and added cloud variables.
Last edited by TheCreatorOfUnTV (Nov. 7, 2024 13:10:12)
- Discussion Forums
- » Advanced Topics
-
» Fewest amount of blocks technically needed to use Scratch









