Get the position of the biggest item in a multi-dimensional numpy array, use unravel_index
.
In [170]: state
Out[170]:
array([[8, 5],
[3, 2],
[5, 1],
[9, 6]])
In [171]: state.argmax()
Out[171]: 6
In [172]: maxidx = state.argmax()
In [173]: np.unravel_index(maxidx, state.shape)
Out[173]: (3, 0)