I have the error: "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()" in three lines:
col, minimax_score = int(minimax(board, 2, -math.inf, math.inf, True))
,
valid_locations = get_valid_locations(board)
and
if available_square(board, col):
I searched for possible solutions in the Internet (for e.g. using (a-b).any()
or (a-b).all()
instead of a and b
) but none of them seemed to apply to my case.
edit:
The "minimax" function is very long so I will just add this:
def minimax(board, depth, alpha, beta, maximizingPlayer):
This is the "get_valid_locations" function:
def get_valid_locations(board):
valid_locations = []
for col in range(BOARD_COLS):
if available_square(board, col):
valid_locations.append(col)
return valid_locations
This is the "available_ square" function:
def available_square(row, col):
return board[row][col] == 0