My Octopress Blog

A blogging framework for hackers.

Raytracer

Last semester for Graphics, we each wrote raytracers, and this semester for Graphics II, we’ve been asked to add more advanced features to them.

I had written mine in Ruby for its short development cycle, but raytracers aren’t the most efficient renderers on the planet, and it would take hours to run on a single input on occasion. So, not wanting to deal with that this semester, I rewrote it in C++. Much faster. The most difficult input (same set) now takes about a minute. I finished it up today, and here are some pretty pictures to sate you:

[gallery link=”file” orderby=”ID”]

Texttwist

Anyone who knows me knows my obsessions with anagrams and this game, Texttwist. At one point it actually became relatively problematic - hours and hours spent playing it with Rachel.

Like sudoku before it, I set out on a quest to conquer it.

I downloaded an open-source dictionary, took an hour to parse it out, code a program to compute unique permutations of the input words and see which ones are valid words in English.

Dan - 1; Texttwist - 0

When Rar’ers Hate You

There are few things that I absolutely loathe more in coding than when someone rars a set of files instead of a folder. It’s as if they’re saying, “whatever you had in this folder is completely worthless, and I’m going to dump 1000 byzantine files here for your to sift through. Oh, and have a nice day.”

Vector

Had a bizarre C.S. / kitten related dream. Apparently I was giving way kittens, and I wanted to make sure I had one left for myself, and so I thought it would be a good idea to declare a standard template library vector of kittens, fill it with my kittens, and only give away more kittens while there was still more than one left:

vector kitties;

# Put kittens in vector
# ...

while(kitties.length() > 1) {
	give_away(kitties.pop());
}

Grading

As it’s my first semester T.A.’ing, it’s also my first semester grading. I picked up the first homework from Prof. Qiu this morning, and I just got done grading it. There are about 40-45 kids and it took about 3 hours. So, 4-5 minutes per homework - I can live with that.

Tonight was also the first time that a student in the class scheduled an appointment to get help with her homework. I hadn’t looked at the upcoming homework as they just finished the first assignment, but I was very pleased when I was able to jump right in and know exactly the problem. It’s a great feeling to know the entirety of a class without needing a refresher, and being able to take any section and just go.

In short, so far so good.

جدّة (Jeddah)

Here are some pictures I took in Jeddah. Unfortunately, I forgot my camera at home, so these are all off of the iPhone. I hope they satisfy a little.

[caption id=”attachment_236” align=”aligncenter” width=”225” caption=”Jeddah Hilton’s lobby as seen from the 8th floor.”]Jeddah Hilton's lobby as seen from the 8th floor.[/caption]

[caption id=”attachment237” align=”aligncenter” width=”225” caption=”Falcons are popular in Saudi Arabia.”]Falcons are popular in Saudi Arabia.[/caption] [caption id=”attachment238” align=”aligncenter” width=”300” caption=”Saudi Aramco is tightly associated with KAUST, and they put on this event on one of their compounds. They put out couches and rugs on a lawn, and had a bunch or cultural presentations.”]Saudi Aramco is tightly associated with KAUST, and they put on this event on one of their compounds.  They put out couches and rugs on a lawn, and had a bunch or cultural presentations.[/caption] [caption id=”attachment239” align=”aligncenter” width=”300” caption=”Saudi sunset.”]Saudi sunset.[/caption] [caption id=”attachment240” align=”aligncenter” width=”300” caption=”Many restaurants and cafes have family sections, and single sections. If you are not with your family, you get kicked out of the family section, and the converse it also the case.”]Many restaurants and cafes have family sections, and single sections.  If you are not with your family, you get kicked out of the family section, and the converse it also the case.[/caption][caption id=”attachment241” align=”aligncenter” width=”300” caption=”More of the Hilton.”]More of the Hilton.[/caption][caption id=”attachment242” align=”aligncenter” width=”300” caption=”The picture doesn’t do it justice.”]The picture doesn't do it justice.[/caption][caption id=”attachment243” align=”aligncenter” width=”300” caption=”Another garden at the Hilton, near the mosque.”]Another garden at the Hilton, near the mosque.[/caption][caption id=”attachment244” align=”aligncenter” width=”225” caption=”The mosque and minaret of the Jeddah Hilton”]The mosque and minaret of the Jeddah Hilton[/caption][caption id=”attachment_245” align=”aligncenter” width=”300” caption=”The entryway to the Hilton.”]The entryway to the Hilton.[/caption]

Jeddah Hilton

After a series of long flights, we finally arrived at Jeddah International Airport. A little trouble at immigration, but nothing that prevented me from entering the country.

We make our way through a sea of women in burkhas and men in thawbs onto a bus that’s headed to our hotel. A kid who is from Jeddah but was studying abroad in the States was pointing out sights along the way. Mostly dreary nods and acknowledging the presence of this or that.

Happy to see the hotel, we entered a gate surrounded by concrete blockades, with Steyr-AUG-assault-rifle-bearing soldiers. Nearby another guard is perched atop a Hummer, clutching his mounted machine gun. Not unexpected, but still a little surprising.

We enter the hotel which stuns from the moment you first see it. Marble everything, and 6 great glass elevators. The registration desk hands us our schedules, badges, and even SIM cards so we can get local cell phone service while we’re here. (Unfortunately it’s not a network that Apple will willingly support, but we have ways.) In the rooms, they have marbled wood furniture, and a beautiful patio. I actually feel a little guilty about staying in such a nice place. Photos to come.

iP0wn3d!

I broke down, and I bought one. I’m now one of those a**holes walking down the street checking his email. I want to stay connected, via email and the internet, and also a phone.

See, for what has now become a multi-year bother, my friends have been pestering me about getting a cell phone. I put it off citing the associated charges and the shortcomings of other phones. But now, I can do a lot of tedious tasks I used to use my laptop for - checking mail, calling people, reading news, find local movie show times, get directions from point me to point b. Even listen to my music and watch stupid internet videos.

Simultaneously a great and sad day. [caption id=”attachment220” align=”aligncenter” width=”200” caption=”Fully charged and ready to go”]Fully charged and ready to go[/caption] [caption id=”attachment221” align=”aligncenter” width=”200” caption=”What I see when it says hello”]What I see when it says hello[/caption] [caption id=”attachment222” align=”aligncenter” width=”200” caption=”A demo graph from the grapher program I bought”]A demo graph from the grapher program I bought[/caption] [caption id=”attachment223” align=”aligncenter” width=”200” caption=”My daily news intake”]My daily news intake[/caption] [caption id=”attachment224” align=”aligncenter” width=”200” caption=”Looking for movies - blue dot is where I was”]Looking for movies - blue dot is where I was[/caption] [caption id=”attachment226” align=”aligncenter” width=”300” caption=”Watching a Reel Big Fish music video on YouTube”]Watching a Reel Big Fish music video on YouTube[/caption] [caption id=”attachment_227” align=”aligncenter” width=”300” caption=”Which album to play?!”]Which album to play?![/caption]

Graphing

For Scientific Computing, I decided I wanted to have a grapher with which I could programmatically interface easily. Of course, there are options other there, from gnuPlot to you-name-it, but I figured that it wouldn’t be too hard to write one myself. Especially since there’s a ruby port for OpenGL.

Long story short, I’ve got something that’s not too terrible. Not perfect, but it’s certainly a start: [caption id=”attachment_216” align=”aligncenter” width=”300” caption=”A few functions plotted with my grapher”]A few functions plotted with my grapher[/caption]

But then, I thought, “why stop there?” I figured it wouldn’t be that hard to make a 3D version. While the 2D one will work on any generic function you give it, this 3D one has it hard-coded in right now. Of course, it wouldn’t be too much more to make it more flexible, but given that this took 30 minutes, I’m ok with its rigidity. [caption id=”attachment_217” align=”aligncenter” width=”300” caption=”A simple surface.”]A simple surface.[/caption]

We’ll see where this goes. It makes me feel a little nerdy that I’m two days into my winter break, and this is how I’ve spent some of it.

Chess

For Artificial Intelligence, in order to satisfy the final project requirement, I wrote a small chess-playing agent. It’s not horrible, but it’s not going to win any awards. Still, despite its simplicity, I’ve noticed that in games against itself, it exhibits some seemingly second-order behaviors, like forks, pins, skewers and so on. I found that interesting.

I did write a text-based interface for playing against it, but it’s tedious to actually use, and so, having done well in graphics, I decided to write a simple GUI in OpenGL. You can click-and-drag your pieces to where you want them, and then wait for the computer to play. Here’s a screenshot of a game’s conclusion: [caption id=”attachment_213” align=”aligncenter” width=”300” caption=”A game’s conclusion”]A game's conclusion[/caption]

I’d like to give the piece icons transparency on the border so that you can see the underlying square, but that will be a job for tomorrow. Even as it is, I’m pleased with it.