0% found this document useful (0 votes)
3 views

samcodepy

The document is a Python script for a Tic Tac Toe game, featuring a game board initialized with empty spaces and a current player set to 'X'. It includes functions to print the board, input player moves, and check for wins or ties. However, there are some errors in the code, such as incorrect function names and indentation issues that need to be addressed for proper functionality.

Uploaded by

santanathan828
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

samcodepy

The document is a Python script for a Tic Tac Toe game, featuring a game board initialized with empty spaces and a current player set to 'X'. It includes functions to print the board, input player moves, and check for wins or ties. However, there are some errors in the code, such as incorrect function names and indentation issues that need to be addressed for proper functionality.

Uploaded by

santanathan828
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import random

board=["-","-","-",
"-","-","-",
"-","-","-"]
Currentplayer="X"
Winner= None
gameRunner= True
print("welcome to TICTACTOE.py")
#print board
def printboard(board):
print(board[0]+"|"+board[1]+"|"+board[2])
print("-------")
print(board[3]+"|"+board[4]+"|"+board[5])
print("-------")
print(board[6]+"|"+board[7]+"|"+board[8])

#input player
def inputplayer(board, Currentplayer):

Inp=int(input("selectionnez une case:"))


if board[Inp-1] =="-":
board[Inp-1]=Currentplayer
else:
print("cette case est déja utilisée")
#check the win or tie
return True
return False
def Checkcolumms(board, Currentplayer):
for i in range(0,9,3):
if board[i]==board[i+3]==board[i+6] and board[i]!="-":
return True
return False
def Checkdiag(board, Currentplayer ):
if board[0]==board[4]==board[8] and board[0]!="-":
return True
if board[2]==board[4]==board[6] and board[2]!="-":
return True
return False
# Declarer le win or tie
def CheckWin(board, Currentplayer):
if Checkhorizantle(board, Currentplayer) or Checkcolumns(board, Currentplayer)
or Checkdiag(board, Currentplayer):
return True
return False

You might also like