mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
feat(ai): add holes
This commit is contained in:
parent
9daa4f6509
commit
00da10e482
@ -4,4 +4,19 @@ import numpy as np
|
|||||||
def holes(
|
def holes(
|
||||||
field: np.ndarray[int, np.dtype[np.uint8]],
|
field: np.ndarray[int, np.dtype[np.uint8]],
|
||||||
) -> int:
|
) -> int:
|
||||||
return 0
|
"""
|
||||||
|
Calculate the number of holes in each column of the given field.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
field: The signal field.
|
||||||
|
peaks: Array containing peak indices. If not provided, it will be computed from the field.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The total number of holes in the field.
|
||||||
|
"""
|
||||||
|
|
||||||
|
first_nonzero_indices = np.argmax(field != 0, axis=0)
|
||||||
|
|
||||||
|
mask = (field == 0) & (np.arange(field.shape[0])[:, np.newaxis] > first_nonzero_indices)
|
||||||
|
|
||||||
|
return int(np.sum(mask))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user