示例#1
0
def test_get_all_scales():
    sc = [map(to_tuple_pos, i) for i in get_all_iscales(0, Rook.vects) if i != []]

    ok(sc).length(2)
    s1, s2 = sc

    ok(min(s1[0][0], s2[0][0])) == 0

    if s1[0][0] != 0:
        s1, s2 = s2, s1

    ok(set(s1)) == {(0, i) for i in range(1, 8)}
    ok(set(s2)) == {(i, 0) for i in range(1, 8)}

    sc = [map(to_tuple_pos, i) for i in get_all_iscales(0, Bishop.vects) if i != []]
    ok(sc).length(1)
    ok(set(sc[0])) == {(i, i) for i in range(1, 8)}

    for pos in [(3, 4), (0, 0), (2, 3), (7, 7), (0, 7)]:
        for color in "BW":
            for piece_cl in (Rook, Queen, Bishop):
                pmc1 = get_all_iscales(to_int_pos(pos), piece_cl.vects)
                pmc2 = piece_cl(to_int_pos(pos), color).move_cells()
                pmc1.sort()
                pmc2.sort()

                ok(pmc1) == pmc2
示例#2
0
def test_get_all_scales():
    sc = [
        map(to_tuple_pos, i) for i in get_all_iscales(0, Rook.vects)
        if i != []
    ]

    ok(sc).length(2)
    s1, s2 = sc

    ok(min(s1[0][0], s2[0][0])) == 0

    if s1[0][0] != 0:
        s1, s2 = s2, s1

    ok(set(s1)) == {(0, i) for i in range(1, 8)}
    ok(set(s2)) == {(i, 0) for i in range(1, 8)}

    sc = [
        map(to_tuple_pos, i) for i in get_all_iscales(0, Bishop.vects)
        if i != []
    ]
    ok(sc).length(1)
    ok(set(sc[0])) == {(i, i) for i in range(1, 8)}

    for pos in [(3, 4), (0, 0), (2, 3), (7, 7), (0, 7)]:
        for color in "BW":
            for piece_cl in (Rook, Queen, Bishop):
                pmc1 = get_all_iscales(to_int_pos(pos), piece_cl.vects)
                pmc2 = piece_cl(to_int_pos(pos), color).move_cells()
                pmc1.sort()
                pmc2.sort()

                ok(pmc1) == pmc2
示例#3
0
 def get_move_cells(self):
     return get_all_iscales(self.ipos, self.vects)
示例#4
0
 def get_move_cells(self):
     return get_all_iscales(self.ipos, self.vects)