Tuesday, July 15, 2008

Must....write....some...code....

Programmers suffer from writer's block just like prose writers.

Ever since my week of fishing with my father, my code production is almost zilch. Granted, it's summer and I'm a teacher, so I can just call it "recharging," but holy man, I need to get going here!

So last night, when I turned out the light after reading, instead of just falling asleep I ended up refining an idea I have for a Python program. I should write it in Java, just for the practice, but Python is just so much better suited for this type of scripting.

The idea itself comes from a strange recollection I had before I fell asleep. I remember once I was hanging out with the students in the programming club and we were talking about inventions we'd like to see reach fruition. I mentioned a long-time wish of mine: to be able to access your brain's memories like you can access a computer database. I told my students, "wouldn't it be fun to be able to say something like 'what song have I listened to more than any other song?' and then get the answer, with all the cool stats.

For instance, wouldn't it be cool to get the real answers to questions like:

1. How many Big Macs have I eaten in my life?
2. How many times have I said "please" in my life?
3. How many movies have I watched?
4. How many hours have I spent playing video games?
5. How many different students have I had in my classes?

Well, my idea for a program won't help answer questions like that, but it will help answer questions like:

1. What's my favorite Steely Dan song?
2. Which book of Richard Laymon's did I like the most?

You may think, "but you should know the answers to those questions," but I don't know if we really do. Or maybe the answers change over time.

Anyway, I'm going to write a Python program that will do this:

1. Parse a text file that contains a large list of items that all have something in common. All 80s songs, for instance, or Steely Dan songs, or Richard Laymon books.

2. Associate an ELO rating with each member of that list.

3. From time to time, ask the user to decide between two random items on the list. For instance: Which do you prefer: "Aja" or "Reelin' in the Years"?

4. Adjust the ELO ratings for each of the two items just compared.

5. Keep doing this until over time you can sort the entire list by descending value of ELO ratings and find out which Steely Dan song (for instance) you really prefer.

I know. Strange idea. That's what comes to someone during that special time right before you fall asleep.... :-)

1 comment:

RichSkyline said...

I've actually completed this programming project. Currently it indicates Zanac as my favorite NES game.....