I'm troubled with the np.where() function. (line 7 in my example)
Background: I am programming the game "Connect Four". This insert_chip() method accesses the variable self.board which is an 8x8 np array of my personal dtype Chip. If there is no chip in an entry of self.board, then the value is None.
For some reason, np.where(col_entries is None) does not return the indices of the elements that are None. And why do I receive a different output, when I write col_entries == None in the condition? It's not a if None has a reference right?
def insert_chip(self, chip, col):
# slices the entries of the column into a new array
col_entries = self.board[:, col:col+1]
# checks for all unoccupied pos in this col (entries are None)
# gives double array of indexes with the form (array([row_i, ...]), array([col_i, ...]))
none_indexes = np.where(col_entries is None)
# the pos where the chip will fall is the one with the highest index
self.board[len(none_indexes[0]), col] = chip