From b2bea7d03ac6050c2b45dce3e0ff4de6ceb033ff Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Thu, 11 Jan 2024 18:59:51 +0200 Subject: [PATCH] fix(ai): `aggregate_height` function --- src/ai/heuristics/height.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ai/heuristics/height.py b/src/ai/heuristics/height.py index 8f87b05..c511e74 100644 --- a/src/ai/heuristics/height.py +++ b/src/ai/heuristics/height.py @@ -11,4 +11,10 @@ def aggregate_height(field: np.ndarray[int, np.dtype[np.uint8]]) -> int: Returns: The aggregate height of the field. """ - return int(np.sum(field.shape[0] - np.argmax(field, axis=0))) + heights = np.zeros(field.shape[1], dtype=np.uint8) + for col in range(field.shape[1]): + for row in range(field.shape[0]): + if field[row, col] != 0: + heights[col] = field.shape[0] - row + break + return int(np.sum(heights))