mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
refactor(ai): get_peaks
This commit is contained in:
parent
1ce17c43ba
commit
aca113f562
@ -4,14 +4,8 @@ from ai.log import log
|
|||||||
|
|
||||||
|
|
||||||
def get_peaks(field: np.ndarray) -> np.ndarray:
|
def get_peaks(field: np.ndarray) -> np.ndarray:
|
||||||
col_num = field.shape[1]
|
peaks = np.where(field == 1, field.shape[0] - np.argmax(field, axis=0), 0)
|
||||||
peaks = np.zeros(col_num)
|
return peaks.max(axis=0)
|
||||||
|
|
||||||
for col in range(col_num):
|
|
||||||
if 1 in field[:, col]:
|
|
||||||
peaks[col] = field.shape[0] - np.argmax(field[:, col], axis=0)
|
|
||||||
|
|
||||||
return peaks
|
|
||||||
|
|
||||||
|
|
||||||
def get_peaks_max(field: np.ndarray) -> int:
|
def get_peaks_max(field: np.ndarray) -> int:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user