From 89884d7e2a878b0a482478feb982cd25142a3344 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Tue, 9 Jan 2024 20:27:56 +0200 Subject: [PATCH] feat(ai): add `bumpiness` --- src/ai/heuristics/bumpiness.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ai/heuristics/bumpiness.py b/src/ai/heuristics/bumpiness.py index 03b4828..17c57ae 100644 --- a/src/ai/heuristics/bumpiness.py +++ b/src/ai/heuristics/bumpiness.py @@ -4,4 +4,13 @@ import numpy as np def bumpiness( field: np.ndarray[int, np.dtype[np.uint8]], ) -> int: - pass + """ + Calculate the bumpiness of a given signal based on peaks. + + Args: + field: The game field. + + Returns: + The bumpiness of the field. + """ + return int(np.sum(np.abs(np.diff(field.shape[0] - np.argmax(field, axis=0)))))