Tetris/tests/ai/test_moves.py
2024-01-06 17:56:02 +02:00

21 lines
565 B
Python

import unittest
import numpy as np
from ai.moves.height import aggregate_height
class TestFitness(unittest.TestCase):
def test_aggregate_height(self):
field = np.array(
[
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 0, 0, 1],
[0, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
]
)
self.assertEqual(aggregate_height(field), 48)