Friday, July 18, 2008

Google Code Jam 08

This year Google Code Jam started day before yesterday (16th of July), for me it was yesterday. It was organised in a bit different way, usually they used to sponsor the contest as a event on Topcoder and contestants used their arena to develop the code. This time they applied a new approach and a better one. They opened the contest for all languages and was compiler independent. We were supposed to download input generate the output and upload it along with the source code file. So on 16th was the qualification round, 24 hr long event with 3 problems. The person submitting one solution correct was to be promoted to the next level.

Each question had two input sets: small and large. The output of small was evaluated instantly and the result was displayed. The output for large data set was submitted and the result was announced after the event.

So in all it worked out well, and yes I have qualified for the online round 1 too, with a full score of 75 and world ranking 336 :) Lets see what happens in the rounds ahead.

Wednesday, July 16, 2008

Launching hairyhi.info

Hey everyone, today I am officially announcing the launch of my new site hairyhi.info. Its displays my profile. So go ahead and check out the site if you want to know more bout me. It uses a beautiful accordian and has cool javascript effects. Its a better and updated version of my last site which still exist at ankit-jain.info.

Wednesday, July 2, 2008

Browser Based games III

Yes, I actually managed to write the third version of my browser based games tutorials. Today I am going to discuss the second type of browser games: small Animation games. Like I discussed last time, small animations games are like tetris, frogger, bricks which require moving objects but very less AI and have static backgrounds. These games require a lot of memory space to store the position and status of various objects along with the objects' properties.

There are a few points that one can consider while planning the game for development:
  • Firstly, examine the game very carefully and be very clear with all the rules/ instructions of the game to be developed. This will help you decide the data structures to be used. Usually most of the data is stored in javascript Arrays. So, we need to be very careful while designing the game to optimise the utilisation of memory (try to use minimum memory space and use local variables as much as possible)
  • The idea behind using Arrays is to find patterns among the objects. For example, the image objects in the frogger game which move along the road can be stored in the arrays. By finding the right quantity of those objects we can define the size of the array. By deleting the old objects which have crossed the screen and inserting new objects in those places. Similarly.. we could store the empty and filled spaces of the screen in an array in the game of Bricks.
  • Moving the objects is fairly simple now.. if we have a constant speed, we could just move objects by using a set interval command, and calling a function which moves all objects on the screen.
    timer=setInterval("functionName()",50);//This function is called periodically after aevery 50 ms.
    function funtionName()
    {
    for(i=0;i<size;i++)
    arr[i].style.left=parseInt(arr[i].style.left)+moveRight;
    }
  • This will move the array objects to the right by moveRight pixels every 50 ms. If you have to move both ways.. u might need an array to store a boolean value indicating left or right. and move accordingly.
  • Similarly to detect collision both the objects coordinates have to be matched. Generally all objects could be considered as rectangles and hence they could be checked for their areas of intersection by their end points easily.
I think rest is dependent on your imagination and creativity. Just try to make game as light as possible (in complexity and memory used).. so that it could be played on low end systems as well.

Tuesday, June 24, 2008

Browser Based Games II

I am back with the second edition of how to develop browser based games. If you haven't read the first volume, please do it before reading this one. It will help you to understand this one.

Alright, so as I told in my previous post that there are several types of browser based games. But like last time I'll be talking about the Javascript games which are visually appealing and help you understand on how to build a game.

To start with, we first need the structure of the game. I would broadly classify the games into three categories: board games (very less animations required but high AI requirements), minor animation games (these are games like frogger, bricks, tetris where we have minor animations and have static backgrounds) and complex games (like pinball, snooker, tanks where we need to apply the collision mechanisms, trace the paths of the objects and can also have moving backgrounds plus these might require a lot of AI too).

The board games are like casino games(blackjack, slots, roulette, etc) where the main aim is to develop a proper game play mechanism, defined on a set of rules which are hard coded into the program. For instance if we are to develop the blackjack game, we know certain rules that blackjack pays 3 to 2, insurance pays 2 to 1, etc. These rules can be laid down in form of JavaScript functions which calculate the final value of a variable (Score) based on these parameters and these functions are trigger when the respective conditions occur.

AI part might be required in a multiplayer game where the opponents are all bots. For instance a game like texas hold'em poker, where we need to figure out certain parameters based the values of which the bot makes his move. These rules can be designed by carefully observing a real game play. You can figure out certain limits which define the responses of a player, and code them to create a bot player for your game.

Oh and yes, the random part like finding a card out of the deck can be done in this fashion:
function Shuffle(max){
var num=Math.random()*max;
return Math.round(num);
}
This Shuffle function would return a no. lying between 0 and max inclusive. So if you have to pick a card use the following to obtain the suit as well as cardno.:
funtion getCard()
{
var cardno=Shuffle(12)+1;
var suit=Shuffle(3)+1;
}
Where each no. from 1 to 4 can represent a suit for the card. Also for the minor animations I use this function, though it was specifically made for movement in right to left direction, but with minor tweaks, one can adjust it to work both ways:
function Animate()
{
the_style=Img.style;
the_style.left = parseFloat(the_style.left) + movLeft;
the_style.top = parseFloat(the_style.top) + movTop;
if(parseInt(the_style.top)>=lastTop&&parseInt(the_style.left)<=lastLeft&&splitting==0) { the_style.left=lastLeft; the_style.top=lastTop; animating=0; eval(afterAnim); return; } if(parseInt(the_style.top)<=lastTop&&parseInt(the_style.left)<=lastLeft&&splitting==1) { the_style.left=lastLeft; the_style.top=lastTop; animating=0; eval(afterAnim); return; } if(parseInt(the_style.top)<=lastTop&&parseInt(the_style.left)>=lastLeft&&splitting==2)
{
the_style.left=lastLeft; the_style.top=lastTop; animating=0; eval(afterAnim);
return;
}
setTimeout("Animate()",10);
}
Well that's it for this time, I'll dicuss the other 2 types of games next time.

Saturday, June 7, 2008

IT is sinking, or is it?

Hello folks, you might be reading daily in the newspapers that the IT (Information Technology) sector is sinking, big losses, job cutoffs, layoffs and no recruitment. Well that might be true, infact it is, but sometimes I wonder, why doesn't it bother a few people, the elite group!

My point of writing this blog entry is to give a clear picture of what is going on in the IT sector and why. Like I said, the IT is sinking, but despite of this fact, I have got 4 job offers (2 from in-campus placement and 2 PPO offers). Why is it so, that a few people get so many jobs and a few don't land up with one god job? One might feel that I am trying to boast myself, but that's not true and the fact remains there. My cousins, engineer from reputed colleges, are still searching for job. Why is it so?

Well the reason lies in the fact that due to the fall in IT, the companies has shifted from hiring quantity of employees to hiring quality employees. So instead of hiring bulk of people they are hiring a few good and experienced people and treating them well. So despite the fall in IT, job of many people has not been affected while majority of people are into the search of jobs. This trend has let to lay-offs, cutoffs and everything. This paradigm shift has made life miserable for many people. Also the hired employees have to work for longer hours as they are doing the work which was one by 3-4 people earlier. Therefore, the employees and the unemployed are both affected in a bad way, due to this shift.

Redifining the post from the conclusion, I would say "Yes, IT is falling, and the employers are trying to compensate that . At the losing end are the employees and the people looking for jobs".

Saturday, May 31, 2008

Happy Birthday to Freelancing

Hey people, its now an year that I have been working on several projects from around the world and I have gained enough experience to share with you on which projects/ works should one select and which works(though the tempting ones) should one let go off.

So, there are a few things one should take care of a few things while accepting any project.
  • Firstly make sure of the person you are working with is the real client or is forwarding someone else's project. Though there isn't anything bad with working with an intermediate person(who's just forwarding a project), but usually it becomes real difficult doing work because that person may not know the exact specifications/requirements of the project. I have had a similar experience while working for a freelancing firm. They don't give you a passage for direct communication with the actual client for obvious reasons, and hence your every query is answered by the intermediate person. This results in incorrect or incomplete info and usually delays the work. So make sure you communicate with the person enough to gather all the details of the project.
  • Next thing one should be clear about is the platform being used. I remember trying to work on a project which required Java. I convinced the client to use PHP over Java for some reasons and he agreed to it. But later it turned out that the project was not very feasible with PHP and had to be done in Java. So not being very comfortable with Java, I had to turn down that project. So no matter which language you code in, you should be very clear which language/platform is to be used in the work.
  • And one should discuss each and every term with the customer/client and should have an exhaustive list of the requirements of the work. Usually what happens is that the project requirements keeps on increasing as one proceeds. So clearing all the terms with the customer makes it easy for you to work.
  • Always leave a good impression on the customer (usually the customer have multiple works and if you have nice terms with him, he may award you more projects in future). Even if you turn down the project, you should talk it over with the customer and tell him the reason for turning it down. Maybe you could work down the stuff sometime later. I have two PPO offers because of leaving a good impression on the clients.
  • Lastly One should be very clear of the background of the person one is working for. There are several people offering projects, very attractive and luring. But one must take care that the person one is working for is genuine. He might make lame excuses while making payments and may even won't pay at all. There are several con sitting to serve fodder to you. Talk bout the payments earlier and if possible ask them to escrow some amount (Its better to get some money less than not getting it at all).
Please remember these things when you go off for doing some work in your free time. So this was a post to celebrate the first anniversary of my freelancing work. I hope this goes on and on as I really love doing this work. And I would really recommend every programmer good or bad to atleast try freelancing work atleast once, its fun ( I have also recommended the same to a couple of my friends and they have also loved it).

Friday, May 23, 2008

Universal Developers Environment

Hey, Its a long time since last post. I am here today to discuss bout my Final year major project. It is a web based universal developers environment. I was writing the abstract of it yesterday and thought of discussing it here on my blog. Here is the abstract that I have written:

Ever wished for an application that could take care of your precious projects meanwhile helping you to access them from anywhere in whole world? Is it difficult for you to manage the versions and concurrency of your projects manually on which over hundreds of developers are working? Do you have to install the complete platform and development toolkit wherever you work on your project? Do you have to use hundreds of tools and software to develop one application?

If answer to any of these questions is “Yes”, then this application is meant for you. UNIVERSAL DEVELOPERS ENVIRONMENT (UDE) is an approach to solve all these problems with one click. UDE is one stop to CREATE, DESIGN, DEVELOP, SHARE & COLLABORATE. UDE is an online application/site where users can manage their own projects and also work on others’ projects.

CREATE

Once registered, users can create as many projects as he/she wants. When the user creates and online project, he/she is allotted some space on the web server where he can host his project. He/she can upload files, documents and create folders in the allotted space.

DESIGN

The application has a complete toolkit which could help you design the web pages with efficiency. This designing toolkit includes drag and drop features, inserting elements with one click, editing tags and features to develop standard XHTML complaint web pages.

DEVELOP

Developing the projects is the easiest part of this application. The application includes a complete real time color coded area to write your code. It provides features which are these days available in only offline/desktop applications. It also includes automatic indentation, redo-undo features and many more.

SHARE

Not only this, the projects you develop can be either made public or private. The public projects are sharable, searchable and accessible by any registered user. They can even view the project details and then contact the owner to discuss the project.

COLLABORATE

Collaboration is the best part of this project. The owners can allow other users to collaborate and work on their projects by inviting them. The users can also send a request to the administrators of the project to join and work on it. The administrators can manage the users and their access levels.

MANAGE

This application comes with a file manager from where the users of the project can view all the files and directory structure of the project. This file manager provides a complete control on the files. Here you can create new files and folders, rename, delete and move files in the folder.

CONCURRENCY CONTROL

With the inbuilt Concurrent Versioning System which contains all the details of the files modified, along with the capability of the administrators to move back to the earlier version and undo the changes done by other users in the files.

ACCESSIBILITY LEVELS

There are three levels of accessibility for any project in the application: Administrator or the Owner of Project, Moderators and Users. These three levels of accessibility provide a complete control of the project and help the owner to work on the project efficiently.


I guess this should give a fair idea of what the project is all about. So I won't go in further details this time. Do check back later for any update.