I didn’t finish the assignment this week, sadly. I was trying to work with this TSA Claims Data, and spent awhile manipulating the data so that it would sum the total claims per airline. I got it to look like this (which involved figuring out how to change NaN to 0):
But I couldn’t figure out how to then extract each element in the code. I’m sure this is a simple problem but I didn’t have time to fix it and make a visualization this week. 😦
My idea for this assignment was very stupid. It came from the fact that when typing “python” in the command line, I regularly accidentally type it as “pythong” instead.
So I decided to make a mashup of Sisqo’s 1999 classic, Thong Song, and some documentation from python.org.
I knew I wanted it to maintain the structure of the Thong Song, but with the flavor of Python documentation sprinkled throughout.
What I ended up doing was making two source files, thong-song.txt (which had the lyrics) and python.txt (which included a chunk of documentation text). I then replaced one random word in each song line with a random word from the Python text.
I quickly ran into the problem of the program picking words from python.txt that were not very useful to me, like “the” or “it” or “a.” So to solve this problem, I made another file with a list of “boring words,” and I told it to only select a word from python.txt if it was not also in boring.txt:
use_these = [i for i in line.split() if not i.lower() in boring_words]
for individual_word in use_these:
And of course, I also changed every instance of the word “thong” or “Python” to the word “Pythong.”
When I run the program, it’s different each time with varying degrees of success. I think it works best when the song still generally rhymes (so in most cases, if the last word on each line is not changed). I also experimented with trying to get it to only replace each word with a word that began with the same letter, but I couldn’t quite get it to work in time, and I’m not sure it would actually make much of an improvement. Anyway, a couple ideas for building this program further.
Code and text files below, including a full sample of the results:
For my midterm, I want to make a game about petting cats. Specifically, I want to make a game about how hard it is to pet a cat. In real life, it’s already a bit of a game – you never know exactly where the cat wants you to pet it, or for how long. One wrong move and you get scratched. Hopefully, this little game I make will capture a bit of that feeling.
I’m very much not good at drawing, or visual art in general, but I had a good time using Piskel to make these sprites. (For this post I’ve exported them as gifs.)
For my controller, I’ll be making something that has a joystick to allow you to move the petting hand around the screen, and then a piece of furry fabric that you actually have to pet in order to trigger the action. The fur will be on top of a fabric button made with Velostat that connects to the Arduino.
(The url for this project is here. If I’ve turned off the server, it won’t be currently running.)
Building off of the chatroom I made the other week, I added a feature that takes a picture from your webcam once you submit your message, and posts them together. It was tricky to get it up and running, and I had a lot of problems managing divs, but it looks like it generally works.
Sometimes the images don’t post, and I’m not entirely sure why. Also the formatting of the whole thing leaves a lot to be desired. But I’m glad I managed to get it to generally do what I wanted it to. I’m interested in bringing this one a little further…hopefully I can continue working on this.
Using one way mirrors, lights and movement to create a structure that manipulates space.
Ideas for locations within 721 Broadway include the basement, with its long hallways and brick walls, the room we actually have our class in, or possibly a closet. What kind of illusion we end up making will determine the best location for it. More soon!
Our assignment this week was to clean up the code of a previous assignment, which was quite welcome because my code from last week was a total mess. I’m not completely sure that it’s now sparkling clean, but it’s definitely much better than it was before.
Before I made any changes to the game, I went in and reorganized the code. Having not yet learned arrays or objects in class, I was wandering about in the array wilderness a little bit last week and ended up doing something really weird with them. I think I fixed them up now after looking up how to do an array of objects. I found the jitterbug example to be particularly helpful. Now my falling hearts are arranged like this:
I went in and created a lot of my own functions as well.
Finally, I started adding on to the game itself.
Adding sounds made a big difference. I found music from the Free Music Archive and sounds from Free Sound. I’m not really sure where the proper place to attribute would be…I put it in comments in my code for the time being.
Besides sounds, I made a few other changes — the girl now bounces up and down, the landscape is a bit different, and she smiles if you win the game. (But it’s still pretty hard to do so!)
It was fun playing with speakers and servo motors this week. After doing the labs, I focused mostly on doing things with sound, but in the future I’d like to spend more time experimenting with servos…
In the tone lab, I had some fun with the pitch library, and found it pretty easy to change the song played to something else:
I wanted to continue building on my lonely ghost project from last week. When I last left it, I had hand-sewn an FSR that caused an RGB LED to change colors depending on how hard you squeezed it. It was supposed to express “feeling” with the colors — green was good, red was bad. At that point, using colors were the only output.
I added a speaker to my breadboard and worked on adding sound in addition to color as feedback for the toy’s feelings.
The first thing I did was add the tone() function to the code so that when the variable “force” was 3 — that is, pushed the hardest, the speaker would make a noise in addition to having the LED turn red.
I thought the ghost could be made to be a bit needier. What if it got lonely if you didn’t pay attention to it for a period of time?
I used the millis() function to count the number of milliseconds that have passed whenever the ghost was squeezed. I then set a variable called lonelyTime, which was the amount of time it that could pass before the ghost got lonely. When the last time squeezed subtracted from the current millisecond count exceeded lonelyTime, I had the speakers make a tone. It would stop when you squeezed it again.
(I used the same method to make the LED blink when you weren’t squeezing the FSR, which I thought was a more natural neutral state than having the light just be white.)
This was nice, but all of the tones sounded pretty boring and static. That’s when I realized I could use the pitches library, like in the tone lab, to compose custom sounds for each state. I ended up making three:
I was a bit surprised by how much more effective the custom sounds were at expressing feeling compared to the basic speaker tones.
Now, the ghost feels much more like a pet or a needy toy. When he’s lonely, the light will turn yellow and he’ll make the lonely sound until you squeeze him. If you squeeze him gently, the light turns green and he makes the happy sound. If you squeeze him too hard, he’ll make a distressing sound and the light will turn red. The blink effect makes it feel more alive as well.