From 9daa4f650903059f1f036a83d6ad47dcd0c41e17 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Tue, 9 Jan 2024 20:28:31 +0200 Subject: [PATCH] feat(ai): add `aggregate_height` --- src/ai/heuristics/height.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ai/heuristics/height.py b/src/ai/heuristics/height.py index 9ee8550..8f87b05 100644 --- a/src/ai/heuristics/height.py +++ b/src/ai/heuristics/height.py @@ -2,4 +2,13 @@ import numpy as np def aggregate_height(field: np.ndarray[int, np.dtype[np.uint8]]) -> int: - return 0 + """ + Calculates the aggregate height of the field. + + Args: + field: 2D array representing the game field. + + Returns: + The aggregate height of the field. + """ + return int(np.sum(field.shape[0] - np.argmax(field, axis=0)))