Sunday, June 19, 2011

My Works | Tic-Tac-Toe Game [Model]

Problem: We hope we are all known with the game Tic-Tac-Toe. Well..if we are not, we will be soon. You will not have to build any artificial intelligence for the game as the game will be played by two human, I mean users. Lets get into it.....


In a Tic Tac Toe game there will be a board with minimum 9 cells as follows.

Two player will have to select two different symbols to play with. Such as,

Player 1 taken '0'
Player 2 taken 'X'

Now they will put their symbols in the cells one at each turn. If a player become able to put 3 of his/her symbol in the cells on the board diagonally or horizontally or vertically then the player will be the winner.

Let us mark the cells of the above given picture as follows,


So some of the winning combinations are (1,2,3), (1,4,7), (1,5,9) etc. That is if a player can put his or her symbol in cells 1 and 2 and 3, the player will be the winner. Again if a player can put his or her symbol in cells 1 and 5 and 9, the player will be the winner. [Find out other winning combinations yourself]

Remember, one player can put his or her symbol only once in a turn.

Well, I think all of you are known with this game, so for this specific problem I advice you to download my program on this problem, to see what I was trying to explain at all. Just download and play.


This program will ask you to enter the name of the two players, then this will take you to the board where it will ask the player by given name to enter symbol. To enter symbol, you will have to press the cell number in which the player wants to put the symbol.

Initial Screen:


Next Screen:




Pressing "Y" to play again:


I wish all of you will like it. I am really sorry that I think, I didn't explain it well. I am weak at explaining things.

Happy Coding.


No comments:

Post a Comment

Leave your valuable thoughts before leaving..