Esempio n. 1
0
    /// <summary>
    /// 和牌算法效率测试
    /// </summary>
    private void EfficiencyTest()
    {
        long before  = TimeUtil.GetTimestampMS();
        int  huTimes = 0;

        for (int i = 0; i < 100000; ++i)
        {
            List <Poker> lst = new List <Poker>();
            for (int j = 0; j < 13; ++j)
            {
                int color = UnityEngine.Random.Range(1, 6);
                int size  = color > 3 ? UnityEngine.Random.Range(1, 4) : UnityEngine.Random.Range(1, 10);
                lst.Add(new Poker(0, color, size));
            }
            List <List <CardCombination> > result = MahJongHelper.CheckTing(lst, new List <Poker>()
            {
                new Poker(0, 5, 1)
            }, true, true, true);
            if (result != null && result.Count > 0)
            {
                ++huTimes;
            }
        }
        long after = TimeUtil.GetTimestampMS();

        Debug.Log("计算之前时间戳=" + before);
        Debug.Log("计算之后时间戳=" + after);
        Debug.Log("计算所需时间=" + (after - before) + "毫秒");
        Debug.Log("胡了" + huTimes + "次");
    }