Sunday, 23 December 2012

Photo Journal, Part 2

Hi guys!

As promised, I'm back with the continuation of my Photo Journal. Those who haven't read the first part can go to my post titled 'Photo Journal, Part 1'.

A quick recap: In part 1, I showed you some of my favourite photographs, divided into 2 groups: Group 1 on the photos I took during my road trip in the Himalayas, and Group 2 containing my best wildlife photographs. I had left Group 2 unfinished, which I shall be finishing in this post.

So, here goes:


Group 2 - Wildlife (Continued):

4) Brahminy Kite, taken in Shoja, Himachal Pradesh, India.



5) Shoe-Billed Stork, taken in Jurong Bird Park, Singapore. This one's a real angry bird!



6) Eye of the Peacock - taken in Dapoli village, Maharashtra, India.



7) I really don't know the name of this moth/butterfly, but it looks magnificent. Taken in Spiti Valley. Himachal Pradesh, India.



8) This is a photo of a Glassy Lizard, taken in a forest in Goa, India. It is probably my most prized photograph - I love the effect created by the interplay of light and shadows!




Anyway, that concludes my photo journal.

Hope you liked it!

Signing off,
Pratik.

Photo Journal, Part 1

Apparently, a picture says a thousand words. If so, then this blog post contains more than seventeen thousand words - quite a staggering number, isn't it? Read on if this has piqued your curiosity......

My interest in digital photography grew exponentially around the time I was in the 7th grade. Maybe it was because of my father, who has always been somewhat of a camera buff himself. Maybe it was because of my uncle, who had just bought a brand-new, awesome camera back then. I don't really know. What I do know is that I have loved photography ever since, and given the chance, I am more than willing to spend hours with my camera.

I love being able to capture the memorable moments of my life and the lives of those around me - some of them sad moments, some happy, some just plain hilarious, and some which induce introspect. Every time that I go back to a photograph that I have clicked, I see it in a new light; I see another aspect, another dimension to it. To me, photography is a way of immortalising a beautiful vista, or an inexpressible emotion.

Nature photography is something that I thoroughly enjoy and is very close to my heart (wildlife and environmental conservation is something that I care deeply about). Nothing matches the glory and beauty of a photograph of a massive, ancient Banyan tree, or a snap of a hawk soaring high. For me, part of the fun lies in the actual process of obtaining the picture - chasing a frisky woodpecker through a forest, or waiting in dead silence to photograph a timid Chital deer.

As the title suggests, this post is a photo journal of some of my favourite snaps out of all the photos I have ever clicked. Each one is special to me for a reason - because of the colours and clarity of the picture, the significance of the moment, or simply the overall effect of the photograph. I have divided the pictures into two main groups: Group 1 contains pictures I took on my 15 day road trip with my family in the Kinnaur and Lahaul-Spiti regions of the Himalayas (in Himachal Pradesh, India) during the summer of 2010, a journey that is one of the most memorable ones I have been on. Group 2 is a collection of my best (according to me) wildlife photos. I took all of these photographs with a Canon SX 10 Ultrazoom camera.

I guess I'll just get started with the photos now:


Group 1 - Himalayan Odyssey:

1) A beautiful snowdrift on a distant peak that I managed to capture while camping in Sangla village, Kinnaur:



2) Three adorable kids in a small hamlet in Hamchal Pradesh. You can't but help marvel at their expressions!



3) During the last 8 days of the trip, we were surrounded by dry ravines, barren, snowcapped mountains, and azure skies, with hardly any vegetation in sight, as we journeyed in the Spiti valley. Albeit a non-conventional kind of beauty, but beauty nonetheless!









4) This is a panoramic photograph of a mountain near Tabo village in the Spiti Valley. For some reason, it reminded me of chocolate ice-cream.



5) I just love the colour contrast between the sky and the mountainside in this one:




Group 2 - Wildlife:

1) Vulture in Spiti Valley, Hamichal Pradesh:



2) A Hanuman Langur silhouetted against the evening sky. Taken in Dandeli Forest Reserve, Karnataka, India.



3) Great Pied Hornbill, taken in Dandeli Forest Reserve, Karnataka, India.



I shall be ending this post here. But the photojournal is not yet done. It will be continued in my next blog post.

Good bye for now.


Pratik.



Wednesday, 19 December 2012

Mastermind

Hello world!

While this opening statement may sound cliche, I have used it for a very specific purpose - it's related to the main theme if this post. The phrase is a reference to the classic 'Hello World' computer program (Humorous wordplay. Ha ha). To the uninitiated, the 'Hello World' program is a computer program that displays the sentence 'Hello world!' on a display device - it is generally one of the easiest programs to write, irrespective of the language used. To those of you who got the reference, I suppose there is no point in explaining it and rendering the pun moot. 

So I'm guessing that a lot of you have by now guessed what this post is all about. You're actually partially correct. Yes, this post is about computer programming. But no, it is not a generic post describing a programming language or its evolution.


In the 9th and 10 grade, I took a course in Java programming in high school. It was incredible fun - but I'm not going to focus on that right now (maybe in a later post). Anyway, after I started to get a feel of the language and had completed taking my first baby steps in program writing, I decided to get a little more adventurous. I consolidated my knowledge and Java coding skills and made up my mind - I was going to develop a  . . . . DUN DUN DUN . . . . game.

For my ambitious project (or so it seemed to me), I decided to develop a text-based emulator of the hugely popular board game, Mastermind. (Yes, the one with the coloured pegs). If you haven't heard of or played it, I suggest that you read up on the game before going further into this post (the Wikipedia article on the game is excellent).

In my version of the game, the user plays against the computer. It is the computer that decides the sequence of colours and the user who has to deduce the colour code in 10 turns. As in the original game, the computer does provide a clue after each turn. I haven't kept any provision for it to be the other way around - maybe I'll come up with that one some day. My first beta testers were my parents (my father is the one who introduced me to mastermind in the first place, way back when I was a kid) and my high school course teacher. 

I wrote the code using Java on BlueJ as an Integrated Development Environment (IDE). It turned out pretty well and I'm quite proud of it. While I haven't put it up on the Internet, I have put up the entire code below. Those of you who are interested in reading the code can scroll down the page.

-

CODE FOR MASTERMIND EMULATOR (IN JAVA):


import java.lang.*;
import java.io.*;

public class Mastermind
{
    long noseq[];
    int noseq2[];
    String seq[];
    String eseq[];
    char tmpseq[];
    int white;
    int black;
   
    static String nm;
    static String lines[];
    static int wordcnt = 0;
   
    public Mastermind()
    {
        noseq = new long[4];
        noseq2 = new int[4];
        seq = new String[4];
        eseq = new String[4];
        tmpseq = new char[4];
        white = 0;
        black = 0;
        nm = new String();
        lines = new String[20];
        wordcnt = 0;
    }
   
    public static void timeloop()
    {
        for(double j = 0.0; j < 25000000.0; j++)
        {
        }
    }
   
    public void timeloop2()
    {
        for(double i = 0; i < 7500000000.0; i++)
        {
        }
    }
   
    public void genSequence()
    {
        for(int i = 0; i < 4; i++)
        {
            noseq[i] = Math.round(Math.random()*10);
           
            if(noseq[i] > 6)
            noseq[i] -= 6;
           
            if(noseq[i] < 1)
            noseq[i] += 1;
        }
                    
        for(int i = 0; i < 4; i++)
        {
            noseq2[i] = (int)(noseq[i]);
        }
    }
   
    public void saveSeq()
    {
        for(int i = 0; i < 4; i++)
        {
            switch(noseq2[i])
            {
                case 1: tmpseq[i] = 'G';
                break;
               
                case 2: tmpseq[i] = 'B';
                break;
               
                case 3: tmpseq[i] = 'R';
                break;
               
                case 4: tmpseq[i] = 'Y';
                break;
               
                case 5: tmpseq[i] = 'P';
                break;
               
                case 6: tmpseq[i] = 'O';
                break;
            }
        }
    }
   
    public void assignColours()
    {
        for(int i = 0; i < 4; i++)
        {
            if(noseq[i] == 1)
            {
                seq[i] = "Green";
            }
       
            else if(noseq[i] == 2)
            {
                seq[i] = "Blue";
            }
       
            else if(noseq[i] == 3)
            {
                seq[i] = "Red";
            }
       
            else if(noseq[i] == 4)
            {
                seq[i] = "Yellow";
            }
       
            else if(noseq[i] == 5)
            {
                seq[i] = "Purple";
            }
       
            else if(noseq[i] == 6)
            {
                seq[i] = "Orange";
            }
        }
    }
   
    public void instructions()
    {
        System.out.println();
        System.out.println("There are 6 main colours in this game: Green, Blue, Red, Yellow, Purple & Orange.");
        System.out.println("Each colour has a corresponding letter:");
        System.out.println("G – Green");
        System.out.println("B - Blue");
        System.out.println("R - Red");
        System.out.println("Y - Yellow");
        System.out.println("P - Purple");
        System.out.println("O - Orange");
        System.out.println("The letters written next to the colours are used to select the respective colours during the game.");
        System.out.println("It is recommended that you write down the color code(key) as it will not be displayed again.");
        timeloop2();
               
        System.out.println();
        System.out.println("The computer will select a random sequence of 4 colours out of the 6 main ones.");
        System.out.println("A colour may be repeated.");
        System.out.println("Your job is to deduce the correct sequence of colours in 10 chances.");
        System.out.println("In each chance, you will have to enter your own sequence to see if it matches with the computer’s sequence.");
        System.out.println("After you have entered your sequence, the computer will compare the 2 sequences & display a message.");
        System.out.println("If a colour in your sequence is present in the computer’s sequence at the same position, you will be");
        System.out.println("given a white peg (the word white will be written on the screen).");
        System.out.println("If a colour in your sequence is present in the computer’s sequence but at a different position, you ");
        System.out.println("will be given a black peg (the word black will be written on the screen).");
        timeloop2();
       
        System.out.println();
        System.out.println("Example 1:");
        System.out.println("Computer’s sequence:  Green Blue Red Yellow");
        System.out.println("Your sequence:       Green Orange Yellow Red");
        System.out.println("Display:              1 white & 2 black");
        System.out.println("Green is at the same position in both sequences (1 white).");
        System.out.println("Red is at different positions in the 2 sequences(1 black).");
        System.out.println("Yellow is at different positions in the 2 sequences(1 black).");
        timeloop2();
       
        System.out.println();
        System.out.println("Example 2: ");
        System.out.println("Computer’s sequence:    Orange Orange Purple Yellow");
        System.out.println("Your sequence:         Orange Red Purple Green");
        System.out.println("Display:               2 whites");
        System.out.println("Purple at position 3 in both – 1 white");
        System.out.println("Orange at position 1(your sequence) & position 1(computer’s sequence) – 1 white");
        System.out.println("The orange at position 2(computer's sequence) will not give a black peg as the orange at 1 is giving a white.");
        System.out.println("This holds true for all such cases in the game.");
        timeloop2();
        System.out.println();
       
        wordcnt = 0;
       
        lines[0] = "You will get 10 chances to solve the code.";
        lines[1] = "In every chance, you will have to enter a sequence based on the result of the previous sequence.";
        lines[2] = "The sequence should consist of only the starting letters of 4 colours based on the key displayed earlier.";
        lines[3] = "Example: For Green Blue Red Yellow, you will enter – GBRY (no spaces!!). ";
        lines[4] = "You are now ready to play the game. Good Luck!!! ";
        while(wordcnt < 5)
        {
            timeloop();
               
            for(int i = 0; i < lines[wordcnt].length(); i++)
            {
                System.out.print(lines[wordcnt].charAt(i));
                timeloop();
            }
           
            System.out.println();
            wordcnt++;
        }
        System.out.println();
        System.out.println();
    }
    public void game()throws IOException
    {
        String ch = new String();
        char ch1[] = new char[4];
        white = 0;
        int wh[] = new int[4];
        black = 0;
        int bl[] = new int[4];
        int cnt = 1;
              
        InputStreamReader reader = new InputStreamReader(System.in);
        BufferedReader input = new BufferedReader(reader);
       
        System.out.println("The computer has selected a random sequence of 4 colours. You have 10 chances to deduce it.");
        System.out.println("A final reminder: the 6 colours are - Green, Blue, Red, Yellow, Purple & Orange.");
        System.out.println("PLEASE TURN ON THE CAPS LOCK ON YOUR KEYBOARD AS ALL SEQUENCES HAVE TO BE ENTERED IN CAPITAL LETTERS ONLY!");
        System.out.println();
       
        outer:
        do 
        {
            saveSeq();
           
            System.out.print("Chance " + cnt + ":         ");
       
            ch = input.readLine();
           
            for(int i = 0; i < 4; i++)
            {
                ch1[i] = ch.charAt(i);
            }
           
            for(int i = 0; i < 4; i++)           //white
            {
                if(ch1[i] == tmpseq[i])
                {
                    wh[i]++;
                    ch1[i] = 'Z';
                    tmpseq[i] = 'Z';
                }
            }
       
       
            for(int i = 0; i < 4; i++)           //black
            {
                for(int j = 0; j < 4; j++)
                {
                    if(i != j)
                    {
                        if((ch1[i] == tmpseq[j]) && (ch1[i] != 'Z'))
                        {
                            bl[i]++;
                            ch1[i] = 'Z';
                            tmpseq[j] = 'Z';
                        }
                    }
                }
            }
           
            for(int i = 0; i < 4; i++)
            {
                black += bl[i];
                white += wh[i];
            }
           
            if(white == 4)
            {
                System.out.println();
                System.out.println("Congratulations " + nm + "! You have won the game.");
                break outer;
            }
            
            else
            {
                System.out.print("                                " + black + " Black & " + white + " White");
                System.out.println();
                System.out.println();
               
                for(int i = 0; i < 4; i++)
                {
                    wh[i] = 0;
                    bl[i] = 0;
                }
            }
           
            black = 0;
            white = 0;
           
            cnt++;           
        }
        while(cnt <= 10);
       
        System.out.println();
       
        if(white != 4)
        {
            System.out.println(nm + ", you have been unable to deduce the correct code. You have lost the game.......");
            System.out.println("The correct sequence was:");
            for(int i = 0; i < 4; i++)
            {
                System.out.print(seq[i] + " ");
            }
        }
    }
   
    public static void main()throws IOException
    {
        Mastermind mf4 = new Mastermind();
       
        InputStreamReader reader = new InputStreamReader(System.in);
        BufferedReader input = new BufferedReader(reader);
       
        int ch = 0;
        wordcnt = 0;
       
        lines[0] = "Welcome to Pratik Gandhi's version of the all time classic game - MASTERMIND!!!!!!!";
        lines[1] = "This game is a challenge for people of age 10 & above.";
        lines[2] = "All you need to play this game is a peice of paper, a pen and some logic.";
        lines[3] = "";
        lines[4] = "To get started, type in your name & then press enter.";
        while(wordcnt < 5)
        {
            timeloop();
               
            for(int i = 0; i < lines[wordcnt].length(); i++)
            {
                System.out.print(lines[wordcnt].charAt(i));
                timeloop();
            }
           
            System.out.println();
            wordcnt++;
        }
        nm = input.readLine();
        System.out.println();
        wordcnt = 0;
       
        lines[0] = "To play after reading the instructions, press 1 & then press enter.";
        lines[1] = "To start the game straightaway, press 2 & then press enter.";
        while(wordcnt < 2)
        {
            timeloop();
               
            for(int i = 0; i < lines[wordcnt].length(); i++)
            {
                System.out.print(lines[wordcnt].charAt(i));
                timeloop();
            }
           
            System.out.println();
            wordcnt++;
        }
        System.out.println();
        wordcnt = 0;
       
        ch = Integer.parseInt(input.readLine());
       
        switch(ch)
        {
            case 1:
            {
                mf4.instructions();
                mf4.genSequence();
                mf4.saveSeq();
                mf4.assignColours();
                mf4.game();
            }
            break;
           
            case 2:
            {
                mf4.genSequence();
                mf4.saveSeq();
                mf4.assignColours();
                mf4.game();
            }
            break;
        }
    }
}


CODE ENDS HERE.


That's all for this post.

Hope you enjoyed it!

Pratik.

Tuesday, 27 November 2012

Kooky

Hey.

This post is about someone very special to me.

I adore her and she adores me back. My mood lightens up every time I see her. If I've had a rough day, I seek comfort in her presence - the most amazing part is that she is always there to listen.

For those of you who have started to think I'm talking about my girlfriend, this is who I am actually talking about:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.



Yep. 'She' is my canine best friend:  Kooky.

Kooky actually is my 'semi-pet'. What do I mean by that?
She is technically a stray dog, but chooses to spend almost all of her time in the building in which my apartment is. She has been a resident of the building since before we moved in, and my parents, this other family living in the building and I take care of her. It's hard to guess her age, since she's always so youthful and full of life!

You might be wondering why we named her Kooky, especially when the more conventionally used pet name 'Cookie' was already available. (And no, it wasn't just for the sake of originality)
We call her Kooky because she really is Kooky. And by Kooky, I mean a wee bit crazy. (Don't look so shocked. I still love her and everything) It's just that her behaviour is a little weird. At some time during the day, she might be lying peacefully under the shade of a tree, the epitome of quiet indifference. While at some other time, she would be racing up and down the street, jumping like a circus performer, and just acting totally whacky. It's almost as if she suffers from a Split - Personality Disorder: Dr. Dog and Mrs. Crazy!

Although Kooky has a beautiful voice (I've heard her bark at other dogs), she rarely makes a sound, except when another canine strays into her territory. The amazing thing is that she has a voice, yet she CHOOSES to remain silent! It's like she's a saint or something. Her self-imposed muteness is one of the things that makes her so mysterious and enigmatic.

The past 4 years of my life have been graced with Kooky and her fun-loving, carefree nature. She reminds me that being in a good mood can really make life seem much rosier. And she always knows how to bring a smile to my face.

This post is for you, Kooky.




Tuesday, 20 November 2012

Science Fiction

Boldly Going Where No Man Has Gone Before


Hi.

I know it's been a while since I've written a blog post. It's just that I have been SO SO busy with facebook my exams. I shall definitely update my blog more frequently from now on. (I promise)

Anyway, that's enough of my excuses. Now, on to the main topic of this blog : 

Science Fiction. (I'm already salivating)

A couple of weeks ago, I started reading my first Isaac Asimov novel: 'The Caves of Steel', part of his series on robots. (Yes, I know - I started reading Asimov pretty late in life - I'm disgusted with myself too. Somehow I never came around to reading his work, which is surprising, since I ABSOLUTELY LOVE TO READ.)



















As expected, I loved it. It bound me in a web of literary fantasy. It floored me. It left me craving for more. I loved how he managed to integrate robots into human society (although there were a few bumps along the way) and how his characters literally came to life. As science fiction, it was every bit as exciting as it promised to be.

However, what amazed me most was how a writer in the 1940's and 50's could have possibly foreseen a future so far ahead and so far removed from his time! The more I thought about it, the more mind - blowingly   (pardon me, grammar Nazi's) amazing it seemed. In his time there were no personal computers, no mobile phones, manned spacecraft had not yet been launched. And yet there was this man - a remarkable individual possessing powerful foresight. You could say he was the da Vinci of his time.

Asimov himself believed that his most enduring contributions would not be his work as a biochemist or the textbooks on science that he wrote, rather his famous Three Laws of Robotics. They boggled people's minds. They gained a cult following of their own. Such was the 'scientific imagination' of Isaac Asimov.

(For those unacquainted with Asimov's 3 laws of robotics, here they are:

1. A robot may not injure a human being, or, through inaction, allow a human being to come to harm.
2. A robot must obey all orders given it by human beings except where such orders would conflict with the 1st law.
3. A robot must protect its own existence as long as such protection does not conflict with the 1st or the 2nd law.)

Another man who had similar visionary thinking was Gene Roddenberry, the creator of Star Trek. His brainchild elevated him to the status of international icon. As a die-hard Star Trek fan myself, I have a great deal of respect for the man. In the 1960's, when technology was still primitive by today's standards, Gene Roddenberry envisioned phasers, the warp drive, a galactic federation of planets and an era when man's primary aim was not the accumulation of wealth, but the expansion of his knowledge and preservation of galactic peace!

The 3 heroes of the original Star Trek series 


Granted, the special effects seen on the original Star Trek series might seem outdated compared to the visual feast that is Avatar or the Transformers movies, but what it lacked it graphics it made up for in ideas and imagination. The technology shown in Star Trek - laser guns, spacecraft travelling faster than light, teleportation, is technology that we might see after hundreds of years (if at all we do obtain it)! American physicist Michio Kaku credits Star Trek with being one of the factors that got him interested in science in the 1st place. In his books 'Visions' and 'Physics of the Impossible' he explains how the technology seen on Star Trek might one day become reality.

Science fiction might one day become reality. (How I ache for that day!) What seems like exaggerated imagination today might become commonplace many years from now. What shouldn't change, however, is man's thirst for achieving the impossible. The world needs more Asimovs and Roddenberries if we are to convert science fiction into scientific fact. 

The world needs its thinkers. But what it needs even more is its dreamers. 

Live long and prosper.