I was fascinated with technology ever since I can remember. I was curious and knowing something gives me happiness. After 19 years, I didn't lose that interest. I am now a Computer Science student in second year of B.Tech programme. Unlike other students, I always wanted to do something that differentiates me from the rest. I decided to build applications. In my first semester, I did three, two in the next semester and only one in my third semester. All but the last one were nothing but small games. The last one is a Tic Tac Toe.
Tic Tac Toe, popularly knows as Noughts and Crosses. The game is played by two players where one of them takes X and other O. The winner is the player who forms three of their symbol consecutively. The speciality of the game is that, if both the players are careful, none can win. There were already games like these and even this one developed by many people. But, I wanted to build one myself, especially where the second player is played by the program itself.
I choose Java to build it because it had GUI tools that we have just learnt. It took me about four to five hours to write the logic. I did it with certain motives in mind. To check if the program can win, to defend, to make a move which lays the foundation for next move, to predict and stop the player's move. Finally, with the GUI, I built an application that had buttons and windows to display appropriate messages.
It was about 7 PM when I gave this to my father and challenged him to win against it. He played and it was a draw. Then he played again and he won. Then, I asked to play the same way again. He did and he won. I noted the steps, opened the IDE and changed the source code to defend itself. Now I asked my father play again. Despite multiple attempts, he either lost or made a draw but never won.
Overwhelmed with happiness, I challenged my sister to play against it. She did and won. It took me some time to write the code and these people were winning against it like nothing. Then I found out that the bug I covered up to defend my father's play has opened another bug which was not there earlier. Wth all the happiness gone, I took back my laptop and went into my room. Opened the source code and started debugging. After about ten minutes, I was found a patch to both those bugs. Then I took it my sister, she either lost of made a draw but never won.
I, myself tried other inputs and did not win the game. I pushed it to my Github repository hoping to show all my friends the next day. I never liked to do the lab programs in the lab. I always used to finish it before and have fun in the lab while I see my friends stuck somewhere while doing it. So came the next day and the Java Lab.
As usual, I opened my Google Drive, downloaded my programs that I did three weeks ago on a holiday when my friends were watching 'Jai Lava Kusa' and 'Spyder'. It was running perfectly and I put it aside. The atmosphere in the lab eased and I pulled the source code from my Github repository and ran it.
Pranav was the first one to try it. To my bad luck, he won. I realised I prioritised the wrong outcomes. Made changes and got over his play. Harsha played next and he didn't crack it. Next was Vidya. She came in like a typical nine pointer and won. Fish, I had to change my code again. Now it was good enough. I tried to play against Google's 'Impossible' level and it was always a draw. Several other people played it and were amused to see themselves lose.
I learnt that automating something isn't as difficult as I thought it was. It was much challenging. After all, a game of tic tac toe required all these testing and debugging. Also, after each of them played, I learnt a new method to trick the other player, which was the program in this place. So, what if, I wrote a program which learns from the game by considering the player's inputs and plays the next game smarter. Like it might lose a game with someone, but when those same inputs are entered again, it should be able to counteract. Like there was certain intelligence in the program.
Like I told you, I am curious all the time and I can google something very appropriately. I did it. I found about Machine Learning and Deep Learning. I read about them. I understood them better than before because now I know why it is used for. Suppose, it was a game of chess. Maybe, I could be changing the code for my entire life and still lose or write that intelligent program, train it on data and let it win.
I never quite understood Machine Learning properly. I thought maybe it was above my level of understanding or someone needs to teach me. But then, it all goes by the saying, "Experience is the best teacher".
If you are interested, check out the source code at my github repository.
Comments
Post a Comment