Beispiel #1
0
        /// <summary>
        /// 默认2倍,闪光为3倍
        /// 我压中的概率是三分之一
        /// </summary>
        /// <param name="selectInd_"></param>
        /// <param name="fen"></param>
        /// <returns></returns>
        public string[] pick_a_card(int selectInd_, Int64 jiaoFen)
        {
            //winOrLost,fen,machine_pick,your_pick,light
            //string[] pickResult = { "0", "0", "0" };
            _pickResult = new string[] { "0", "0", "0", "0", "0" };

            //
            Random r = new Random(RandomUtil.GetRandSeed());

            int machine_pick = r.Next(3);

            machine_pick++;

            int light = r.Next(2);

            //
            _pickResult[2] = machine_pick.ToString();
            _pickResult[3] = selectInd_.ToString();
            _pickResult[4] = light.ToString();

            //
            if (selectInd_ == machine_pick)
            {
                _pickResult[0] = "1";

                //获得的分值 = 押分;
                if (0 == light)
                {
                    _pickResult[1] = (jiaoFen * 1).ToString();
                }
                else
                {
                    _pickResult[1] = (jiaoFen * 2).ToString();
                }
            }
            else
            {
                _pickResult[0] = "0";

                //扣掉的分值 = 押分 * 1
                _pickResult[1] = (jiaoFen * 1).ToString();
            }

            return(_pickResult);
        }
        /// <summary>
        /// 洗牌前必须先reset
        /// </summary>
        public void xipai()
        {
            //
            reset();

            //
            int i   = 0;
            int len = 0;
            int n   = 0;

            //clone pai name
            List <string> p = PAI_NAME.GetList();

            //第一次发17张牌
            len = 17;

            //提高随机数不重复概率的种子生成方法:

            //Millisecond 取值范围是 0 - 999
            //DateTime.Now.Ticks是指从1970年1月1日(具体哪年忘了哈,好像是1970)开始到目前所经过的毫秒数——刻度数。

            //54张牌的组合是 54!
            //是一个非常大的数,结果是: 2.3e + 71
            //因此我们的seed的取值范围也应该非常大,也就是0到上面的结果,
            //Millisecond小了,导致只会出现999种牌的组合
            //guid方法不可取,每回都是一样的

            //直接以Random做为随机数生成器因为时钟精度问题,
            //在一个小的时间段内会得到同样的伪随机数序列,
            //你shuffle后会得到同一个结果。
            //.net提供了RNGCryptoServiceProvider可以避免这种情况

            //GetRandSeed后的取值范围是 0 - int32.MaxValue,虽然还差很远,但是999要好很多
            Random r = new Random(RandomUtil.GetRandSeed());


            for (i = 0; i < len; i++)
            {
                n = r.Next(p.Count);

                grid[0, i] = p[n];

                p.RemoveAt(n);
            }


            //test

            /*
             * grid[0, 0] = PokerName.X_J; p.Remove(PokerName.X_J);
             *
             * grid[0, 1] = PokerName.F_A; p.Remove(PokerName.F_A);
             * grid[0, 2] = PokerName.X_A; p.Remove(PokerName.X_A);
             * grid[0, 3] = PokerName.T_A; p.Remove(PokerName.T_A);
             * grid[0, 4] = PokerName.T_K; p.Remove(PokerName.T_K);
             *
             * grid[0, 5] = PokerName.F_K; p.Remove(PokerName.F_K);
             * grid[0, 6] = PokerName.M_K; p.Remove(PokerName.M_K);
             * grid[0, 7] = PokerName.T_8; p.Remove(PokerName.T_8);
             * grid[0, 8] = PokerName.X_8; p.Remove(PokerName.X_8);
             *
             * grid[0, 9] = PokerName.X_3; p.Remove(PokerName.X_3);
             * grid[0, 10] = PokerName.T_3; p.Remove(PokerName.T_3);
             * grid[0, 11] = PokerName.X_2; p.Remove(PokerName.X_2);
             * grid[0, 12] = PokerName.X_4; p.Remove(PokerName.X_4);
             *
             * grid[0, 13] = PokerName.X_5; p.Remove(PokerName.X_5);
             * grid[0, 14] = PokerName.X_6; p.Remove(PokerName.X_6);
             * grid[0, 15] = PokerName.X_10; p.Remove(PokerName.X_10);
             * grid[0, 16] = PokerName.T_10; p.Remove(PokerName.T_10);
             */



            for (i = 0; i < len; i++)
            {
                n = r.Next(p.Count);

                grid[1, i] = p[n];

                p.RemoveAt(n);
            }


            //test

            /*
             * grid[1, 0] = PokerName.M_J; p.Remove(PokerName.M_J);
             *
             * grid[1, 1] = PokerName.F_4; p.Remove(PokerName.F_4);
             * grid[1, 2] = PokerName.X_4; p.Remove(PokerName.X_4);
             * grid[1, 3] = PokerName.T_4; p.Remove(PokerName.T_4);
             * grid[1, 4] = PokerName.T_5; p.Remove(PokerName.T_5);
             *
             * grid[1, 5] = PokerName.F_5; p.Remove(PokerName.F_5);
             * grid[1, 6] = PokerName.M_5; p.Remove(PokerName.M_5);
             * grid[1, 7] = PokerName.T_Q; p.Remove(PokerName.T_Q);
             * grid[1, 8] = PokerName.X_Q; p.Remove(PokerName.X_Q);
             *
             * grid[1, 9] = PokerName.X_K; p.Remove(PokerName.X_K);
             * grid[1, 10] = PokerName.M_K; p.Remove(PokerName.M_K);
             * grid[1, 11] = PokerName.M_2; p.Remove(PokerName.M_2);
             * grid[1, 12] = PokerName.M_4; p.Remove(PokerName.M_4);
             *
             * grid[1, 13] = PokerName.X_5; p.Remove(PokerName.X_5);
             * grid[1, 14] = PokerName.X_6; p.Remove(PokerName.X_6);
             * grid[1, 15] = PokerName.X_J; p.Remove(PokerName.X_J);
             * grid[1, 16] = PokerName.T_10; p.Remove(PokerName.T_10);
             */


            for (i = 0; i < len; i++)
            {
                n = r.Next(p.Count);

                grid[2, i] = p[n];

                p.RemoveAt(n);
            }//end for


            //底牌
            grid2[0] = p[0];
            grid2[1] = p[1];
            grid2[2] = p[2];

            //distory
            p.Clear();
        }