Esempio n. 1
0
    def get_move_cells(self):
        p1 = self.ipos + self.move_vec
        res = []
        if is_valid_icell(p1):
            res.append(p1)

        if get_y(self.ipos) == self.double_move_cell:
            p1 += self.move_vec
            if is_valid_icell(p1):
                res.append(p1)
        return [res]
Esempio n. 2
0
    def get_move_cells(self):
        p1 = self.ipos + self.move_vec
        res = []
        if is_valid_icell(p1):
            res.append(p1)

        if get_y(self.ipos) == self.double_move_cell:
            p1 += self.move_vec 
            if is_valid_icell(p1):
                res.append(p1)
        return [res]
Esempio n. 3
0
    def get_hit_cells(self):
        p1 = self.ipos + self.hv1
        res = []
        if is_valid_icell(p1):
            res.append([p1])

        p2 = self.ipos + self.hv2
        if is_valid_icell(p2):
            res.append([p2])

        #print self, to_str_pos(self.ipos), "=>", [to_str_pos(i[0]) for i in res]
        return res
Esempio n. 4
0
    def get_hit_cells(self):
        p1 = self.ipos + self.hv1
        res = []
        if is_valid_icell(p1):
            res.append([p1])

        p2 = self.ipos + self.hv2
        if is_valid_icell(p2):
            res.append([p2])

        #print self, to_str_pos(self.ipos), "=>", [to_str_pos(i[0]) for i in res]
        return res
Esempio n. 5
0
def test_is_valid_poses():
    for x in range(8):
        for y in range(8):
            ok(is_valid_cell((x, y))).is_truthy()
            ok(is_valid_icell(x * 0x10 + y)).is_truthy()

    for x in (-200, 1.42, "as", -1, 8, 9, 100):
        for y in range(8):
            ok(is_valid_cell((x, y))).is_falsy()

    for y in (-200, 1.42, "as", -1, 8, 9, 100):
        for x in range(8):
            ok(is_valid_cell((x, y))).is_falsy()

    for y in (-200, 1.42, "as", -1, 8, 9, 100):
        for x in (-200, 1.42, "as", -1, 8, 9, 100):
            ok(is_valid_cell((x, y))).is_falsy()
Esempio n. 6
0
def test_is_valid_poses():
    for x in range(8):
        for y in range(8):
            ok(is_valid_cell((x, y))).is_truthy()
            ok(is_valid_icell(x * 0x10 + y)).is_truthy()

    for x in (-200, 1.42, "as", -1, 8, 9, 100):
        for y in range(8):
            ok(is_valid_cell((x, y))).is_falsy()

    for y in (-200, 1.42, "as", -1, 8, 9, 100):
        for x in range(8):
            ok(is_valid_cell((x, y))).is_falsy()

    for y in (-200, 1.42, "as", -1, 8, 9, 100):
        for x in (-200, 1.42, "as", -1, 8, 9, 100):
            ok(is_valid_cell((x, y))).is_falsy()
Esempio n. 7
0
 def get_move_cells(self):
     return [[self.ipos + diff] for diff in self.move_diffs
             if is_valid_icell(self.ipos + diff)]
Esempio n. 8
0
 def get_move_cells(self):
     return [[self.ipos + diff] 
                 for diff in self.move_diffs 
                     if is_valid_icell(self.ipos + diff)]