Shadow1
Shadow1

Reputation: 9

Tic Tac Toe winning algorithm

I have a school project that asked me to create a 6*7 tic tac toe game but i don't know how to check for a wining condition my idea is to pass the current row and current column to a method and loop through the 3x3 box that contains the token but i can't figure out how

Upvotes: 0

Views: 317

Answers (1)

Codor
Codor

Reputation: 17595

If I understood the question correctly, you are looking for an approach to implement an algorithm to play Tic Tac Toe (or a similar two-player boardgame like Four in a Row, if that is the correct name). A suitable algorithm would be the Minimax algorithm which aims at recursively evaluating the game tree, taking the alternating perspective of each player. If the game uses different traits, like different board games or different winning configurations, the algorithm has to be adapted; however the basic approach remains the same.

Upvotes: 1

Related Questions