- Joined
- Oct 10, 2013
- Messages
- 173
So recently I have been making an AI in tic tac toe game.
unfortunately it is giving me headache by this error.
The original code of the function
unfortunately it is giving me headache by this error.
Code:
The current situation of board is...
EMPTY EMPTY X
EMPTY EMPTY 0
EMPTY EMPTY EMPTY
The squares starts from 1 to 9.
Which square do you want to move?
9
The current situation of board is...
EMPTY EMPTY X
EMPTY EMPTY 0
EMPTY EMPTY X
yes
Traceback (most recent call last):
File "D:\Softwares\Developing\Python\Installation\programs\TicTacToePractical.py", line 147, in <module>
board_update(move,computer)
File "D:\Softwares\Developing\Python\Installation\programs\TicTacToePractical.py", line 67, in board_update
temp = temp - 1
TypeError: unsupported operand type(s) for -: 'list' and 'int'
The original code of the function
Code:
def board_update(move,player): #Tested, and disapproved.
'''Updates the board with respect to input given by the user'''
temp = move
global board
global used
global X
global O
if player == 'X':
board[move-1] = 'X'
used = used + [move]
else:
temp = temp - 1
board[temp] = 0
used = used + [temp]