当前位置: 首页>>代码示例>>Python>>正文


Python callhistory.CallHistory类代码示例

本文整理汇总了Python中core.callhistory.CallHistory的典型用法代码示例。如果您正苦于以下问题:Python CallHistory类的具体用法?Python CallHistory怎么用?Python CallHistory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CallHistory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bidding_rounds

 def test_bidding_rounds(self):
     self.assertEquals(CallHistory.from_string("")._bidding_rounds_count(), 0)
     self.assertEquals(CallHistory.from_string("").bidding_rounds(last_call_only=True), [['?', None, None, None]])
     self.assertEquals(CallHistory.from_string("").bidding_rounds(last_call_only=True, mark_to_bid=False), [])
     self.assertEquals(CallHistory.from_string("P").bidding_rounds(last_call_only=True), [['P', '?', None, None]])
     self.assertEquals(CallHistory.from_string("P P").bidding_rounds(last_call_only=True), [['P', 'P', '?', None]])
     self.assertEquals(CallHistory.from_string("P P", dealer_string="E").bidding_rounds(last_call_only=True), [[None, 'P', 'P', '?']])
     self.assertEquals(CallHistory.from_string("P P", dealer_string="W").bidding_rounds(last_call_only=True), [[None, None, None, 'P'], ['P', '?', None, None]])
     self.assertEquals(CallHistory.from_string("2H P 3H P").bidding_rounds(last_call_only=True), [['2H', 'P', '3H', 'P'], ['?', None, None, None]])
     self.assertEquals(CallHistory.from_string("P P P P").bidding_rounds(last_call_only=True), [['P', 'P', 'P', 'P']])
     self.assertEquals(CallHistory.from_string("P P P P", dealer_string="E").bidding_rounds(last_call_only=True), [[None, 'P', 'P', 'P'], ['P', None, None, None]])
开发者ID:samfin,项目名称:saycbridge,代码行数:11,代码来源:test_callhistory.py

示例2: test_from_identifier

 def test_from_identifier(self):
     self.assertEqual(CallHistory.from_identifier('E:EW:P').identifier(), CallHistory.from_string('P', 'E', 'E-W').identifier())
     # Test that from_identifier is forgiving of a missing trailing colon
     self.assertEqual(CallHistory.from_identifier('E:EW:').identifier(), CallHistory.from_string('', 'E', 'E-W').identifier())
     self.assertEqual(CallHistory.from_identifier('E:EW').identifier(), CallHistory.from_string('', 'E', 'E-W').identifier())
     # Test that from_identifier is forgiving of a trailing comma.
     self.assertEqual(CallHistory.from_identifier('N:NO:P,').calls_string(), "P")
开发者ID:samfin,项目名称:saycbridge,代码行数:7,代码来源:test_callhistory.py

示例3: from_expectation_tuple_in_group

 def from_expectation_tuple_in_group(cls, expectation, test_group):
     hand_string = expectation[0]
     assert '.' in hand_string, "_split_expectation expectes C.D.H.S formatted hands, missing '.': %s" % hand_string
     expected_call = Call.from_string(expectation[1])
     history_string = expectation[2] if len(expectation) > 2 else ""
     vulnerability_string = expectation[3] if len(expectation) > 3 else None
     hand = Hand.from_cdhs_string(hand_string)
     call_history = CallHistory.from_string(history_string, vulnerability_string=vulnerability_string)
     return cls(test_group, hand, call_history, expected_call)
开发者ID:abortz,项目名称:saycbridge,代码行数:9,代码来源:harness.py

示例4: from_identifier

    def from_identifier(self, identifier):
        components = identifier.split("-")
        if len(components) == 2:
            (board_number_string, deal_and_history_identifier) = components
            if ':' in deal_and_history_identifier:
                deal_identifier, call_history_identifier = deal_and_history_identifier.split(':')
                # We have to do a bit of a dance to convert from the board url system that
                # the JS code uses to the one the python uses.
                call_history = CallHistory.from_board_number_and_calls_string(int(board_number_string), call_history_identifier)
            else:
                deal_identifier = deal_and_history_identifier
                call_history = CallHistory.empty_for_board_number(int(board_number_string))
        else:
            (board_number_string, deal_identifier, call_history_identifier) = components
            call_history = CallHistory.from_identifier(call_history_identifier)

        board_number = int(board_number_string)
        deal = Deal.from_identifier(deal_identifier)
        return Board(number=board_number, deal=deal, call_history=call_history)
开发者ID:pdm55,项目名称:saycbridge,代码行数:19,代码来源:board.py

示例5: test_copy_with_partial_history

 def test_copy_with_partial_history(self):
     history = CallHistory.from_string("P P 1N P P P")
     self.assertEquals(len(history.calls), 6)
     self.assertEquals(len(history.copy_with_partial_history(0).calls), 0)
     self.assertEquals(len(history.copy_with_partial_history(2).calls), 2)
     self.assertEquals(len(history.copy_with_partial_history(-2).calls), 4)
     partial_history = history.copy_with_partial_history(3)
     self.assertEquals(len(history.calls), 6)
     self.assertEquals(len(partial_history.calls), 3)
     partial_history.calls.append(None)  # Invalid, but fine for testing.
     self.assertEquals(len(history.calls), 6)
     self.assertEquals(len(partial_history.calls), 4)
开发者ID:samfin,项目名称:saycbridge,代码行数:12,代码来源:test_callhistory.py

示例6: test_last_to_call

 def test_last_to_call(self):
     self.assertEquals(CallHistory.from_string("").last_to_call(), None)
     self.assertEquals(CallHistory.from_string("P").last_to_call(), NORTH)
     self.assertEquals(CallHistory.from_string("1N P").last_to_call(), EAST)
     self.assertEquals(CallHistory.from_string("1N P 2C").last_to_call(), SOUTH)
     self.assertEquals(CallHistory.from_string("1N P 2C P").last_to_call(), WEST)
     self.assertEquals(CallHistory.from_string("1N P 2C P 2D").last_to_call(), NORTH)
开发者ID:samfin,项目名称:saycbridge,代码行数:7,代码来源:test_callhistory.py

示例7: test_is_passout

 def test_is_passout(self):
     self.assertEquals(CallHistory.from_string("").is_passout(), False)
     self.assertEquals(CallHistory.from_string("P").is_passout(), False)
     self.assertEquals(CallHistory.from_string("P P").is_passout(), False)
     self.assertEquals(CallHistory.from_string("P P P").is_passout(), False)
     self.assertEquals(CallHistory.from_string("P P P P").is_passout(), True)
     self.assertEquals(CallHistory.from_string("P 1N P P P").is_passout(), False)
开发者ID:samfin,项目名称:saycbridge,代码行数:7,代码来源:test_callhistory.py

示例8: _board_from_request

    def _board_from_request(self):
        board_number = int(self.request.get('number'))
        vulnerability_string = self.request.get('vunerability')
        hand_strings = map(str, [
            self.request.get('deal[north]'),
            self.request.get('deal[east]'),
            self.request.get('deal[south]'),
            self.request.get('deal[west]'),
        ])

        deal = Deal.from_string(' '.join(hand_strings))
        dealer_char = self.request.get('dealer')
        calls_string = self.request.get('calls_string', '')
        history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)
        return Board(board_number, deal, history)
开发者ID:abortz,项目名称:saycbridge,代码行数:15,代码来源:autobid_handler.py

示例9: _board_from_request

    def _board_from_request(self):
        board_number = int(self.request.get('number'))
        vulnerability_string = self.request.get('vunerability')
        hand_strings = map(str, [
            self.request.get('deal[north]'),
            self.request.get('deal[east]'),
            self.request.get('deal[south]'),
            self.request.get('deal[west]'),
        ])

        deal = Deal.from_string(' '.join(hand_strings))
        dealer_char = self.request.get('dealer')
        # Note: We keep bids_string around to I can test old requests.
        calls_string = self.request.get('calls_string') or self.request.get('bids_string') or ''
        history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)
        return Board(board_number, deal, history)
开发者ID:samfin,项目名称:saycbridge,代码行数:16,代码来源:bidder_handler.py

示例10: _board_from_request

    def _board_from_request(self):
        board_number = int(self.request.get("number"))
        vulnerability_string = self.request.get("vunerability")
        hand_strings = map(
            str,
            [
                self.request.get("deal[north]"),
                self.request.get("deal[east]"),
                self.request.get("deal[south]"),
                self.request.get("deal[west]"),
            ],
        )

        deal = Deal.from_string(" ".join(hand_strings))
        dealer_char = self.request.get("dealer")
        # Note: We keep bids_string around to I can test old requests.
        calls_string = self.request.get("calls_string") or self.request.get("bids_string") or ""
        history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)
        return Board(board_number, deal, history)
开发者ID:pdm55,项目名称:saycbridge,代码行数:19,代码来源:bidder_handler.py

示例11: get

    def get(self):
        interpreter = InterpreterProxy()
        calls_string = self.request.get('calls_string') or ''
        dealer_char = self.request.get('dealer') or ''
        vulnerability_string = self.request.get('vulnerability') or ''
        call_history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)

        knowledge_string, rule = interpreter.knowledge_string_and_rule_for_last_call(call_history)
        explore_dict = {
            'knowledge_string': knowledge_string,
        }
        explore_dict.update(self._json_from_rule(rule, call_history.calls[-1]))
        self.response.headers["Content-Type"] = "application/json"
        self.response.headers["Cache-Control"] = "public"

        expires_date = datetime.datetime.utcnow() + datetime.timedelta(days=1)
        expires_str = expires_date.strftime("%d %b %Y %H:%M:%S GMT")
        self.response.headers.add_header("Expires", expires_str)

        self.response.out.write(json.dumps(explore_dict))
开发者ID:samfin,项目名称:saycbridge,代码行数:20,代码来源:explore_handler.py

示例12: get

    def get(self):
        interpreter = BidInterpreter()
        calls_string = self.request.get('calls_string') or ''
        dealer_char = self.request.get('dealer') or ''
        vulnerability_string = self.request.get('vulnerability') or ''
        history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)

        existing_knowledge, knowledge_builder = interpreter.knowledge_from_history(history)
        matched_rules = knowledge_builder.matched_rules()
        explore_dict = {
            'knowledge_string': existing_knowledge.rho.pretty_one_line(include_last_call_name=False) if existing_knowledge else None,
        }
        explore_dict.update(self._json_from_rule(matched_rules[-1], history.calls[-1]))
        self.response.headers["Content-Type"] = "application/json"
        self.response.headers["Cache-Control"] = "public"

        expires_date = datetime.datetime.utcnow() + datetime.timedelta(days=1)
        expires_str = expires_date.strftime("%d %b %Y %H:%M:%S GMT")
        self.response.headers.add_header("Expires", expires_str)

        self.response.out.write(json.dumps(explore_dict))
开发者ID:pdm55,项目名称:saycbridge,代码行数:21,代码来源:explore_handler.py

示例13: _rule_for_last_call

 def _rule_for_last_call(self, call_history_string):
     history = CallHistory.from_string(call_history_string)
     knowledge, knowledge_builder = self.interpreter.knowledge_from_history(history)
     matched_rules = knowledge_builder.matched_rules()
     return matched_rules[-1]
开发者ID:samfin,项目名称:saycbridge,代码行数:5,代码来源:interpreter_unittest.py

示例14: _hand_knowledge_from_last_call

 def _hand_knowledge_from_last_call(self, call_history_string):
     history = CallHistory.from_string(call_history_string)
     knowledge, _ = self.interpreter.knowledge_from_history(history)
     return knowledge.rho
开发者ID:samfin,项目名称:saycbridge,代码行数:4,代码来源:interpreter_unittest.py

示例15: _assert_point_range

 def _assert_point_range(self, call_history_string, expected_point_range):
     history = CallHistory.from_string(call_history_string)
     knowledge, matched_rules = self.interpreter.knowledge_from_history(history)
     # We use rho() instead of me() because knowledge_from_history auto-rotates the Knowledge.
     self.assertEqual(knowledge.rho.hcp_range_tuple(), expected_point_range)
开发者ID:samfin,项目名称:saycbridge,代码行数:5,代码来源:interpreter_unittest.py


注:本文中的core.callhistory.CallHistory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。