» Archive for January, 2009

First Annual Global Game Jam

Friday, January 16th, 2009 by Niki

The First Annual Global Game Jam is taking place at the end of the month, from January 30th to February 1st. New York City has two host locations: NYU-Poly and Columbia’s Teacher’s College. A few of my coworkers and I are planning on participating. I’m an NYU-Poly alum (well technically a Polytechnic University alum) however I will be at the Columbia game jam as the NYU-Poly game jam is open only to NYU/NYU-poly students and alums (which precludes my coworkers from attending).

The Global Game Jam is a game development competition that takes place over 48 hours. The design and constraints of the competition aren’t revealed until the very start so that the teams cannot plan ahead. An entire video game must be developed within 48 hours, from design to implementation.

The goal is for us to split up and join other groups as a means of networking, giving students an opportunity to work with professionals and to advertise our company.

The Dark Ages

Sunday, January 11th, 2009 by Niki

I have added two more projects to my projects page, both of which come from the dark ages. The dark ages is back when I knew nothing about programming and considered myself to be a great programmer. The Dunning-Kruger effect I suppose. I look back at this code now and shudder, I’m sure that you could post it to The Daily WTF and it would fit right in.

But who doesn’t have some code that they were once proud of and are now ashamed of? That’s all part of growth and learning. I decided to put these projects online for posterity and to remind myself of how far I’ve come and [hopefully] how far I’ll go. With that preamble out of the way, the projects I posted are:

The Mandelbrot set – I wrote this when I was in high school, using the Windows API. The code actually isn’t that bad, aside from some silly code-repetition. Overall it was a pretty simple project with a lot of boiler-plate code so there was little room for my naivety to get in the way.

Robotic Motion Planning – I wrote this in college for my Computational Geometry class. I of course left this to the last minute and coded the entire thing in about a week, getting very little sleep during that time. Given the complexity of it and the extremely tight schedule it’s not that surprising it turned out the way it did. It’s extremely buggy (in fact, I can’t get it to run anymore!) and missing features. I never got around to actually calculating the path of the robot.

I have a few other old projects lying around, mostly from college. If I get a chance I’ll add those to the Dark Ages section of my projects page as well.

The Power of Perl

Friday, January 9th, 2009 by Niki

Perl was the first “real” programming language that I learned. As I recall I was really into web design at the time and wanted to learn how to make CGIs. Perl of course was the language de rigeur at the time for CGIs and was the natural choice. I did end up writing a couple of CGIs (including a message board!) as well as some more general scripts.

I once wrote a perl script that generated a Sierpinski Triangle using periods and asterisks. It was an extra-credit assignment for one of my high school math classes. It used the even/odd properties of Pascal’s triangle to generate it. I had to modify Pascal’s triangle, actually, because the size of the numbers ended up overflowing the integer type.

However it wasn’t until many years later that I truly started to understand and appreciate the power of Perl. By that time I had moved onto more “hardcore” languages (specifically C and C++) and largely forgot about Perl. That is until I started working at my current employer Powerhead Games. While our games are written in C++, we use Perl for a lot of behind-the-scenes work. Sometimes this is directly related to the game code – use a Perl script to read some files created by designers and have it output a C++ source file.

Sometimes however it’s just used as a time saver. Today, for example, we received a bug list from a publisher. This bug list was saved as an Excel document, but the individual bug reports it contained weren’t formatted in an “Excel-y” manner – they weren’t neatly arranged in rows and columns. This meant that in order to add these bugs into our database as-is they would have to be entered by hand.

Enter Perl. I saved the Excel document as a tab-separated text file and managed to write a script that extracted the meaningful information from each bug report and reformat so that it could be imported into our database. This took me no more than an hour (and I’m far from a Perl monk). Trying to write some C/C++ code to do the same thing would probably have taken longer than just manually entering all the data.

Tupper’s self-referential formula and other projects

Thursday, January 8th, 2009 by Niki

Last night I added a Projects page and added two projects: my OCaml code and DWM patches mentioned in the previous post.

Over the past couple of days I managed to fix a couple of bugs in the OCaml code and add a Perl script to generate some information that can be used as input to the OCaml program. Tupper’s self-referential formula is a formula that can graph a monochromatic bitmap. The self-referential part refers to Tupper using it to graph a bitmap that looks like the formula itself. You can check out the projects page for more information on what the software actually does (and check Wikipedia for more information on the formula). The rest of this post is going to be about the code.

\displaystyle{1\over 2} < \left\lfloor \mathrm{mod}\left(\left\lfloor {y \over 17} \right\rfloor 2^{-17 \lfloor x \rfloor - \mathrm{mod}(\lfloor y\rfloor, 17)},2\right)\right\rfloor

Tupper's formula contains an exponent that is negative for most values of (x, y). A negative exponent of course results in the multiplicative inverse of the expression with a positive exponent. Since the OCaml Big_int module only supported positive exponents I simply negated the exponent (thus making it positive) and then inverted the result.

This worked fine for every case except when x was equal to zero, so initially I just skipped that case to prevent run-time errors. Eventually I realized that when x was zero the exponent was positive and since I was negating it, it ended up negative. The Big_int library then threw an exception.

I added in a check to test the sign of the exponent and to do the calculations with the absolute value. Then, depending on the sign, I would either multiply or divide (use the inverse). To do this I curried either the multiplication or division function and used the curried function for the rest of the calculations.

After that it rendered the image properly. I then went about generalizing the formula (and my code) so that it could support any monochromatic bitmap, not just the self-referential bitmap.

Tupper’s version of the formula is restricted to a bitmap that is 17 pixels high. There really isn’t a way to generalize the formula to accept any size bitmap unfortunately, but it’s easy enough to change the formula to accept a specific size. This of course makes it easy to generalize the code.

Finally I wrote a Perl script that will take an image and convert it to that magic number (the special integer representation of the bitmap).

Happy New Year!

Tuesday, January 6th, 2009 by Niki

One of my New Year’s resolutions was to start and maintain a blog dedicated to software development. Here I am making good on it only five days into the new year!

My other development related resolutions are:
* Learning a functional programming language
* Develop software for Android
* Learn to use a distributed version control system
* Contribute to more open source projects
* Go to grad school

I plan on using this blog to track my progress in these areas as well as to post various ideas, stories and thoughts relating to development.  On that note, let’s see how things are going:

A few days ago I started playing around with OCaml, a multi-paradigm (but primarily functional) programming language. I coded a small program that graphs Tupper’s self-referential formula to test out some features and libraries of the language. I also picked up a copy of Pratical OCaml today and I hope to be able to read through most of the book by the end of the month.

My friends Lee, Justin and I have started working on an Android project together. The ultimate goal is to create a PDF reader for Android, or rather a more general eBook reader that supports PDFs. The short term goal is to create a decent text file reader (that can read text files located on the sdcard file system).

As luck would have it, we are using Git to handle version control for the Android project. This should give me ample opportunity to learn the ins and outs of distributed version control.

The Android project is going to be open source so that by itself will be a contribution to an open source project. However I have in the past submitted patches to DWM and I plan on continuing to do so. Other than that I don’t have any other open source plans, but the it’s still early in the year.

Finally I plan on going back to school – specifically I plan on getting a Master’s degree in Mathematics. Originally I had planned on attending grad school starting this February but work got in the way and I put the applications aside. The goal now is to start grad school in September which gives me plenty of time to fill out applications and mail them in.

I’ll probably make several more posts in the following days before slowing down and settling into a more stable rhythm. I have a lot of ideas that I would like to write about and a lot of projects that I plan on uploading (such as the aforementioned OCaml code).

Oh, and please excuse the current state of this blog. This is my first attempt at using word press and I have yet to change any of the defaults.