Monday, October 31, 2005

One year of blogging

All of a sudden I realized that it has been one year since I posted my first entry on this blog. So, Errr.. Happy Birthday Blog (????). With over 1200 hits, 180 entries and a whole lot of Ninjutsu this should make other blogs turn a shade of green (or maybe not). This would have to be the most memorable entry for me.
The blog started as a log of my day to day activities and things which I found interesting on the web. It still remains like that although I have decreased reporting *everything* I do on each day.
Anyway other than that, Happy Diwali to everyone and I guess the best Diwali gift we all received was Dhoni's marvellous innings against Sri-Lanka. This series will surely revive the interest in cricket, which was lost due to all the politics and the Indian team not performing.
Exams are closing by and studies seem to be balanced by an equal dose of Counter Strike.

Sunday, October 30, 2005

Code blog

I started a code blog (yawn) for I had nothing else to do during my exam holidays. I should start studying more seriously :(

Saturday, October 29, 2005

The (computer) gods must be crazy

So, here I am reading my text on analysis and design of algorithms (I have exams :( )when I see a mention of Donald E. Knuth's paper on "The complexity of Songs" (PDF). Whether it is supposed to be humorous or a mathematical description of songs, I couldn't decide because I suck at analysis. God help me.

Thursday, October 27, 2005

Battlefield

After doing a lot of sleeping in the afternoon and evening we all went outside to have dinner in South Star. We had a more than a filling meal and came back. After coming back I went to Rahul's place (who is now the proud owner of a GeForce 7800 GTX. Yep, he has a SLI enabled motherboard.) to play Battlefield 2 Demo. Now Battlefield 2 is a team deathmatch/domination kind of game. The scenario being that of war. The demo has only one map: Gulf of Omaha.
Now the best part of the game is that you get to do all kind ofthings which you would do in a war (that is other than killing people). You get to drive tanks, drive boats, fly fighter jets (my favorite) etc. Today I had a nice time flying the F-16. The dog fighting experience was pretty cool. Me and another guy were hell bent on blowing up each others aircraft. The only thing which sucked was the damned slow net connection which was causing lag at some times. Other than that the experience was pretty entertaining.
The Google key chain which I was talking about. The results for the written test have not come out yet :( Posted by Picasa

Wednesday, October 26, 2005

One hot Cappuccino (before)


One hot Cappuccino (before)
Originally uploaded by [Rohit].
Me and Rahul had gone to Cocoa tree (yesterday) to get RK's birthday cake. Had a nice cup of coffee followed by a high speed bike race. Did I mention that Rahul is an extremely fast (yet safe) biker. One poor Unicorn guy got his ass kicked by a CBZ and I had front row seats to the action.
Poor Nishant forgot to #include <math.h> in his graphics lab internal and didn't get output. Followed by the humilation on the net (see pic below), my heart really goes out for him (mwhwahahaaha). Posted by Picasa

Tuesday, October 25, 2005

7th semester almost over

All our classes are over and so are our internal exams. Now what is left is the university exam which is coming up on Novemeber 7th. With a preparatory leave of just about 12 days its going to be an uphill task.
Had my graphics lab internal today. We got a pretty simple program to make and animate a planetary system consisting of a star, three planets and some randomly moving rocks (asteroids??). Given that the lab was conducted in TurboC (yuck!), there were no eye catching effects. They were all plain circles going around one another. The viva also went smoothly.

Sunday, October 23, 2005

The game on Linux

As I had previously said the Pacman game which I had made ran very slowly on Linux. So I made some posts on forums and got to know of the cause. Now it runs pretty nicely on both windows and linux. I have updated the sources and included a makefile for Linux also.
Update: I had my demonstration today and it went pretty well :) The faculty was impressed. I would like to thank all those people who have played the game and/or given me feedback. Thanks a ton !!

Pacman aftermath

So, I completed Pacman and the demo is to be tomorrow. I don't care how it goes. But there are a few things which I learnt while making this project and which I do care about.

First of all: designing before you actually code helps later. While making this project I never layed pen to paper. Everything was directly typed onto the computer without actually thinking it through. That is the reason why at some parts the collision detection doesn't work. I don't think that I will be able to rectify that without doing a total overhaul of the code.

Secondly, making tools which aid some part of the program are not only cool but also an excellent saviour of time. I made the pacman map editor because I was lazy to actually put in all of the coordinates of the maze into the program. In the end it was a big convenience in testing the program.

Thirdly, something which works fine on your computer may not work the same, somewhere else. The game ran smoothly on my windows machine. It ran extremely fast on my friend (Rakesh's) P.C (maybe because of a better graphics card) and extremely slowly on my Linux box. I'm still trying to figure out why it is running slowly on Linux. By the way did I mention that the game was portable :D

And finally the only tough part in doing any project is .... starting the project. Once you have started it doesn't take much time to finish it..

Saturday, October 22, 2005

Pacman finished

Pacman finished !!! Well ya you could say it is "finished", because it is not exactly same as the original pacman. The monsters don't look the same and they move randomly in the maze. But thats not the main point. You have only one life and you can't eat the monsters. If you eat the super pill you will just be able to pass through them (disguised as one of them). And there is no score, the reason being I didn't want to go into the trouble of setting up fonts in OpenGL. The windows executables can be found here and the source code can be found here. I haven't commented it too much, at the moment. This project has been done in OpenGL , SDL compiled using Bloodshed Dev C++ (I don't like the IDE part of it that much) and edited using good old xemacs. Should run on Linux through wine but I guess it can also be built for Linux.  Posted by Picasa

Pacman continued

Well I'm back working on Pacman again. I did the collision detection part, but it is not working everywhere :( I don't think that I will be able to correct that before the deadline (which is monday). I did the sounds also and they are working fine. The only remaining part being the monsters. One real bad thing which I noticed about OpenGL is that to write some text on the screen is not that straightforward. The common ways are not cross platform and the other ways (like using SDL_ttf) are...well, a bit complex (at least right now). Posted by Picasa

Wednesday, October 19, 2005

Fork bomb

Ever since I had heard about fork bombs (last semester Operating Systems course), I wanted to create one for myself and see its effect. Please don't try this if you don't want to waste your *nix system.



#include <sys/types.h>
#include <unistd.h>
int main() {
while(1)
fork();
return 0;
}


I ran it on my Gentoo system and it was brought to its knees in a few seconds. I couldn't open any new processes or even login in another terminal (well login is again a process, so I guess that was redundant). Couldn't even terminate the fork bomb by Ctrl+C. Ctrl+Alt+Del (reboot) also didn't work. So had to push the power off button.
It was pretty cool :D

Tuesday, October 18, 2005

Google 2084

 Posted by Picasa


This will surely increase my job prospects :))

The Big G

Google was in campus today for recruitment today. The presentation was followed by a written round consisting of objective questions and one programming problem. It was ok. The results will take around one week to be announced :( We got Google key chains after the whole thing got over.

Sunday, October 16, 2005

This is a screenshot of a maze (created by the map editor) loaded by the pacman game. A few things are still missing at the moment. There is no collision detection (meaning pacman can roam through and out of the boundaries) and no monsters. With my internal exams coming up I don't think I will get to work on this, this week. Posted by Picasa

Saturday, October 15, 2005

Pacman map editor

I was working on creating the maze for my Pacman project. To do that I divided the screen into cells of dimensions 40x40. Each cell can either be a boundary entity, a pill , a super pill or empty. The boundary entities are the ones which actually form the maze (the blue thingies).

Now I had done all the coding for the Cell class, but I was really not in the mood to type in all the values (namely the x,y coordinates and the type) for all the cells to make the maze (I hate magic numbers in a program). So I made a map editor which is basically a WYSIWYG editor with which you can create mazes for my pacman game. It is very basic at the moment. You just hover the mouse on to a region and click. The cell's type, in which the region belongs, is changed with each mouse click. The map can then be saved into a file which is read by the Pacman game.

I think it is pretty neat :D Posted by Picasa

Friday, October 14, 2005

Obfuscated code

I was tempted many times to make one. Here is the first one in my life:

main (U
,C
) {
scanf(" %s",
C);sscanf(
C,"%x ",&
U
) ;
printf ( "%d ",U) ;
}


Runs in gcc and converts hex (input) to decimal(output).

I hate myself

Two days back (the day before the "last date of submission" of our major project abstract), I was getting frustrated scouting for ideas for the major project. I was not liking the topics suggested by the sites. The reason being: I like making projects which are technical but can be understood and appreciated by everyone.
So, coming back to my deranged state of mind, while scouting I came across this article on linuxdevcenter.com . It was basically an interview with the lead developer of an open source 3-D graphics engine called Irrlicht. Anyway a 3-D graphics engine fit my "reason for making projects". So, in a fit of inspiration I typed out an abstract and submitted it today (it seems the "last date" was flexible).
The only problem being: my relative inexperience in graphics programming. Yes, I'm doom(ed). And yes I'm doing this alone..

Among other things we went to play a match (basketball) in UC College (Aluva) against MCC, Calicut on the same day. Given the fact that we had not practised and MCC was a sports college we were bound to lose. And yes we did, but by a reasonable margin :D Everyone was being cycled through the fives as no one had enough stamina.

Thursday, October 13, 2005

Pacman started...

I had decided to make a Pacman clone as a part of the graphics (micro) mini project. The project should have started (ended??) a long time ago, but we lazy people like to keep things for the last moment.
Anyway I finally started coding a few things for the project. I basically have three entities of the game almost ready i.e Pacman, the pills and the super pills. The monsters and the maze are yet to be taken care of. The bigger pill is the super pill and the smaller one is the normal one. The yellow thingie is Pacman. I have the keyboard controls working and animations for pacman and the super pill too. Posted by Picasa

Monday, October 10, 2005

Shed skin

I first came to know about shed skin when Mark Dufour (the guy who is making shed skin ) mailed me. He said that he wanted to use one of my python programs to use as a unit test case for a python-to-c++ compiler he was working on (that is what shed skin is). I did a little more research on the project and I find out that it is actually one of the projects funded by the "Google summer of code" thingie. The project is pretty cool and shed skin can effectively convert a lot of python programs into C++ code.
Today while I was trying to compile a program with shed skin I got an error which had something to do with "dlopen". So I googled for it and got a lot of interesting stuff.
dlopen, along with a few other functions, is used to dynamically load in libraries. Basically it is used so that you can make your program more "plugin friendly". You can find a lot of interesting reads on this topic.
Among other things, I still don't have any bright ideas for my major project :(

Sunday, October 09, 2005

The day after

Today was the last day of Inspire '05. We had events like programming, web designing etc taking place today. Followed by the grand finale the DJ show. I couldn't attend the DJ show as I was busy munching pizzas courtesy my cousin Neethu (who got placed in Infosys).
Among other things I'm wondering if this is an year of disasters, with the latest being the quake in north India/Pakistan.

Saturday, October 08, 2005

Inspire '05 Hackathon

Today was the first day of our computer science fest : Inspire '05. I was helping out in an event titled "Hackathon" which had to do with cracking and cryptography. We didn't expect much participation for our event but a healthy number of 8 teams turned up. There were two parts to the event: cracking and cryptography. In the cracking part the participants were given three executables (which I downloaded from various sites and was able to crack myself) which they had to crack. The tools provided were ollydbg, w32dasm and xvi32.
For the cryptography part they were given three simple ciphers designed by me, which they had to decipher. The three were something like this:

Cryptography challenge 1 - More than Caesar

guvf xvaq bs pvcure vf xabja nf gur ebgngvba pvcure. gur nafjre gb guvf ceboyrz vf ebgngvba


Cryptography challenge 2 - Bad numbers

69 66 20 79 6f 75 20 64 69 64 20 74 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 77 69 74 68 6f 75 74 20 74 68 65 20 68 65 6c 70 20 6f 66 20 61 20 70 72 6f 67 72 61 6d 20 74 68 65 6e 20 79 6f 75 20 6d 75 73 74 20 68 61 76 65 20 74 68 65 20 61 73 63 69 69 20 74 61 62 6c 65 20 69 6e 20 79 6f 75 72 20 68 65 61 64 2e 20 74 68 65 20 61 6e 73 77 65 72 20 74 6f 20 74 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 69 73 20 68 65 78 63 6f 64 65 7a

Cryptography challenge 3 - A nice compliment

10011101
10010110
10010001
10011110
10001101
10000110
10001100
10001011
10001101
10010110
10010001
10011000


All these were generated by programs written by me and are pretty simple.

Solution for Cryptography 1

The cipher is a simple shift cipher also known as ROT-13. The letters a-z are translated to n-za-m. A simple PERL program solves it.

$a="guvf xvaq bs pvcure vf xabja nf gur ebgngvba pvcure. gur nafjre gb guvf ceboyrz vf ebgngvba";
$a=~tr/n-za-m/a-z/;
print $a;

Which reveals:
this kind of cipher is known as the rotation cipher. the answer to this problem is rotation

Solution for Cryptography 2

The cipher is basically ASCII codes written in hex. Here is a simple python program to solve it:

s="""69 66 20 79 6f 75 20 64 69 64 20 74 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 77 69 74 68 6f 75 74 20 74 68 65 20 68 65 6c 70 20 6f 66 20 61 20 70 72 6f 67 72 61 6d 20 74 68 65 6e 20 79 6f 75 20 6d 75 73 74 20 68 61 76 65 20 74 68 65 20 61 73 63 69 69 20 74 61 62 6c 65 20 69 6e 20 79 6f 75 72 20 68 65 61 64 2e 20 74 68 65 20 61 6e 73 77 65 72 20 74 6f 20 74 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 69 73 20 68 65 78 63 6f 64 65 7a """
l=s.split()
m=""
for k in l:m+=chr(int(k,16))
print m

Which reveals:

if you did this challenge without the help of a program then you must have the ascii table in your head. the answer to this challenge is hexcodez

Solution to cryptography 3

This was basically ASCII code changed to binary and complimented by 1. Again python does the job for us :)

s="""10011101 10010110 10010001 10011110 10001101 10000110 10001100 10001011 10001101 10010110 10010001 10011000"""
l=s.split()
m=""
for k in l:
m+=chr(~int(k,2)+256)
print m


Which reveals
binarystring

The event went of pretty smoothly and I'm happy that it got a good response. The winners were from MCA CUSAT. Thanks to Chandan, Saurav and all the other juniors who ran around for this event :)

Thursday, October 06, 2005

A Python one liner

I was just fiddling around with IDLE, when I made up this one line program to reverse a string and display it.

print (raw_input()[::-1])


Well it is not too clever, but what the heck it is my blog and I put in whatever I want to.

Wednesday, October 05, 2005

Quake 2 Nostalgia

With the last date for the submission of the major project abstract drawing closer, I was scouting the web for ideas. When I was making my chess engine (6th semester mini project), I was intrigued by the idea of making a bot for a FPS like quake 3, UT etc. Although we take these bots for granted while playing the game, a lot of effort actually goes into making these bots life like. The majority of information on bot programming available on the web seems to be restricted to quake 2. After reading through a few of these sites I decided against making one. The reason being 1) It won't seem too academic. 2) The information is confined to quake 2 (I was hoping at least quake 3)
Anyway looking at all that info about quake 2 made me download the demo. That being one of the first games I ever played (I guess at that time I was in 10th standard). Surprisingly I could remember most of the things and the demo lasted for a fiery 20 minutes of gameplay (no saves). It is still fun playing it :) Come to think of it I have been playing on the quake 2 engine all these days. Counter strike condition zero is built on the Half life engine. The half life engine is actually a highly tweaked quake 2 engine which was brought by valve from id software.
Among other things I again got hit on the nose by the basketball.

Monday, October 03, 2005

Harvey Danger

Well, there was this article on slashdot which said that a Seattle based rock band called Harvey Danger had released their newest album Little by little for free download. So, I went right ahead and downloaded the album.
The verdict: It is pretty good and even better because it is free.
Among other things, I got hit right on the nose by the basketball while playing. It is not a nice feeling.

Permutation

Well, there was this sample google question on the notice board which went something like this: "How will you find whether string A is a permutation of string B?" . One method will be to actually make all the permutations and keep on comparing them with the other string. This is obviously inefficient as it takes O(N!) time. I did something else which takes O((N)^3) time (I think. I am not too good at analysis.). You just check whether all the characters in one string are there in the other string and their lengths are equal (obviously).