aboutsummaryrefslogtreecommitdiffstats
path: root/tests_solver/test_solver.py
blob: e2b45a56c2b74fb37d0bbc31b0b7c1ace0a090d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3

import os
import sys

sys.path.append(os.getcwd())

from solver import *

def test_is_swappable():
    assert is_swappable(Kana("norm", "su"), Kana("norm", "su"))
    assert is_swappable(Kana("froz", "su"), Kana("norm", "su"))
    assert is_swappable(Kana("norm", "su"), Kana("empt"))
    assert is_swappable(Kana("empt"), Kana("froz", "su"))
    assert not is_swappable(Kana("norm", "su"), Kana("rock", "su"))
    assert not is_swappable(Kana("froz", "su"), Kana("froz", "su"))
    assert not is_swappable(Kana("empt"), Kana("empt"))


def test_kana_grid():

    initial_grid = [
        kana_void         , Kana("myst", "su"), kana_void         , Kana("myst", "ko"), kana_void         ,
        Kana("froz", "se"), Kana("empt"      ), Kana("empt"      ), Kana("empt"      ), Kana("froz", "so"),
        Kana("froz", "ku"), Kana("empt"      ), Kana("empt"      ), Kana("empt"      ), Kana("froz", "no"),
        kana_void         , kana_void         , Kana("rock", "ka"), kana_void         , kana_void         ,
    ]
    initial_grid_size = 5, 4
    chain_target = 7

    expected_grid = [
        kana_void         , Kana("myst", "su"), kana_void         , Kana("myst", "ko"), kana_void         ,
        Kana("empt"      ), Kana("empt"      ), Kana("empt"      ), Kana("froz", "se"), Kana("froz", "so"),
        Kana("froz", "ku"), Kana("empt"      ), Kana("empt"      ), Kana("empt"      ), Kana("froz", "no"),
        kana_void         , kana_void         , Kana("rock", "ka"), kana_void         , kana_void         ,
    ]

    kanagrid_orig = KanaGrid(initial_grid_size, initial_grid)
    kanagrid_new  = kanagrid_orig.action(pos=(0, 1), action_type="right")

    print("kanagrid_orig")
    print(kanagrid_orig)
    print("kanagrid_new")
    print(kanagrid_new)
    print("expected_grid")
    display_grid(expected_grid, initial_grid_size)

    assert kanagrid_new.grid == expected_grid