Back To Homepage

Programming


Programming With NetLogo!

Today and yesterday we were on a program called NetLogo- which is a multi-agent
programmable modeling environment. We used turtles as the 'agents' and we
learned how to do a lot. I learned how to program the turtle to move in different
direction, and how to turn different degrees/angles.
When we did microworlds, today, it was much more fun and interesting than it was
yesterday. When I say that, I mean that what we did was more fun than learning
how to do everything. Today we learned how to program a little bit better than
yesterday. One thing that I loved out of this whole NetLogo adventure, I liked how
we were able to make the turtles look like they were eating the patches which
were green to make the illusion of it being grass.

Programming with Python!

This is a program I worked on in a program called Python. Python is a programming language
which allows you to function concepts using codes and such like that. In class today, we programmed
a number guessing game. We first had an exampled of our game in real life by having someone think of a
number and having the rest of the class guess what the number was. In Python, we had the computer think
of a number while we guessed what it was. In the picture above, the right side of the screen is the controls
we put into the computer. On the left is what we told the computer to do by running what was on the
control side.

This is another program we made in class. Instead of guessing of the number the computer randomly chose, we
made a program for the computer to guess of a number we were thinking of. I couldn't open up the
page which showed the controls/functions, but this is the program we made. The guess range was from one to one
hundred and instead of having the computer guess one hundred numbers, we made a simple way for it to determine
whether the number is higher or lower.


The computers' first guess was always fifty because 100/2 is 50. We programmed it to do this because if the
number I was guessing of was higher, the computer would know that my number isn't 1-50. After knowing
1-50 isn't the number I was thinking of, the computer determines half of 50-100 which is 75. 75 is the computers'
second guess if it's higher that 50. If the number is lower than 50, what would the guess be? 25. If you've got the
pattern already, the computer just cuts the range and guesses the number in the middle.

Processing

On Monday of our final week in Computer Science, we learned a language in the C-Family of programming called Processing.
Processing is used to make it easy to create graphics. In Processing, you need a little bit of math to make shapes
and such. In class, we had an objective in Processing to create a smiley face. I was able to create the smiley face with
the Processing.org's references and with some help from Mr. Farrell while he was lecturing in the front of the class. The

The C Family programming languages include C, C++, Java, and JavaScript-- all using the same syntax for defining variables and
making loops and conditionals.

The code I used to make a smiley face is below.


This is the face I made closer up:


In order to make the smiley face, we had to make ellipses and triangles. I screenshotted a reference from Processing.org so you
would be able to see what the different codes meant when I put it in my smiley face program:

For the Ellipse's

For the Triangle's


JavaScript!

In class today we worked on JavaScript. JavaScript is a programming language based around the language C. In class we used a website called
jsbin.com in order to practice coding JavaScript. It was cool because in class we learned about how to use conditionals and such like that.

On the website we all used, I first learned how to make a program that prints out what you want. All you need to do is put "console.log('...');" with
your text between the quotes. In JavaScript, at the end of each command, you have to put a semicolon there- just a good fyi so you won't
have to deal with simple errors in the code like how I did.


This is the code and output for when I tested out the printing function.
In JavaScript, the way you define variables isn't that difficult. I order to declare a variable and it's worth, all you have to do is write "var,"
write an equal sign (=), and then label what it's value is.

Here's an example of mine.

More Processing!


On Wednesday in class, in the morning, we made a little house function in Processing. Instead of just making a new code for every single house, we
made a house function where all we need to declare is the parameters of the house.


This is the function just to make one house that is one size, in one exact place. The function we made with parameters to make houses anywhere we
want is below:


Also, if you notice, this house is bigger than the one in the first house picture. We also made a loop to make new houses. The code for that, we
changed the position to be a set width.



After lunch on Wednesday, we made a ball using sin and cos in Soh-Cah-Toa and made the ball oscillate around the screen.

The left is the different circle the code made.

We used ellipses also. This picture is a close up on how we used cos and sin.