Skip to content

Commit 59c7ff4

Browse files
author
Christian Bender
committed
added numbered play field
1 parent 7248a3f commit 59c7ff4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

TicTacToe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def playAgain():
4040
return input().lower().startswith('y')
4141

4242
def makeMove(board, letter, move):
43-
if board[move] == ' ':
43+
if isSpaceFree(board,move):
4444
board[move] = letter
4545
else:
4646
raise Exception("makeMove: the field is not empty!")
@@ -68,7 +68,7 @@ def getBoardCopy(board):
6868

6969
def isSpaceFree(board, move):
7070
# Return true if the passed move is free on the passed board.
71-
return board[move] == ' '
71+
return board[move].isdigit()
7272

7373
def getPlayerMove(board):
7474
# Let the player type in his move.
@@ -141,6 +141,8 @@ def main():
141141
while True:
142142
# Reset the board
143143
theBoard = [' '] * 10
144+
for i in range(9,0,-1):
145+
theBoard[i] = str(i)
144146
playerLetter, computerLetter = inputPlayerLetter()
145147
turn = whoGoesFirst()
146148
print('The ' + turn + ' will go first.')

0 commit comments

Comments
 (0)