TicTacToe Game Collection View With Swift
TicTacToe—Collection-View
Game Rules
A game will consist of a sequence of the following actions:
-
Initially, the “X” marks will play first (we call him/her player 1) and the player that gets to play with the “O” marks will play second (we call him/her player 2).
-
Player 1 and 2 take turns making moves. A move (mark row column) should satisfy the following constraints:
a. Move preconditions- mark is “X” if it is player 1’s turn and “O” if it is player 2’s turn.
- The position (row, column) on the board is empty.
b. Move postconditions - After the move, the position (row, column) on the board will be occupied by a mark .
- It will be the other player’s turn.
-
The game ends when either:
a. one of the players wins the game, i.e. this player gets three of his/her marks in a row (vertically, horizontally, or diagonally).
b. all the positions on the board are occupied. In this case, the game ends in a draw.