Exemplo n.º 1
0
    def test_diag_LU(self):

        self.assertEquals(Pos(algebra_to_cartesian("a1")).diag("LU", 5), [])
        self.assertEquals(Pos(algebra_to_cartesian("a8")).diag("LU", 5), [])

        print(Pos(algebra_to_cartesian("h8")).diag("LU", 5))
        self.assertEquals(Pos(algebra_to_cartesian("h8")).diag("LU", 5), [])
Exemplo n.º 2
0
    def test_knight_hops(self):

        self.assertEquals(
            Pos(algebra_to_cartesian("b1")).knight_hops("RU"), [[2, 5]])

        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("RD"))
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("RU"))
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("LU"))
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("LD"))
Exemplo n.º 3
0
    def test_diag_LU(self):

        self.assertEquals(Pos(algebra_to_cartesian("a1")).diag("LU", 5), [])
        self.assertEquals(Pos(algebra_to_cartesian("a8")).diag("LU", 5), [])
        """self.assertEquals(
            Pos(algebra_to_cartesian("h1")).diag("LU", 5),
            [[6, 6], [5, 5], [4, 4], [3, 3], [2, 2]],
        )
        """
        print(Pos(algebra_to_cartesian("h8")).diag("LU", 5))
        self.assertEquals(Pos(algebra_to_cartesian("h8")).diag("LU", 5), [])
Exemplo n.º 4
0
    def test_diag_RU(self):

        self.assertEquals(
            Pos(algebra_to_cartesian("a1")).diag("RU", 5),
            [[1, 6], [2, 5], [3, 4], [4, 3], [5, 2]],
        )
        self.assertEquals(Pos(algebra_to_cartesian("a8")).diag("RU", 5), [])

        self.assertEquals(Pos(algebra_to_cartesian("h1")).diag("RU", 5), [])

        self.assertEquals(Pos(algebra_to_cartesian("h8")).diag("RU", 5), [])
Exemplo n.º 5
0
    def test_knight_hops(self):

        # knight_pos = Pos(algebra_to_cartesian("b1"))
        # self.assertEquals((knight_pos).knight_hops("RU"), [])
        self.assertEquals(
            Pos(algebra_to_cartesian("b1")).knight_hops("RU"), [[2, 5]])

        # self.assertEquals(knight_pos).knight_hops("RD", [121])
        # self.assertEquals(knight_pos).knight_hops("LU", [1])
        # self.assertEquals(knight_pos).knight_hops("LD", [1])
        # print(knight_pos.knight_hops())
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("RD"))
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("RU"))
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("LU"))
        print("8888", Pos(algebra_to_cartesian("b1")).knight_hops("LD"))
Exemplo n.º 6
0
 def f2():
     kn = Knight("ddd", 3, "", algebra_to_cartesian("b8"), None)
     for i in range(0, 7):
         for j in range(0, 7):
             kn.newpos.x = i
             kn.newpos.y = j
             kn.validateMove()
     return
Exemplo n.º 7
0
 def __init__(self, coord):
     if isinstance(coord, tuple) or isinstance(coord, list):
         self.x = coord[0]
         self.y = coord[1]
         self.actualx = coord[0]
         self.actualy = coord[1]
     elif isinstance(coord, str):
         # Sorts out algebra to cartesian conversions
         self.x, self.y = algebra_to_cartesian(coord)
         self.actualx = self.x
         self.actualy = self.y
Exemplo n.º 8
0
 def __init__(self, coord):
     if isinstance(coord, tuple) or isinstance(coord, list):
         self.x = coord[0]
         self.y = coord[1]
         self.actualx = coord[0]
         self.actualy = coord[1]
     elif isinstance(coord, str):
         # TODO check that its a valid str
         self.x, self.y = algebra_to_cartesian(coord)
         self.actualx = self.x
         self.actualy = self.y
Exemplo n.º 9
0
 def paintBoard(self, board: Board):
     """ Given any board it will blit the positions 
         Requires the pieces in the board to have specific names so that 
         the png paths can be found
     """
     self.drawEmptyBoard()
     for posstr, piece in board.pieceByPosDict.items():
         print(posstr, piece)
         res = piece.name.split("_")
         print(res)
         pngpath = "_".join([res[0], res[1]])
         displayimg = pygame.image.load("ui\\%s.png" %
                                        (pngpath))  # from piece
         X, Y = algebra_to_cartesian(posstr)
         print((X + 1) * 60, (Y + 1) * 60)
         self.gameDisplay.blit(displayimg, ((X + 1) * 60, (Y + 1) * 60))
Exemplo n.º 10
0
 def test_King(self):
     board = Board()
     Board.populateBoard(board)
     b = King("ddd", algebra_to_cartesian("g1"), board)
Exemplo n.º 11
0
 def test_conversion2(self):
     self.assertEquals(algebra_to_cartesian("h8"), (7, 0))
     self.assertEquals(algebra_to_cartesian("b8"), (1, 0))