Python Forum
Text Based Tic Tac Toe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text Based Tic Tac Toe
#1
I've been given an assignment that utilises the random function in python to make a simple game. I've chosen to make a text based tic tac toe, player vs AI game. Ive gotten the board up by:
x = ['1','2','3','4','5','6','7','8','9'] #values to be inserted to                     the board per layer from left to right. 
Layer1 = '[ ' + x[0] + ' ] ' + ' [ ' + x[1] + ' ] ' + ' [ ' + x[2] + ' ]'
Layer2 = '[ ' + x[3] + ' ] ' + ' [ ' + x[4] + ' ] ' + ' [ ' + x[5] + ' ]'
Layer3 = '[ ' + x[6] + ' ] ' + ' [ ' + x[7] + ' ] ' + ' [ ' + x[8] + ' ]' 
print(Layer1 + '\n' + Layer2 + 'n' + Layer3)

Then I would have all the contents of 'x' replaced with '', and have the user input from 1 - 9 and verify if that slot has already been taken, and if not replace it with an 'x', but somehow when I print out Layer1 to Layer3, it still shows the values of 1 to 9 even though it says that the array has been replaced.
I should also state that this is in 2.7 and this is occuring inside a non repeating function.
Reply


Messages In This Thread
Text Based Tic Tac Toe - by incineratez - Nov-11-2017, 06:21 AM
RE: Text Based Tic Tac Toe - by heiner55 - Nov-11-2017, 03:13 PM
RE: Text Based Tic Tac Toe - by incineratez - Nov-19-2017, 04:46 AM
RE: Text Based Tic Tac Toe - by heiner55 - Nov-19-2017, 10:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  beginner having text based adventure trouble mrgee 2 2,128 Dec-16-2021, 05:07 AM
Last Post: buran
  Random Math Text Based Game captainflint 2 4,539 Aug-05-2018, 05:40 PM
Last Post: ahsankhan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020