示例#1
0
    def play_engine_move_and_get_speech(self, session_id: str) -> str:
        """Play engine's move and return the speech conversion of the move"""

        if not self.engine:
            self.activate_engine()

        user = get_user(session_id)

        # Doesn't actually play the move
        result = self.engine.play(user.board, chess.engine.Limit(time=0.100))

        # Store LAN notation and push
        lan = user.board.lan(result.move)
        user.board.push(result.move)

        # Update DB
        update_user(session_id, user.board)

        return lan_to_speech(lan)
示例#2
0
    def test_lan_to_speech_pawn_capture_check(self):

        lan = "e6xd7+"
        expected = "Pawn from e6 captures d7 check"

        assert lan_to_speech(lan) == expected
示例#3
0
    def test_lan_to_speech_pawn_capture(self):

        lan = "e4xd5"
        expected = "Pawn from e4 captures d5"

        assert lan_to_speech(lan) == expected
示例#4
0
    def test_lan_to_speech_pawn_move_check(self):

        lan = "e4-e5+"
        expected = "Pawn from e4 to e5 check"

        assert lan_to_speech(lan) == expected
示例#5
0
    def test_lan_to_speech_pawn_move(self):

        lan = "e2-e4"
        expected = "Pawn from e2 to e4"

        assert lan_to_speech(lan) == expected
示例#6
0
    def test_lan_to_speech_promotion_capture_bishop(self):

        lan = "a2xb1=B"
        expected = "Pawn from a2 captures b1 Bishop"

        assert lan_to_speech(lan) == expected
示例#7
0
    def test_lan_to_speech_promotion_capture_knight_check(self):

        lan = "b2xc1=N+"
        expected = "Pawn from b2 captures c1 Knight check"

        assert lan_to_speech(lan) == expected
示例#8
0
    def test_lan_to_speech_piece_capture(self):

        lan = "Rh1xh8"
        expected = "Rook from h1 captures h8"

        assert lan_to_speech(lan) == expected
示例#9
0
    def test_lan_to_speech_promotion_move_queen(self):

        lan = "a7-a8=Q"
        expected = "Pawn from a7 to a8 Queen"

        assert lan_to_speech(lan) == expected
示例#10
0
    def test_lan_to_speech_long_castle_checkmate(self):

        lan = "O-O-O#"
        expected = "Long castle check"

        assert lan_to_speech(lan) == expected
示例#11
0
    def test_lan_to_speech_long_castle(self):

        lan = "O-O-O"
        expected = "Long castle"

        assert lan_to_speech(lan) == expected
示例#12
0
    def test_lan_to_speech_short_castle_check(self):

        lan = "O-O+"
        expected = "Short castle check"

        assert lan_to_speech(lan) == expected
示例#13
0
    def test_lan_to_speech_short_castle(self):

        lan = "O-O"
        expected = "Short castle"

        assert lan_to_speech(lan) == expected
示例#14
0
    def test_lan_to_speech_piece_move_checkmate(self):

        lan = "Ke6-d6#"
        expected = "King from e6 to d6 check"

        assert lan_to_speech(lan) == expected
示例#15
0
    def test_lan_to_speech_piece_capture_check(self):

        lan = "Qd1xa4+"
        expected = "Queen from d1 captures a4 check"

        assert lan_to_speech(lan) == expected
示例#16
0
    def test_lan_to_speech_piece_move(self):

        lan = "Ng1-f3"
        expected = "Knight from g1 to f3"

        assert lan_to_speech(lan) == expected
示例#17
0
    def test_lan_to_speech_piece_move_check(self):

        lan = "Bf1-c4+"
        expected = "Bishop from f1 to c4 check"

        assert lan_to_speech(lan) == expected
示例#18
0
    def test_lan_to_speech_pawn_promotion_move_rook_check(self):

        lan = "d7-d8=R+"
        expected = "Pawn from d7 to d8 Rook check"

        assert lan_to_speech(lan) == expected