Turtle Challenge

For discussion of xTalk topics related to education.
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Turtle Challenge

Post by richmond62 »

As some sort of educator I am always getting vaguely stimulating stuff in my email in-box; and this was slightly more stimulating that some insofar as it is something that lends itself to imitation in OXT rather more than some other things:

https://www.bebras.uk/index.php?action=content&id=41

Shades of:
-
tortuga.jpg
tortuga.jpg (8.01 KiB) Viewed 3565 times
-
[ I have an irreparably bust one of these glued to the wall of my school! ]
-
Screenshot 2024-06-26 at 10.46.13.png
Screenshot 2024-06-26 at 10.46.13.png (158.12 KiB) Viewed 3564 times
-
Before I proceed any further I should like to state that I have grave misgivings re code blocks, and am NOT treating this exercise as a way of promoting code blacks, but as an exercise to show how this sort of thing can be imitated in OXT.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

Obviously the first thing to do is generate an 'action board' (well, I don't know what else to call it):
-
Screenshot 2024-06-26 at 10.50.35.png
Screenshot 2024-06-26 at 10.50.35.png (222.9 KiB) Viewed 3563 times
-
This takes snapshots of a field, names each snapshot sequentially, and positions it:

Code: Select all

on mouseUp
   put 1 into BOARD
   put 1 into KOLUMN -- column counter
   put 1 into RROW -- row counter
   repeat until BOARD > 25
      put BOARD into fld "f1"
      import snapshot from fld "f1"
      set the name of the last image to ("x" & BOARD)
      set the top of the last image to (KOLUMN * 120)
      set the left of the last image to (RROW * 120)
      add 1 to KOLUMN
      if KOLUMN > 5 then
         put 1 into KOLUMN
         add 1 to RROW
      end if
      add 1 to BOARD
   end repeat
end mouseUp
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

There are various 'artefacts' in the Turtle Challenge.

While I feel perfectly happy about copying the functionality of Turtle Challenge, I do NOT feel comfortable copying their images, so I downloaded free resources from the internet:
-
Screenshot 2024-06-26 at 11.11.51.png
Screenshot 2024-06-26 at 11.11.51.png (114.45 KiB) Viewed 3562 times
-
These can be imported and positioned on the action board:
-
Screenshot 2024-06-26 at 11.18.23.png
Screenshot 2024-06-26 at 11.18.23.png (167.59 KiB) Viewed 3560 times
Attachments
image resources.zip
images
(41.91 KiB) Downloaded 64 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

As can the money:
-
Screenshot 2024-06-26 at 11.29.47.png
Screenshot 2024-06-26 at 11.29.47.png (211.19 KiB) Viewed 3559 times
-
You will notice that by the way I generate my action board the numbering is vertical rather than horizontal, as in the original: I do not consider this important; if you do you will have to modify the board generation script.
Attachments
coins.zip
money images
(18.66 KiB) Downloaded 65 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

I also do not like the way the pond on my action board does not extend across 2 squares as in the original: this can be easily adjusted:
-
compare1.png
compare1.png (76.9 KiB) Viewed 3558 times
-
Screenshot 2024-06-26 at 11.40.07.png
Screenshot 2024-06-26 at 11.40.07.png (304.07 KiB) Viewed 3557 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

The next thing we have to consider is our codeblocks and how we might implement them:
-
Screenshot 2024-06-26 at 12.01.55.png
Screenshot 2024-06-26 at 12.01.55.png (26.31 KiB) Viewed 3555 times
-
Luckily the xTalk concept of GROUPS is at hand to help us.

To understand this we should take a codeblock apart into its components; recreate those components in xTalk and then put them together in xTalk.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

Let's start by looking at the MOVE codeblock:
-
Screenshot 2024-06-26 at 12.05.49.png
Screenshot 2024-06-26 at 12.05.49.png (29.49 KiB) Viewed 3555 times
-
It contains 2 menus: a direction menu and a distance menu:
-
direction.png
direction.png (9.34 KiB) Viewed 3555 times
-
amount.png
amount.png (6.16 KiB) Viewed 3555 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

The direction menu ONLY has 2 possibilities:
-
Screenshot 2024-06-26 at 12.09.54.png
Screenshot 2024-06-26 at 12.09.54.png (23.16 KiB) Viewed 3556 times
-
This can easily be replicated in OXT with a drop-down menu:
-
Screenshot 2024-06-26 at 12.17.10.png
Screenshot 2024-06-26 at 12.17.10.png (18.94 KiB) Viewed 3556 times
-
We can start by giving the drop-down menu (which I have called 'Direction') this sort of script:

Code: Select all

on menuPick SX
   set the label of me to SX
end menuPick
This ensures that whichever direction is chosen it will be properly displayed.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

If one wants to be extremely fancy one can lever the Unicode convention like this:
-
Screenshot 2024-06-26 at 12.27.19.png
Screenshot 2024-06-26 at 12.27.19.png (8.46 KiB) Viewed 3554 times
-
The decimal encoding of the hexadecimal 1F893 is 129171, and one can use this to make one's drop-down menu look a whole lot more professional:

Code: Select all

on menuPick SX
   set the label of me to (SX && numToCodePoint(129171))
end menuPick
HOWEVER if one does not have a Unicode-compliant font containing the glyph range containing the downward pointing chevron the results are not good:
-
Screenshot 2024-06-26 at 12.34.06.png
Screenshot 2024-06-26 at 12.34.06.png (18.18 KiB) Viewed 3553 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

Another way to provide a downward facing chevron is by assigning one of OXT's preset icons to the drop-down menu:
-
Screenshot 2024-06-26 at 12.36.05.png
Screenshot 2024-06-26 at 12.36.05.png (116.15 KiB) Viewed 3552 times
-
The amount menu is a simple text field:
-
Screenshot 2024-06-26 at 12.40.12.png
Screenshot 2024-06-26 at 12.40.12.png (16.53 KiB) Viewed 3552 times
-
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

To start putting together the direction codeblock one needs a blank template image:
-
moveBACK.png
moveBACK.png (13.33 KiB) Viewed 3551 times
-
Then the drop-down menu and the text field can be aligned on top of it:
-
Screenshot 2024-06-26 at 12.48.00.png
Screenshot 2024-06-26 at 12.48.00.png (81.47 KiB) Viewed 3551 times
-
Screenshot 2024-06-26 at 12.48.49.png
Screenshot 2024-06-26 at 12.48.49.png (75.95 KiB) Viewed 3551 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

Now we should GROUP those 3 objects and call the GROUP 'tMOVE' as that will be our template direction codeblock:
-
Screenshot 2024-06-26 at 16.16.33.jpg
Screenshot 2024-06-26 at 16.16.33.jpg (317.38 KiB) Viewed 3549 times
-
Let's give our template some simple code so we can move it to where we want:
-
Screenshot 2024-06-26 at 16.16.33.jpg
Screenshot 2024-06-26 at 16.16.33.jpg (317.38 KiB) Viewed 3549 times
https://richmondmathewson.owlstown.net/
TerryL
Posts: 107
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Turtle Challenge

Post by TerryL »

Richmond, please continue with this nicely done interesting post. Terry
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

Sorry: 2 things made me pause:

1. A bug in OXT Lite (now sorted out) to do with grouping).

2. I was ill.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

I have decided to shrink the codeblock images to 65% of their previous size so there is a bit more space available on the stack:
-
Screenshot 2024-07-02 at 11.31.24.png
Screenshot 2024-07-02 at 11.31.24.png (296.89 KiB) Viewed 3461 times
-
moveBACK65.png
moveBACK65.png (11.36 KiB) Viewed 3461 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

And another pause as the script:

Code: Select all

on mouseDown
grab me
end mouseDown
in the "tMOVE" group still CRASHES the IDE.
-
Screenshot 2024-07-02 at 11.44.21.png
Screenshot 2024-07-02 at 11.44.21.png (272.51 KiB) Viewed 3462 times
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 2783
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Turtle Challenge

Post by tperry2x »

Just going to try your stack, but I can't try it on MacOS 12 (or 15) as I don't have a mac that will run either of them here...
Edit: your stack crashes on Linux too, and it also crashes in LCC 9.6.3 on Linux - so it's not a bug specific to OXT Lite.
I've amended it a bit here.

(note: I'll delete these posts if that's okay, when you are ready - so this section just shows your "Turtle Challenge" with none of these comments).
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

So: there is a conflict of interests insofar as a group containing a drop-down menu (which contains an in-built [hence invisible] mouseDown command) mucks up any other mouseDown command inwith the group: hence my code block causing the IDE to crash.

Therefore, before proceeding I have to work out another way to effect code blocks . . .
-
diagram.png
diagram.png (16.29 KiB) Viewed 3433 times
-
A mouseDown in area #1 allows the group to be moved without any problems.

A mouseDown in area #2 (the drop-down menu) crashes the IDE.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

So, having had a "dark night of the soul" (meaning going down to the fridge and grabbing a can of beer at 4 in the morning and fooling around with a pencil and paper (always, always, always got to be better than turning a computer on during the Brahma Muhurta)) . . . 8-)
-
Screenshot 2024-07-03 at 11.38.44.png
Screenshot 2024-07-03 at 11.38.44.png (62.71 KiB) Viewed 3431 times
-
Screenshot 2024-07-03 at 11.42.41.png
Screenshot 2024-07-03 at 11.42.41.png (686.91 KiB) Viewed 3431 times
-
I solved the problem . . .

I deleted the code in the GROUP:

Code: Select all

on mouseDown
grab me
end mouseDown
and put this code into the codeblock image:

Code: Select all

on mouseDown
grab group "tMOVE"
end mouseDown
That was, frankly, an idea that annoyed me immensely that I had not thought of it sooner.
Attachments
codeblock problem.oxtstack.zip
(9.72 KiB) Downloaded 64 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4239
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Turtle Challenge

Post by richmond62 »

I'll delete these posts if that's okay, when you are ready - so this section just shows your "Turtle Challenge" with none of these comments
I would rather you did NOT delete the 2 previous postings as some useful things can be learnt from them.

After all the CRASH caused by the way I coded the group-grab was my fault, and not yours. 8-)
https://richmondmathewson.owlstown.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests