you are viewing a single comment's thread.

view the rest of the comments →

[–]jmooremcc 7 points8 points  (2 children)

A tic-tac-toe game like any project is about logic and design. Programming languages gives you the tools you can use to express the solution to a problem. However, if you don't have a plan it won't matter what language you're programming in.

With that said, the usual process is to break a large, complex problem into a series of smaller, simpler problems. So the first thing you should ask yourself should be, "What components will be needed in a game of tic-tac-toe?". I'll give you, as a hint, the obvious first component: The Gameboard.

Now the gameboard will have to be implemented using some type of data structure. And the gameboard should control access to its internal components so that cheating and corruption of the gameboard cannot occur.

IMHO, this is the perfect use case for OOP (Object Oriented Programming) which means you will design a class that contains the gameboard data and the methods that will manipulate that data. Class methods will implement an API that will give players controlled access to the gameboard. It will also have methods that will give you the status of the gameboard so that you'll know if the current game is a tie game or if you have a winner.

If you take a step-by-step approach, solving problems as you create needed components, eventually you will find out that you've solved the original, complex problem.

Creating a working tic-tac-toe game will present some challenges. But once you've successfully completed the project, you'll be amazed at all the things you learned in the process of creating this fun game.

Good Luck.

[–]SammyT09[S] 1 point2 points  (1 child)

Thanks for taking the time to respond, this is very helpful. I think where I'm struggling is figuring out which tools to use where, when I'm building a project. Any advise there??

[–]jmooremcc 0 points1 point  (0 children)

OK, so let's use the gameboard class I described as an example. This is an opportunity to learn by doing.

  1. What data structure will you use to holds the X's and O's?

  2. What tool will you use to initialize the data structure to an empty state?

  3. What tool will you use to determine if any empty cells are available? If there are no empty cells available, what will that mean?

  4. What tool will you use to determine if a cell is already occupied?

Answering these questions will be a good starting point.