0 votes
1 view
in Data Science by (7k points)

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;

 result([[None, None, None], [None, None, None], [None, None, None]], (1,1))

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.

Code of method:

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)


    return tempboard


    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

1 Answer

0 votes
by (14.3k points)

I think it is because of input is not valid from action try and print action it will be out of range or something

Learn Python for Data Science Course to improve your technical knowledge.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !