Hello... I'm Kelechi Ngaka a computer scientist who makes things (code/food/designs), and welcome to my awesome blog powered by Blogger

X and O in C

+
Most times my friends ask me how I was able to do this game, I would always try to explain, but the story is too long. This is the shorter version of how I did it. Read it and be inspired to even do more and better.

After learning the basics of C like printing a line of text, accepting inputs and making decisions, then i realized i had to take my programming in C to another level. While brain storming, it just came to me that i should try to develop a game in C which requires A.I (Artificial Intelligence). Now, the main X and O game requires 2 players to place crosses(X) and noughts(O) into squares on a grid with nine spaces, the winner is the first person to form a row of three noughts(O) or crosses(X). Note that the positions available is reduced at every play.

Looking at it from the surface, it looks simple. So my plan was to develop an X and O game in which the user plays against A.I. As you play, the c.p.u (Kelechi's A.I) would have to decide from the numerous possible places to play. For me to carry out this monstrous programming in C, I had to play the game against myself on paper for close to 70 times with different approaches and techniques, just to see errors and flaws in the game. While doing that, I was building the flow chart, all these stuffs where done by only me, on only one laptop.

It took me 3 weeks to complete the 1st phase of the development i.e Programming and Designing, and an additional 2 weeks for Testing and Maintenance. When the program was ready, i showed it to my room mates in which they were very delighted in what I did. They were even happy to be playing a game programmed by a friend. The game was played by most of the computer scientist close to me, each commending me on the superb A.I that was built. This A.I recorded no loss to any human, only wins and draws. I was glad I completed that huge task.To the high extent of superiority, i gave price to anyone that ever beats my A.I in the game N1000, this was stated in the game before you play. Thanks to my friends for supporting me with their inspirational talks and ideas.

The X and O program had up to 3470 lines of codes, and with the experience gained in the process I am never scared of coding. All the codes were hand typed as in, there were no code generators. It was developed by me when I was in yr 2 during the holidays.

My Last words are, always go for what you believe in and with time you would achieve it.