예제 #1
0
 public static void Shuffle(Pukes pukes)
 {
     for (int i = 0; i < pukes.pukes.Length - 1; ++i)
     {
         int randomIndex = Random.Range(0, pukes.pukes.Length - i);
         pukes.Draw(randomIndex, pukes.pukes.Length - i - 1);
     }
 }
예제 #2
0
 public static void Shuffle(Pukes pukes)
 {
     for (int i = 0; i < pukes.pukes.Length; ++i)
     {
         int randomIndex = Random.Range(0, pukes.pukes.Length);
         pukes.Swap(i, randomIndex);
     }
 }
 public static void Shuffle(Pukes pukes)
 {
     for (int i = pukes.pukes.Length - 1; i >= 0; --i)
     {
         int randomIndex = Random.Range(0, i + 1);
         pukes.Swap(i, randomIndex);
     }
 }
예제 #4
0
        public static void Shuffle(Pukes pukes)
        {
            int len = pukes.pukes.Length;

            for (int i = 0; i < len; ++i)
            {
                int randomIndex = Random.Range(0, i + 1);
                pukes.Swap(i, randomIndex);
            }
        }
예제 #5
0
        public static void Shuffle(Pukes pukes)
        {
            //取两个列表,一个是洗牌前的序列A{ 1,2….54),一个用来放洗牌后的序列B,B初始为空
            //while A不为空
            //  随机从A取一张牌加入B末尾

            List <int> list    = new List <int>(pukes.pukes);
            List <int> newlist = new List <int>(list.Count);

            for (int i = 0; i < pukes.pukes.Length; ++i)
            {
                int randomIndex = Random.Range(0, list.Count);
                int r           = list[randomIndex];
                newlist.Add(r);
                list.RemoveAt(randomIndex);
            }
            pukes.ResetPuke(newlist.ToArray());
        }