Coding with Turtle Blocks

This week, I was tasked to perform the "simple" task of writing my name. Here is the catch: I have to write my name using a programmed colorful turtle on the Turtle Blocks website. This activity is an introduction to programming (more recently referred to as "coding"). Typical code looks like a series of numeric/mathematical values that are used to tell a computer program to behave in a particular way. Coding can be used as a glorified calculator, or could be used to create the internet or establish a new monetary system (Bitcoin uses blockchain technology... Lots of complex code!). Common programming languages include Python, Javascript, HTML or R. All have their own quirks and primary usages but they all generally function similarly. Like verbal language, programming languages have various relationships and similar foundations. I consider this coding project to be essentially exploring the "Latin" of programming. In other words, this project demonstrates the exact thinking required in order to develop an effective program. Every step must be explicitly stated and explained (All this time I thought the computers were getting too smart, but really they're just following instructions! Machine learning, however, is a whole other animal...). My goal was to have the turtle write my name using a combination of block, upper/lower case, and script letters. In addition, I wanted to create actions to separate my code as opposed to having one long chain of code. This is a good strategy to implement during coding as it is very easy to miss a small detail that gets lost among a forest of formulas and variables. Since I used actions, I can explain my process by each letter. Let's start with "k". I wanted to make sure I gave myself enough room so I wanted to move the turtle to the left by utilizing the set xy function. However, I realized that the "pen up/down" feature is critical when moving your turtle. This is one of those simple things that is easy to overlook. However, if you think about it, we can't really write anything without picking up and lower our pen/pencil. Next, I use a series of forward and turn commands. At first, I thought that right would make the turtle go right. Instead, it actually rotates the turtle based on degrees of a circle (360 degrees would make a complete rotation). There was a lot of playing with values in order to get the "k" to look good. I wonder if the repeat function could be used in order to simplify the block letter process. Could this perhaps create an inverse of the original code?
Onto my script "e". Sure, this may have been an easy letter to try in script but I was pretty clueless on how to do this. However, I realized it could be done using the arc command. The code is pretty short, but it was super challenging to get right. First, I had to rotate the turtle to the right to place it in the desired orientation. Then, I utilized the arc function. The arc function works by inputting 2 values. The first value is the angle. Based on the direction I needed the turtle to go, I had to figure out how to make a counter-clockwise motion of the turtle. The second value refers tot he radius of the circle that the arc will travel on (you don't see the whole circle but it just tells the turtle to travel a certain path. Since we need a spiral-esque shape for an "e", I had to use multiple arc commands. This took a lot of trial and error but I am sure there is a mathematical way to make this more symmetrical.
What's next?... Oh right - "v"!. I continued my script writing into "v" and followed the same procedure. However, you will notice in the image below that the "v" is not oriented in space correctly. This is because I ran the code separately within the action. Therefore, the turtle's orientation will dictate its traveled path. While I could have had the turtle reset with every letter, I had to connect the "e" and "v". In order ot do that, their code had to relate to one another. In other words, the "v" will not function correctly without the "e". Perhaps I should have combined the code into one action instead.
For the "i", I return to block letters. This was, definitely, the easiest letter since it is just a thin rectangle. All it required was utilizing rotations and the forward command. However, again, you will notice its orientation depends on where the turtle is in space. The code was written to follow the "v". Therefore, running the code alone will not result in an "i" but results in a horizontal rectangle.
For the capital "N", I wanted to make a different kind of block letter that looks like those broadway playbills. It didn't come out perfect but it looks kind of cool! Again, this just utilized rotation and forward commands. The tricky part was completing its block form. Contrary to the "k", the way I wrote "N" is not continuous. Therefore, I had to utilize the pen up/down command and orient the turtle. While I could have used the set xy function, I felt that the pen up/down would be easier in this case since I did not know the exact position of the turtle. I could have used the cartesian coordiantes but was having trouble finding the precise location of the turtle.
Finally, I put this all together in the start action. To spice things up a bit, I had the color randomized between each letter and also had to make sure to lift the pen when transitioning in and out of script. Also, at the end, I lift the pen and move the turtle forward so the final result can be seen clearly. Here is a video of everything coming together!
This was a great activity to practice the thought process involved in coding. Things that seem trivial can actually be pretty complicated!

Comments

  1. Kevin,
    I really appreciate you increasing the level of challenge by adding different font styles for each letter. Good for you! Your commentary is also very helpful in making your thinking transparent. Great work!

    ReplyDelete
  2. Hi Kevin,

    I found this good video (https://www.youtube.com/watch?v=_JRWVqwf_rU) on robot battles and since you're an engineer and this is an ed with tech class, I thought I'd mention it on your blog for the class. It might also be good for your anchoring phenomenon for science methods too.

    Basically a team of engineers have to design and program the best bot to defeat the others in battle. As an essential question, what is the best design for a battle bot? Is there a best design/programming or is just that battle bots should be designed against the opponent bot? It's sort of like a intro to robotics high school elective gone wild.

    I remembered we were going to use robots in this class but unfortunately not at the level used in the video. It would be a good method of making sure dogs stay off my lawn. Better yet, maybe the bots could be used to reenact the battle scene between Hamlet and Claudius. Hopefully this will also be relevant to the upcoming guest we have next week.

    Best,

    Mr. Baldi 2021

    ReplyDelete

Post a Comment

Popular Posts