Discuss Scratch

MartinBraendli2
Scratcher
100+ posts

[ATC#4] Tic Tac Toe

Here is the Advanced Topics Challenge number 4:
Congratulations to CodeLegend for winning this challenge!
Intro
Alice is proud. She just finished her first Scratch project, a game of Tic Tac Toe. Impatiently she's constantly refreshing the project page to check whether someone already had taken a look at the product of her sweat and tears. And then there it is! A first comment:



What a jerk. He didn't even leave a like. But can you figure out, what Bob had in mind?
Rules:
  1. Winner is, who first submits a project, that perfectly mimics the project of Alice.
  2. For the project, you can use an unlimited amount of Boolean Blocks and Reporter Blocks, but you can only use a total of 2 of the other blocks (Hat, Stack, C, Cap and Custom Blocks). The number of blocks (not block types) counts, so if you use for example “show” twice, you already used up your budget on non-boolean-non-reporter blocks.
  3. You can't use any custom variables or lists (no Data Blocks).
  4. No hacked blocks.
What does “mimic perfectly” mean?
You don't have to create a pixel perfect copy of Alice' project (Bob already did that). Don't bother about visual details like fonts, exact size/position/shape and such. If your project COULD be turned into a pixel perfect clone without fundamental changes on the code, it's fine.
To be a valid solution, your project must have the following “features”:
  • You have a “grid” with the marks ‘X’ and ‘O’.
  • Red (X) always starts the game.
  • A text tells the players, who's turn it is respectively what the final outcome of the game is.
  • Every legal move is possible.
  • No illegal move is possible (for example, you can't place your mark in an already filled square).
  • Once the game ended (in a draw or a victory), the user can't change the stage any more (except by pressing the green flag).
  • Green flag will restart the game.
  • Besides the grid, ‘X’s and ‘O’s and the mentioned text, nothing can be visible to the user.
  • Your project must be free of bugs.
This is a puzzle for coders, not lawyers. The goal is not to find legal loop holes, but to program with a limited selection of blocks.


Edit History:
- Changed the word describing Bob for “Jerk”, since the other one got censored.
- Added the “bug-free” line to the “features”.
- Spelling/ grammar.

Last edited by MartinBraendli2 (July 22, 2016 00:30:47)


CodeLegend
Scratcher
500+ posts

[ATC#4] Tic Tac Toe

first!

EDIT: Wow, I didn't think I'd actually be first! Now to read this…

Last edited by CodeLegend (July 21, 2016 03:06:45)

Firedrake969
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

First thoughts…
You have to use a hat to start the project, so there goes one block

@CL
I probably was first to actually see it but I took too long to formulate my one-sentence thought

Last edited by Firedrake969 (July 21, 2016 03:07:52)


'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
PullJosh
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

Oh, this is gonna be fun…

Base 10 is the best number system.
MegaApuTurkUltra
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

Lemme guess

when Stage clicked::hat events
switch backdrop to (some gigantic expression)

probably not going to attempt this
that's what I said last time though :P

Last edited by MegaApuTurkUltra (July 21, 2016 03:14:43)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
PullJosh
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

MegaApuTurkUltra wrote:

Lemme guess

when stage clicked
switch backdrop to (some gigantic expression)
I would imagine so.

Base 10 is the best number system.
Firedrake969
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

PullJosh wrote:

MegaApuTurkUltra wrote:

Lemme guess

when stage clicked
switch backdrop to (some gigantic expression)
I would imagine so.
“Green flag will restart the game”, though.
You can't sense green flag via stage click.

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
CodeLegend
Scratcher
500+ posts

[ATC#4] Tic Tac Toe

Ok, so we have to reset when the flag is clicked, AND we have to run an action when the stage is clicked. so our hat block has to be
when [timer v] > (0)
Right?

EDIT: And then we'll have to switch the background/costume… Can Scratch even handle that many image files?

Last edited by CodeLegend (July 21, 2016 03:17:38)

Firedrake969
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

CodeLegend wrote:

Ok, so we have to reset when the flag is clicked, AND we have to run an action when the stage is clicked. so our hat block has to be
when [timer v] > (0)
Right?
But that only fires once, when the green flag is clicked

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
MegaApuTurkUltra
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

How about the when loudness > block?

Martin never said requiring noise to run the project wasn't allowed

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
Firedrake969
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

MegaApuTurkUltra wrote:

How about the when loudness > block?

Martin never said requiring noise to run the project wasn't allowed
Again, green flag?

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
PullJosh
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

Hmm… Well now I'm confused. I'll have to sleep on it.

Base 10 is the best number system.
CodeLegend
Scratcher
500+ posts

[ATC#4] Tic Tac Toe

MegaApuTurkUltra wrote:

How about the when loudness > block?

Martin never said requiring noise to run the project wasn't allowed

MartinBraendli2 wrote:

perfectly mimics the project of Alice
MegaApuTurkUltra
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

aw I was hoping this would work http://image.prntscr.com/image/8222c3ef01444edb8dd3f2ae8cc42552.png

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
Firedrake969
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

MegaApuTurkUltra wrote:

aw I was hoping this would work http://image.prntscr.com/image/8222c3ef01444edb8dd3f2ae8cc42552.png
I already tried that

Here's something, though…
http://prntscr.com/bvio2e

Last edited by Firedrake969 (July 21, 2016 03:25:29)


'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
CodeLegend
Scratcher
500+ posts

[ATC#4] Tic Tac Toe

:O

I figured it out! Still requires a bajillion costumes, but I know how to make a solution!
gtoal
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

So by boolean block do you mean a *populated* boolean block, ie including the expressions that form the boolean comparisons?

I'm pretty sure this can be done trivially with a tree of costumes, but there's rather a lot of them (this is the magic number you referred to earlier, right) and I don't have the patience to draw them all (in fact I think it would take me more than the 4 hrs to create all those costumes!).

All the text messages etc can be precomputed for each costume. The only logic needed is for moving from one costume to the next depending on which of the 9 squares you click in, which can be done with joining the current costume name with 9 booleans determined by comparing the mouse x and y against two horizontal and vertical boundaries.

Did I guess right? (Took about 3 seconds to come up with this, longer to type it, and it'll be much longer to implement it!)
MegaApuTurkUltra
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

Firedrake969 wrote:

MegaApuTurkUltra wrote:

aw I was hoping this would work http://image.prntscr.com/image/8222c3ef01444edb8dd3f2ae8cc42552.png
I already tried that

Here's something, though…
http://prntscr.com/bvio2e
….how even?

sometimes I really don't get Scratch

gtoal wrote:

So by boolean block do you mean a *populated* boolean block, ie including the expressions that form the boolean comparisons?

I'm pretty sure this can be done trivially with a tree of costumes, but there's rather a lot of them (this is the magic number you referred to earlier, right) and I don't have the patience to draw them all (in fact I think it would take me more than the 4 hrs to create all those costumes!).

All the text messages etc can be precomputed for each costume. The only logic needed is for moving from one costume to the next depending on which of the 9 squares you click in, which can be done with joining the current costume name with 9 booleans determined by comparing the mouse x and y against two horizontal and vertical boundaries.

Did I guess right? (Took about 3 seconds to come up with this, longer to type it, and it'll be much longer to implement it!)
I think that's what we're all thinking here

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
Firedrake969
Scratcher
1000+ posts

[ATC#4] Tic Tac Toe

MegaApuTurkUltra wrote:

Firedrake969 wrote:

MegaApuTurkUltra wrote:

aw I was hoping this would work http://image.prntscr.com/image/8222c3ef01444edb8dd3f2ae8cc42552.png
I already tried that

Here's something, though…
http://prntscr.com/bvio2e
….how even?

sometimes I really don't get Scratch
Lol, no clue at all.

It worked though… I get the feeling that the pick random block value is regenerated every time it's used, and since the timer is in the random block, you get a fresh set of possible values every time.

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
CodeLegend
Scratcher
500+ posts

[ATC#4] Tic Tac Toe

Powered by DjangoBB

Standard | Mobile