mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
21 lines
389 B
Python
21 lines
389 B
Python
import numpy as np
|
|
|
|
from .peaks import get_peaks
|
|
|
|
|
|
def get_bumpiness(
|
|
field: np.ndarray[int, np.dtype[np.uint8]],
|
|
) -> int:
|
|
"""
|
|
Calculate the bumpiness of a given field based on peaks.
|
|
|
|
Args:
|
|
field: The game field.
|
|
|
|
Returns:
|
|
The bumpiness of the field.
|
|
"""
|
|
field = get_peaks(field)
|
|
diff = np.diff(field)
|
|
return int(np.sum(np.abs(diff)))
|