refactor(ai): get_peaks

This commit is contained in:
Kristofers Solo 2024-01-05 17:42:10 +02:00
parent 1ce17c43ba
commit aca113f562

View File

@ -4,14 +4,8 @@ from ai.log import log
def get_peaks(field: np.ndarray) -> np.ndarray:
col_num = field.shape[1]
peaks = np.zeros(col_num)
for col in range(col_num):
if 1 in field[:, col]:
peaks[col] = field.shape[0] - np.argmax(field[:, col], axis=0)
return peaks
peaks = np.where(field == 1, field.shape[0] - np.argmax(field, axis=0), 0)
return peaks.max(axis=0)
def get_peaks_max(field: np.ndarray) -> int: