From bba625f8f623f39f665ccd88fb07624668d36cf1 Mon Sep 17 00:00:00 2001 From: Chard Peter Date: Mon, 22 Jan 2024 14:54:51 +0000 Subject: [PATCH] Added comments to explain what is being done in TicTacToe.py --- Tic-Tac-Toe/TicTacToe.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tic-Tac-Toe/TicTacToe.py b/Tic-Tac-Toe/TicTacToe.py index abb03fb6..d554e8f2 100644 --- a/Tic-Tac-Toe/TicTacToe.py +++ b/Tic-Tac-Toe/TicTacToe.py @@ -3,7 +3,8 @@ def insertLetter(letter,pos): board[pos] = letter - +# Setting out the base plate for the game + def spaceIsfree(pos): return board[pos] == ' ' @@ -20,6 +21,8 @@ def printBoard(board): print(" " + board[7] + " | " + board[8] + " | " + board[9]) print(" | | ") +# Checking if the board is full or not + def isBoardFull(board): if board.count(" ") > 1: return False @@ -27,7 +30,7 @@ def isBoardFull(board): return True def isWinner(b,l): # b = board, l = letter - # check all possibilities + # check all winning possibilities return ((b[1] == l and b[2] == l and b[3] == l) or (b[4] == l and b[5] == l and b[6] == l) or (b[7] == l and b[8] == l and b[9] == l) or (b[1] == l and b[4] == l and b[7] == l) or (b[2] == l and b[5] == l and b[8] == l) or (b[3] == l and b[6] == l and b[9] == l) or (b[1] == l and b[5] == l and b[9] == l) or (b[3] == l and b[5] == l and b[7] == l)) def userMove():