mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
feat(ai): add get_peaks
This commit is contained in:
parent
4a985b7e01
commit
bbdb824e52
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))
|
||||||
Loading…
Reference in New Issue
Block a user