Skip to content

Commit

Permalink
test: fixed heuristic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SFossdal committed Apr 16, 2024
1 parent c538870 commit 40c449e
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions test/agents/test_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ def test_bumpiness_empty():


def test_bumpiness_five():
board = Tetris()
board.board = [

initBoard = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -362,12 +362,13 @@ def test_bumpiness_five():
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
]
board = Tetris(initBoard)
assert bumpiness(board) == 2


def test_bumpiness_nine():
board = Tetris()
board.board = [

initBoard = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -389,12 +390,13 @@ def test_bumpiness_nine():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
]
board = Tetris(initBoard)
assert bumpiness(board) == 9


def test_bumpiness_with_holes():
board = Tetris()
board.board = [

initBoard = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -416,12 +418,13 @@ def test_bumpiness_with_holes():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 1, 0, 1, 0, 1, 0],
]
board = Tetris(initBoard)
assert bumpiness(board) == 0


def test_bumpiness_40():
board = Tetris()
board.board = [

initBoard = [
[1, 0, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -443,12 +446,13 @@ def test_bumpiness_40():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
]
board = Tetris(initBoard)
assert bumpiness(board) == 40


def test_aggregate_height_zero():
board = Tetris()
board.board = [

initBoard = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -470,12 +474,13 @@ def test_aggregate_height_zero():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
board = Tetris(initBoard)
assert aggregate_height(board) == 0


def test_aggregate_height_full():
board = Tetris()
board.board = [

initBoard = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -497,12 +502,13 @@ def test_aggregate_height_full():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
board = Tetris(initBoard)
assert aggregate_height(board) == 200


def test_aggregate_height_half():
board = Tetris()
board.board = [

initBoard = [
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -524,12 +530,13 @@ def test_aggregate_height_half():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
board = Tetris(initBoard)
assert aggregate_height(board) == 100


def test_no_holes():
board = Tetris()
board.board = [

initBoard = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -551,12 +558,14 @@ def test_no_holes():
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
board = Tetris(initBoard)
assert find_holes(board) == 0, "Expected 0 holes"


def test_no_holes():
board = Tetris()
board.board = [

def test_24_holes():

initBoard = [
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -578,4 +587,5 @@ def test_no_holes():
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
]
board = Tetris(initBoard)
assert find_holes(board) == 24, "Expected 24 holes"

0 comments on commit 40c449e

Please sign in to comment.