In result method we give input board which is a list of 3 elements like in tictactoe and action as in a place where we want to keep X or O in tuple form eg. if we put X in center and board is empty then it will look like;
So initially in the first step, it is not showing any error when we make move for the first time but the second time it is showing error.
def result(board, action):
"""
Returns the board that results from making move (i, j) on the board.
"""
#play = player(board)
tempboard = board
print("board...........", board)
print("Action[0] ===> ", action[0])
print("Action[1] ===> ", action[1])
if board[action[0]][action[1]] == EMPTY:
tempboard[action[0]][action[1]] = player(board)
print(tempboard)
return tempboard
else:
raise NotImplementedError('Invalid Action')
While the error being: -
board........... [[None, None, None], [None, None, None], [None, None, None]]
Action[0] ===> 1
Action[1] ===> 2
[[None, None, None], [None, None, 'X'], [None, None, None]]
board........... [[None, None, None], [None, None, 'X'], [None, None, None]]
Traceback (most recent call last):
File "C:/Users/hkfghdk/Google Drive/VIT/Harvard/CS50 AI/week0/tictactoe/runner.py", line 116, in <module>
board = ttt.result(board, move)
File "C:\Users\hkfghdk\Google Drive\VIT\Harvard\CS50 AI\week0\tictactoe\tictactoe.py", line 68, in result
print("Action[0] ===> ", action[0])
TypeError: 'NoneType' object is not subscriptable