mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2026-03-22 00:36:20 +00:00
feat(ai): add get_peaks
This commit is contained in:
14
src/ai/fitness/peaks.py
Normal file
14
src/ai/fitness/peaks.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import numpy as np
|
||||
|
||||
from ai.log import log
|
||||
|
||||
|
||||
def get_peaks(field: np.ndarray) -> float:
|
||||
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 float(np.sum(peaks))
|
||||
Reference in New Issue
Block a user