Robot tracing program for CS Principles

Hi folks!

We working to create an AP CS Principles course based on MakeCode Arcade. In one of the units of this course, students need to complete a bunch of Robot Tracing exercises like this:

The Robot is represented as a triangle, the grid is a 7 x 7 matrix, and there are only 3 functions - Move Forward (1), Turn Right, and Turn Left.

If anyone has some time, I would be eternally grateful if you want to try implementing this in MakeCode Arcade (maybe as an extension with custom blocks?) Would love to include it in the CSP course!

  • Jacqueline
3 Likes

What is this:
image
and this:
image
supposed to do?

n = 1 and n = n +1
it’s just the weird notation that the CS Principles course uses to try and be language agnostic…

1 Like

Seemed like a fun project. I put together a very simple implementation over lunch:

You’ll notice there’s a new RoboDrawing category that has the three blocks you mentioned plus a reset function (which is also required to initialize the sprite and grid).

Right now the sprite just follows instructions blindly; it doesn’t verify that it doesn’t move outside the bounds of the grid or anything…

… also I didn’t spend much time coming up with good names for the blocks or adding documentation.

Feel free to modify/improve the code any way you like.

3 Likes

Wow!!! Jacob, I love this, it’s perfect! Thanks so much for doing this. Will get this included in the course curriculum - lots of kids will be playing this! Do you want me to add a credit/link to you below the game?

2 Likes

Ha. :blush:

No, no credit necessary. Glad to hear it might be useful!

1 Like

Hey Jacob,
Quick question - would it be possible for the Reset function to take a coordinate value? So students could place the robot on any of the tiles?

1 Like

@jacqueline.russell I was interested in seeing some additional exercises of this type, so I hunted around a bit. I found a few in this code.org curriculum: https://curriculum.code.org/csp-20/unit5/5/.

Those examples appear to use a different grid size, starting location for the robot, and starting orientation of the robot. (It also looks like there may be obstacles and an additional conditional instruction later on…)

Do any of your curriculum’s exercises involve different grid sizes or starting configurations (position/orientation)?

Ha; yes. I just posted this as a question but it’s awaiting moderation. :sweat_smile:

@jacqueline.russell Here is an update to the robot drawing with the ability to customize the starting location and direction:

I also started doing some questionable things in the design of the JavaScript API to enable a blocks convenience: the turn blocks now allow you to pick the other turn direction with a drop-down. (I wanted it to work kind of like the Math operators, where +, -, ✖️ and are all listed, but if you pick the wrong one, you can swap over to another.)

… but I really don’t like the JS that it creates. Is it a priority that the generated JS be reasonable? Will the students be looking at that code?

I can roll back that change if it’d be better to force them to swap blocks to change turning directions.

2 Likes

Wow! Even better Jacob! This is perfect! No, students won’t be looking at the JavaScript - it’s all going to be block-based, so no worries there. Thank you so much!!!

1 Like

We’ve built a similar project for hour of code campaign( but no i18n (yet)), same purpose with some features for new coders.
a) Navigating mode, in which students can navigate levels and draw flowcharts on paper or planning their programs (simulator automatically restart after changes detected)
b) Summary after running all levels;
c) Barriers like walls / boulders, context for introducing conditionals (if…then…)

Extension instructions:

2 Likes

Oh Wow! Looks very slick!