コード例 #1
0
ファイル: test.py プロジェクト: ban11111/Algorithm_exercise
    def test_7_with_ghost(self):
        ghost = list()
        ghost.append({
            "alice": "XnAsKsQsJsTs9s",
            "bob": "Xn7hKh3hQhJhTh",
            "result": 0
        })
        ghost.append({
            "alice": "9sTcKh7h2dXn8s",
            "bob": "Qh9sTcKhXn6h5s",
            "result": 2
        })
        ghost.append({
            "alice": "As5d4h3h5sXn2s",
            "bob": "9c5hAsXn4d2s5d",
            "result": 1
        })
        ghost.append({
            "alice": "4c5hXn7h9h6d8s",
            "bob": "4h5s8c7h9h6sXn",
            "result": 0
        })
        ghost.append({
            "alice": "3hAs4dKh8h6hXn",
            "bob": "6dAsTdXn4d7h9s",
            "result": 1
        })
        ghost.append({
            "alice": "3hAs4dKh8h6hXn",
            "bob": "6dAsTdXn4d7hKs",
            "result": 1
        })
        ghost.append({
            "alice": "3hAs4dKh8d6hXn",
            "bob": "6dAsTdXn4d7hKs",
            "result": 2
        })
        ghost.append({
            "alice": "ThAs4dKh8d6hXn",
            "bob": "6dAsTdXn4d8hKs",
            "result": 0
        })
        ghost.append({
            "alice": "Ad5d2cXn2d5s3s",
            "bob": "2c4d2dXn5d5s7h",
            "result": 0
        })
        ghost.append({
            "alice": "Ad5d2cXn2d5s3s",
            "bob": "2c4d2dXn5d2s7h",
            "result": 2
        })

        for i in ghost:
            self.assertEqual(i["result"], cmp.compare_quick(i),
                             "alice: " + i["alice"] + "  bob: " + i["bob"])
コード例 #2
0
ファイル: test.py プロジェクト: ban11111/Algorithm_exercise
    def test_5_no_ghost(self):
        ghost = list()
        ghost.append({"alice": "AsKsQsJsTs", "bob": "AsKsQsJs2s", "result": 1})
        ghost.append({"alice": "9sTcKh4d7h", "bob": "Qh9sTcKh4d", "result": 2})
        ghost.append({"alice": "As5d4h3h2d", "bob": "5cJhAsQdKh", "result": 1})
        ghost.append({"alice": "4c5h3s7h9h", "bob": "4h5h3s7h9h", "result": 0})
        ghost.append({"alice": "3h5h4dKh8h", "bob": "6d7dTd5h4d", "result": 1})
        ghost.append({"alice": "Ad5d8d2c2d", "bob": "2c4d2d9h4s", "result": 2})

        for i in ghost:
            self.assertEqual(i["result"], cmp.compare_quick(i),
                             "alice: " + i["alice"] + "  bob: " + i["bob"])
コード例 #3
0
ファイル: test.py プロジェクト: ban11111/Algorithm_exercise
    def test_5_with_ghost(self):
        ghost = list()
        ghost.append({
            "alice": "AsKsXnJsTs",
            "bob": "XnKsQsJsTs",
            "result": 0
        })  # 这种情况在json的牌型里没有, 标记一下
        ghost.append({"alice": "9sTcKhXn7h", "bob": "Qh9sTcKhXn", "result": 2})
        ghost.append({"alice": "As5d4h3hXn", "bob": "5cJhAsQdXn", "result": 1})
        ghost.append({"alice": "4c5hXn7h9h", "bob": "4h5sXn7h9h", "result": 0})
        ghost.append({"alice": "3hXn4dKh8h", "bob": "6dXnTd5h4d", "result": 1})
        ghost.append({"alice": "Ad5dXn2c2d", "bob": "2c4d2dXn4s", "result": 2})

        for i in ghost:
            self.assertEqual(i["result"], cmp.compare_quick(i),
                             "alice: " + i["alice"] + "  bob: " + i["bob"])
コード例 #4
0
ファイル: test.py プロジェクト: ban11111/Algorithm_exercise
    def test_everything(self):
        ghost = list()
        ghost.append({
            "alice": "XnAsKsQsJsTs9s3s4s",
            "bob": "Xn7hQhJhTh",
            "result": 1
        })
        ghost.append({
            "alice": "XnAsKsQsJsTs9s3s4s",
            "bob": "Xn7hQhJhThKh",
            "result": 0
        })

        for i in ghost:
            self.assertEqual(i["result"], cmp.compare_quick(i),
                             "alice: " + i["alice"] + "  bob: " + i["bob"])
コード例 #5
0
ファイル: Poker.py プロジェクト: ban11111/Algorithm_exercise
def poker_quick(file_in, file_out):
    start = time.clock()  # 开始时间

    data = pt.file2json(pt.path + file_in)
    match = data["matches"]
    flag = 1

    for i in match:
        try:
            result = cmp.compare_quick(i)
        except Exception as e:
            logging.error("第%s行出错, err: %s" % (flag, e))
        else:
            i["result"] = result
        flag += 1

    end = time.clock()  # 结束时间

    print("%f秒" % (end - start))
    pt.json2file(data, pt.my_path + file_out)
コード例 #6
0
ファイル: test.py プロジェクト: ban11111/Algorithm_exercise
    def test_7_no_ghost(self):
        ghost = list()
        ghost.append({
            "alice": "2sAsKsQsJsTs9s",
            "bob": "Ah7hKh3hQhJhTh",
            "result": 0
        })
        ghost.append({
            "alice": "9sTcKh7h2d3d8s",
            "bob": "Qh9sTcKh7s6h5s",
            "result": 2
        })
        ghost.append({
            "alice": "As5d4h3h5s5h2s",
            "bob": "5c5hAsQdKh2s5d",
            "result": 1
        })
        ghost.append({
            "alice": "4c5h3s7h9h6d8s",
            "bob": "4h5s8c7h9h6s3s",
            "result": 0
        })
        ghost.append({
            "alice": "3hAs4dKh8h6h5s",
            "bob": "6dAsTd5h4d7h9s",
            "result": 1
        })
        ghost.append({
            "alice": "Ad5d2c3d2d5s3s",
            "bob": "2c4d2d4s5d5s7h",
            "result": 2
        })

        for i in ghost:
            self.assertEqual(i["result"], cmp.compare_quick(i),
                             "alice: " + i["alice"] + "  bob: " + i["bob"])