Discuss Scratch

PkmnQ
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

PkmnQ wrote:

Here's my list:
-snip-
If you only need the turing-completeness, then you can use just these:
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.
forever
(()-())
replace item () of [list v] with [thing]
(item () of [list v] :: list)
I have a demo project that emulated a subtract and branch if equal to zero here.
caftingdead261
Scratcher
100+ posts

Fewest amount of blocks technically needed to use Scratch

ideapad-320 wrote:

Here's my list for Turing Completeness.
forever
(()-())
replace item () of [list v] with [thing]
(item () of [list v] :: list)
I have a demo project that emulated a subtract and branch if equal to zero here.
please don't necro post
ideapad-320
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

caftingdead261 wrote:

ideapad-320 wrote:

Here's my list for Turing Completeness.
forever
(()-())
replace item () of [list v] with [thing]
(item () of [list v] :: list)
I have a demo project that emulated a subtract and branch if equal to zero here.
please don't necro post
Not all responses to old topics are neroposts.
TheCreatorOfUnTV
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

These blocks are not required:
show
hide
since they can be replicated with stamping, with the sprite always being hidden.
set [ v] to []
show variable [ v]
hide variable [ v]
show list [ v]
hide list [ v]
(variable reporter)
can be replicated with stamping and lists too.

In fact, the turtle extension only requires:
stamp
clear
since the other turtle blocks can be replicated with circle costumes.
Anyway…
repeat until <>

end
can be replicated with broadcasts and the join block:
broadcast (join [condition 1 ] <condition>) // Replace with the name of your condition.

// 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.
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)
TheCreatorOfUnTV
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

MegaApuTurkUltra wrote:

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
add [foo] to [var names v]
add [bar] to [var values v]
to access variable:
(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 clicked

if <> then



else

end

<not <>>
<<> or <>>
set [ v] to []
(foo)
(() + (0))
for Scratch to be Turing-complete (tell me if I'm missing anything)

Last edited by BigNate469 (Aug. 1, 2024 00:59:06)

TheCreatorOfUnTV
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

BigNate469 wrote:

Technically speaking, you only need
when green flag clicked

if <> then



else

end

<not <>>
<<> or <>>
set [ v] to []
(foo)
(() + (0))
for Scratch to be Turing-complete (tell me if I'm missing anything)
How will looping be implemented?

Last edited by TheCreatorOfUnTV (Aug. 1, 2024 01:55:32)

BigNate469
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

TheCreatorOfUnTV wrote:

BigNate469 wrote:

Technically speaking, you only need
when green flag clicked

if <> then



else

end

<not <>>
<<> or <>>
set [ v] to []
(foo)
(() + (0))
for Scratch to be Turing-complete (tell me if I'm missing anything)
How will looping be implemented?
The old-fashioned way- manually duplicating the code
Jonathan50
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

BigNate469 wrote:

The old-fashioned way- manually duplicating the code
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 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

Jonathan50 wrote:

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 if/else you don't need OR, though
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.

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

MegaApuTurkUltra wrote:

(#9)
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
Very comprehensive list! I would say that clones can be replaced by not making a clone and just making a new sprite.
TheCreatorOfUnTV
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

Jonathan50 wrote:

Jonathan50 wrote:

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 if/else you don't need OR, though
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.

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
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.

Last edited by TheCreatorOfUnTV (Aug. 3, 2024 04:42:39)

TheCreatorOfUnTV
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

BigNate469 wrote:

The old-fashioned way- manually duplicating the code
Then how will this:
forever

end
be recreated?

dynamicsofscratch wrote:

MegaApuTurkUltra wrote:

(#9)
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
Very comprehensive list! I would say that clones can be replaced by not making a clone and just making a new sprite.
Or even better, stamping and lists.
dynamicsofscratch
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

TheCreatorOfUnTV wrote:

(#436)

dynamicsofscratch wrote:

MegaApuTurkUltra wrote:

(#9)
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
Very comprehensive list! I would say that clones can be replaced by not making a clone and just making a new sprite.
Or even better, stamping and lists.
but that requires blocks and extensions, whilst this reduces amount of blocks
Jonathan50
Scratcher
1000+ posts

Fewest amount of blocks technically needed to use Scratch

TheCreatorOfUnTV wrote:

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

Jonathan50 wrote:

Jonathan50 wrote:

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 if/else you don't need OR, though
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.

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
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.
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):

Motion wrote:

go to x: () y: ()

Looks wrote:

switch costume to [ v]

Sound wrote:

play sound [ v]

Pen wrote:

stamp

Events wrote:

when green flag clicked
when [ v] key pressed // For mouse scrolling

Control wrote:

repeat until <>

end

Sensing wrote:

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)

Operators wrote:

<[] = []>
(() - ())

Variables wrote:

(☁ score)
set [☁ score v] to []
insert [] at (1 v) of [list v]
delete ( v) of [list v]
(item ( v) of [list v] :: list)

My Blocks wrote:

define run without screen refresh
That's 24 blocks! (including 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)

Powered by DjangoBB