# Need help with tic tac toe pseudocode

I have most of the functional components working minus the actual game. How can I check through rows, columns, and diagonals of a table for a winner? How do I set it up? It’s a bit overwhelming to get started on the game logic.

You’ve actually helped me out… Ive been staring at this challenge for the past day just feeling overwhelmed and having no idea where to start at all… But getting the layout and click functions done would be some progress lol

Ill keep an eye out for any advice you get… in the meantime, Ive been able to gather that a lot of people use the MiniMax AI for the gameplay algorithm… though Ive also seen some people build their own algorithm from scratch by coding in every possible move. The more I read, the more I know, yet the more confused I am and still no closer to actually getting it done, so truly do appreciate the kick in the right direction by seeing what you have done so far

Oh, and I saved this link that I came across earlier today… maybe it will help you: http://neverstopbuilding.com/minimax

1 Like

Yes it can be overwhelming - all that means is the problem is too vague for you to comprehend - try to break it down into smaller pieces till you find a small enough subproblem that has a clear statement

a clear statement is one where the meaning of each term is clear enough for you to work out a solution with pen and paper that can be confirmed against the problem statement

a solution is a set of instructions in everyday language that is guaranteed to produce the right answer if followed blindly by anyone without guidance

once you have a pen and paper solution you can start to express it in programmatic terms

programmatic terms are variables, objects, arrays, functions, loops, conditions etc

it all starts with the smallest problem you can state and solve

it’s small enough if you don’t get stuck trying to solve it - if you do break it down even more

we can go through the exercise right here - let’s start with someone providing a problem statement

1 Like

Update on my progress, almost done but I am stuck on a couple of things:

• How to compare the wincombos array once the x and o array size get larger than 3
• How to clear the board completely when I reset it

Looks like you are coming right along.

How to compare the wincombos array once the x and o array size get larger than 3

Well, let’s think this through. You have an array with all of your win combos already. Can you compare the player moves array with the wincombos array and find a match? Once you figure that out all you would need to do is call your checkWinner function after every move. I think I wrote the function to advance the turn if there was no winner, or to end the game if there was a winner, but this can be done a myriad of different ways.

How to clear the board completely when I reset it

I would look at what has changed during the game and then undo all of those changes. Did you fill a couple arrays with player moves? if so, empty them. Did you insert text into your board to show each move? Empty all of that text. After you have reverted everything to back how it was before you started playing you would need to initiate the process all over again.

Good luck!

1 Like