Tic Tac Toe

Traditional tictactoe game, using Graphics User Interface.

You are now following this Submission

A 2D matrix is declared and initialized with zeros, as any player turns, the corresponding 1 or 2 is written in the matrix.
After each turn the matrix is checked in function "whowins.m", with any number (1 or 2) coming three in line, that number is returned other wise '0', if -1 is returned it means its a draw.

winning logic simply checks all possible options a player can win and the corresponding function is called after each turn.
The 2D array is updated each turn and whowins.m is checking that for all three cases (player 1 wins, player 2 wins and Draw)

Cite As

Suleman Shafqat (2026). Tic Tac Toe (https://www.mathworks.com/matlabcentral/fileexchange/30633-tic-tac-toe), MATLAB Central File Exchange. Retrieved .

Acknowledgements

Inspired: 3 Player TicTacToe

Categories

Find more on Strategy & Logic in Help Center and MATLAB Answers

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.1.0.0

Details added for description and learning point of view.

1.0.0.0