Holiday Themed Post

Our assignment in CSAI class was to make anything we wanted but it had to be holiday themed. Initially I was drawing a Christmas tree using turtle but I decided to make a game instead.

I decided to make a hangman themed game using holiday themed words, such as eggnog and tree. Initially my project was hardcoded so there were only two options to choose from. Now the project is not hardcoded and you will get a different word everytime.

The code will first tell the user that their word has x amount of letters. It will then print x amount of dashes like so… _ _ _ _

After this is done it will ask the user for input as to what letter they would like to guess. If their letter is correct, the code will replace one of the dashes with the letter the user guessed so that the letter is in the correct spot. For example if the word is apple and the user guessed ‘p’, then the code will show… _ p p _ _ . This works so that if the letter appears multiple times, the code will still show the letters and dashes correctly.

If the user guessed wrong, then turtle will start the first step in drawing a hangman. Instead of a hangman though, I used a snowman, to make the code more holiday friendly.

The code will stop if one of 2 conditions is met. 1, the snowman has been drawn completely and the user has guess wrong 6 times. And 2 if the user guesses all the letters before getting 6 letters wrong.

The hardest part of this code was using global and local parameters. If you declare a variable in a function but also use it in another function, you will get an error. Instead, you should declare variables globally so that every function can access that variable.

Another thing I had an issue with was figuring out how I should make sure that if the user guesses a number or series of letters then the code will count it as a wrong guess. I did this simply by converting the user’s guess into a string and if the string was not matching any of the letters then it would be declared wrong.

Here is my code.

Turtle Maze

In CSAI class we were assigned to make our turtle go through random maze. The code for the random maze was given so that the maze is different every time.

When I was first given the problem, I was definitely confused as to how to find the most effective solution. I found a method that worked but unfortunately made the turtle go to great lengths to solve the maze.

I finally came up with a solution that did work and was effective as well. Essentially, the turtle must first go forward the length of the first barrier.

The lengths of the black lines are put into two lists, r and t. The turtle first has to go forward the length of r and then 1/2 of the distance of the gap, t. Therefore the turtle has to go forward the length of r1 (the first length in the list randomR) and 1/2 of the first length in the list t. Then you simply have to turn right, go forward 40 (since that is the length of the vertical distance between each black line. Then the turtle must turn again and then go twice the distance of the first length in the list r plus the first length in the list t and then subtract 800 from this since 800 is the length of the maze. This will take you halfway to the next gap.

Essentially you will continue to repeat this process and make some mathematical changes here and there to ensure that it works properly. Then I just saved the value of the y coordinate in a variable, y. To get to the middle of the final gap in the maze, I just calculated the x coordinate using the starting x coordinate. I used go to commands to make that work and then turned right and went forward to exit the maze.

I really enjoyed this assignment because even though the solution is simple and effective, it can be quite challenging to solve and requires some mathematical trial and error. In my first iteration, I found a solution that somewhat worked but could have been more effective. I finally found a solution and I am happy with how it worked out.

Click here to get to the maze!

The final product!(above)

Archery Program (Alternative to Turtle Race)

For my project I made an archery program. The first thing the program will do is draw the cross section of an archer board (The blue, red and yellow concentric circles.) The location of the board will differ slightly every time. The turtle will go to a random x axis value but will always be on the x axis. This just means that the y coordinate is always 0. The turtle will then face 90 degrees upwards and then take input from the user to determine what angle to shoot the ‘arrow’ at. Then since the board is draw like so…

The board will always have a starting x value of 100 but the y value will differ slightly each time. So since the x value for any point on the board is 100, the code will have the turtle go forward until the x value is 100. Then since I know how long each section of the board is (the red, yellow and blue sections are 15,25 and 30 respectively) I can determine where the turtle is based off the y value. It will either be in the bullseye (red), the yellow section, the blue section or it will miss the board completely. It will then print a statement based on what section of the board you landed on. I also have a variable that keeps track of the point total assuming that landing on the blue,yellow, red and not on the board will give you 10,30,50 and 0 points respectively. After 3 tries at shooting it will print your score.

Click here to understand what I will talk about next. That is my code.

As you can see in the image above, it tells you the score as well as the attempt number you are on. The most important thing I learned from this code is how to use local and global parameters. For example I defined a series of functions but my main issue was setting values to 0 outside the function and having them update in the function but not returning properly. This was because inside the function I had to globally define the variables and set them up so that inside the function they would update locally and globally.

Thanks to this code, I better understand global and local parameters as well as the fact that I now feel more comfortable with functions.

Play the game here!

Inspired Artwork #2

My code is too long to arrange in this post so I have a link for you to use in stead. Click here

The art in “Turtle Art”
The full artwork you cant see because it is too big to show on Turtle Art.

This project was inspired off of Rainbows and Plumeau. Basically for the yellow line, I just set the pen size to 20 and went forward with the color as yellow. The wings were definitely the hardest part because I was using set heading to ensure that when the turtle came back to the same point it would still make go to the north of the screen. To do this I just reset the heading to 0 degrees every-time. The actual wings were pretty easy because all the code is doing is changing the color and increasing the radius of a circle to make each curve and then the angle degree of the circle would be changed to a negative degree so that the rainbows would be visible on both sides.

The tail is pretty much the same thing but all it’s doing is having less circles and changing the heading to face down. And the square is basically a large black square with a side length of 1400 and and filled in with black.

Overall I hit some bumps while working on the wings because I was having issues with figuring out what set heading I should use so that it would go the correct way relative to the turtle’s current position, but overall I think I did a pretty good job.

For my first inspired artwork click here.

Inspired Artwork

For my inspired artwork I took inspiration from the Bursts image on the Gallery. I changed up the colors and added white lines at the end of each colored line and I also added stars in the background. My reflection will be at the bottom.

Find the real code here. <—-







The hardest part of this code was the white tips on each colored line. Instead of just having a line go a fixed amount each time, I chose to have each white tip be 10% of (The length of the colored line + length of the white line)

I did this my making multiple variables.

The first thing the code does is make a square of side length 1400 and the fill in the square with black color. After that is done I made a variable called color and assigned it an initial value of 70 which gives it the blue color of the first burst. Then a variable length is created and assigned an initial value of 600. Then I just set the pen size to 7 and set the color to the variable color which made it blue. Then I made a repeat loop of 4 because I had 4 bursts of different colors. Inside the repeat loop of 4 is a repeat loop of 90 because each burst has 90 colored lines. Then inside the repeat loop of 90 is a set x,y to 0,0 so that each time the turtle draws a colored line, the line starts at the same spot. The turtle will then turn right a random amount of degrees and then a new variable will be created which will be anywhere between 10 and “length” so 10 and 600. I then make a new variable called “len” which is 90% of the length between 10 and 600 (whatever that may be). In addition I made a variable “len_white” which is the remaining 10% of the length between 10 and 600.

Then the turtle will simply go forward “len” (the colored 90% of the variable “length”) and then switch the color to white and go forward the remaining 10% of “length” hence “len_white” Then the turtle will go bak to 0,0 and do it again. But this will only do 1 color, so…

Outside the repeat 90 loop but inside the repeat 4 loop, I decrease the length by 150 and the color is increased by ten. This is so that each burst is a different color and so that each burst can have a maximum length.

The most difficult part of this was the white part of each line and making the code more concise. Initially I had different action blocks for each colored burst but when I started using repeats to make the bursts one action block, the code looked cleaner.

For my 2nd inspired artwork click here.

ccv

Name Turtle Art

For my drawing of my name I just wrote Aria and then added a palm tree using circles…

Find my real code here.. : https://turtle.sugarlabs.org/index.html?id=1600138044575591&run=True

It took me about 10-15 minutes to figure out how to make the palm tree because I couldn’t figure out how to make the leaves start at exactly where the trunk ended. I did that using the (go to x,y) button. To ensure that the (go to) button would work, I used a (go to x,y) button to start off the code. I used action blocks to make the code more concise, but I also attached the actual code.

This is my code…..

The code foe the palm tree

The code for the letter “R”
The code for the letter “I”
The code for the letter A

My Turtle Art

For my Turtle Art Design, I “drew” the Olympics logo…

https://turtle.sugarlabs.org/index.html?id=1598969846757175&run=True

The Olympics logo I drew
Pt 1 of the code
Pt 2 of the code

The hardest part of this code was figuring out how to get the circles on the bottom row to intersect with the ones on the top row. I had tried navigating the turtle so that no matter where you started it would draw the bottom row relative to the first. I fixed this by using the go to block so that the turtle would start in a specific place and I could also use the go to block to draw the 2nd row. After I figured that out the rest was pretty simple. The color order on the design doesn’t align with the Olympic logo but I chose to keep it this way because I like the color arrangement I have now and going in the correct order would mean having longer code.

About me

Hi! My name is Aria and I am a 7th grader at Quest Academy. I have gone to Quest for 9 years (since Pre-K).

School for Gifted Children | Quest Academy | Palatine, IL

Outside of school, I take violin, piano, and Chinese lessons. I have competed in competitions such as IMA (Illinois Music Association) and have also done many recitals.

Metzler Violin Shop - Metzler Violin Shop

One of my favorite things to do is read. I have read lots of books so it’s hard for me to pick a favorite one but I like The Hitchhiker’s Guide to the Galaxy, Crazy Rich Asians and The Sun is Also a Star. I like that when I am reading I can imagine everything in my head and it’s like watching a movie.

Amazon.com: Crazy Rich Asians (Crazy Rich Asians Trilogy Book 1) eBook:  Kwan, Kevin: Kindle Store

That’s pretty much everything about me.