Esempio n. 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            #region ゲームの初期化
            DResult.Text      = "";
            PResult.Text      = "";
            checkBox1.Checked = false;
            checkBox2.Checked = false;
            checkBox3.Checked = false;
            checkBox4.Checked = false;
            checkBox5.Checked = false;
            Snow  = 54;
            Stack = gameinit(Stack);
            #endregion
            switch (gamemode)
            {
                #region gamemodo = MODE_ALONE
            case mode.MODE_ALONE:
                //手札配布
                for (int i = 0; i < 5; i++)
                {
                    Snow--;
                    PHands[i] = Stack[Snow];
                }
                break;

                #endregion
                #region gamemode = MODE_VS
            case mode.MODE_VS:
                //プレイヤーとディーラーに手札配布
                for (int i = 0; i < 5; i++)
                {
                    Snow--;
                    PHands[i] = Stack[Snow];
                    DHands[i] = Stack[Snow - 6];
                }
                Snow -= 5;
                break;

                #endregion
            default:
                break;
            }
            //カード表示
            showcard(PHands, PHands1.Location.X, PHands1.Location.Y);
            //役の判定及び表示
            pre              = Judge(PHands);
            pra              = RankJudge(PHands);
            PResult.Text     = pre.ToString() + "(" + pra + ")";
            btnStart.Enabled = false;
            btnDraw.Enabled  = true;
            lblStart.Visible = false;
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            PHands = new int[] { 1, 14, 54, 33, 34 };//作りたい手札

            /*
             * デバックリスト
             * 1,14,27,40,53 =five(A)J
             * 1,14,27,54,53 =five(A)J
             *
             * 1,10,11,12,13 = RStraightFlush(A)
             * 1,10,11,12,53 = RStraightFlush(A)J
             * 1,10,11,54,53 = RStraightFlush(A)JJ
             *
             * 1,2,3,4,5 = straightFlush(5)
             * 1,2,3,4,53 = straightFlush(5)J
             * 1,2,3,54,53 = straightFlush(5)JJ
             *
             * 1,14,27,40,23 = four(A)
             * 1,14,27,53,23 = four(A)J
             * 1,14,54,53,23 = four(A)JJ
             *
             * 1,14,27,2,15 = fullhouse(A)
             * 1,14,54,2,15 = fullhouse(A)J
             *
             * 2,4,6,8,10 = flush(10)
             * 2,4,6,8,53 = flush(A)J
             * 2,8,7,53,54 = flush(A)JJ                 ○
             *
             * 1,15,29,43,5 = straight(5)
             * 1,15,29,43,54 = straight(5)J
             * 1,15,29,53,54 = straight(5)JJ
             *
             * 1,14,27,33,34 = three(A)
             * 1,14,54,33,34 = three(A)J
             * 1,54,53,33,34 = three(A)JJ               ○
             *
             * 1,14,2,15,48 = two(A)                    ○
             *
             * 1,14,2,48,26 = one(A)                    ○
             * 54,1,13,15,17 = one(A)J                  ○
             *
             * 37,34,28,1,6 = high(A)                   ○
             */
            showcard(PHands, PHands1.Location.X, PHands1.Location.Y);
            pre          = Judge(PHands);
            pra          = RankJudge(PHands);
            PResult.Text = pre.ToString() + "(" + pra + ")";
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var input = 7347;

            List <fuel_cell> cells = new List <fuel_cell>();

            for (int i = 1; i <= 300; i++)
            {
                for (int j = 1; j <= 300; j++)
                {
                    fuel_cell cell = new fuel_cell()
                    {
                        x = i,
                        y = j
                    };

                    cell.power_level = cell.get_power_level(input);

                    cells.Add(cell);
                }
            }

            Console.WriteLine("Starting Task 1");
            Task <result> task1 = Task <result> .Factory.StartNew(() =>
            {
                var result = Part1(cells);
                return(result);
            });

            Console.WriteLine("Starting Task 2");
            Task <result> task2 = Task <result> .Factory.StartNew(() =>
            {
                var result = Part2(cells);
                return(result);
            });

            result res_one = task1.Result;

            Console.WriteLine("Part 1");
            Console.WriteLine(res_one.ToString());

            result res_two = task2.Result;

            Console.WriteLine("Part 2");
            Console.WriteLine(res_two.ToString());
        }
Esempio n. 4
0
 private void CRcomon()
 {
     //ディーラーのカード表示
     showcard(DHands, DHands1.Location.X, DHands1.Location.Y);
     //ディーラーの役及び表示
     dre          = Judge(DHands);
     dra          = RankJudge(DHands);
     DResult.Text = dre.ToString() + "(" + dra + ")";
     //勝ち負け判定及びコイン処理
     #region 勝ち負け処理
     if (pre > dre)//役で勝ち
     {
         MessageBox.Show("You win!!\nコイン" + (bet * 2).ToString() + "枚獲得!!");
         coin        += bet * 2;
         lblCoin.Text = coin.ToString() + "枚";
     }
     else if (pre < dre)//役で負け
     {
         MessageBox.Show("You lose...\nコイン" + bet.ToString() + "枚失った...");
     }
     else//役は引き分け
     {
         if (Ranktoint(pra) > Ranktoint(dra))//数字で勝ち
         {
             MessageBox.Show("You win!!\nコイン" + (bet * 2).ToString() + "枚獲得!!");
             coin        += bet * 2;
             lblCoin.Text = coin.ToString() + "枚";
         }
         else if (Ranktoint(pra) < Ranktoint(dra))//数字で負け
         {
             MessageBox.Show("You lose...\nコイン" + bet.ToString() + "枚失った...");
         }
         else//数字でも引き分け
         {
             MessageBox.Show("Draw\n賭けた分のコイン" + bet.ToString() + "枚獲得");
             coin        += bet;
             lblCoin.Text = coin.ToString() + "枚";
         }
     }
     #endregion
     //終了処理
     bet                    = 0;
     btnCall.Enabled        = false;
     btnRaise.Enabled       = false;
     numericUpDown1.Enabled = true;
     btnBet.Enabled         = true;
     lblBet.Text            = "ベッティングタイム";
     label7.Text            = "現在" + bet.ToString() + "枚\n賭けられています";
     numericUpDown1.Maximum = coin;
     lblCoin.Text           = coin.ToString() + "枚";
     PHands1.BringToFront();
     PHands2.BringToFront();
     PHands3.BringToFront();
     PHands4.BringToFront();
     PHands5.BringToFront();
     DHands1.BringToFront();
     DHands2.BringToFront();
     DHands3.BringToFront();
     DHands4.BringToFront();
     DHands5.BringToFront();
     PResult.Text = "";
     DResult.Text = "";
 }
Esempio n. 5
0
        private void btnDraw_Click(object sender, EventArgs e)
        {
            #region 共通する初期処理
            //手札交換
            for (int i = 0; i < 5; i++)
            {
                if (!PHolds[i])
                {
                    Snow--;
                    PHands[i] = Stack[Snow];
                }
            }
            lblStackCount.Text = "残り" + Snow.ToString() + "枚";
            //カード表示
            showcard(PHands, PHands1.Location.X, PHands1.Location.Y);
            //役の判定及び表示
            pre          = Judge(PHands);
            pra          = RankJudge(PHands);
            PResult.Text = pre.ToString() + "(" + pra + ")";
            #endregion
            switch (gamemode)
            {
                #region gamemodo = MODE_ALONE
            case mode.MODE_ALONE:
                //コインの配布
                MessageBox.Show("コイン" + (((int)Judge(PHands) + 1) * 10).ToString() + "枚獲得!!");
                coin        += ((int)Judge(PHands) + 1) * 10;
                lblCoin.Text = coin.ToString() + "枚";
                //終了処理
                btnStart.Enabled = true;
                PHands1.BringToFront();
                PHands2.BringToFront();
                PHands3.BringToFront();
                PHands4.BringToFront();
                PHands5.BringToFront();
                PResult.Text = "";
                break;

                #endregion
                #region gamemode = MODE_VS
            case mode.MODE_VS:
                //DEALER交換
                for (int i = 0; i < 5; i++)
                {
                    DHolds[i] = false;
                }
                for (int i = 0; i < 5; i++)
                {
                    if (DHands[i] == 53 || DHands[i] == 54)
                    {
                        DHolds[i] = true;    //JOKERは交換しない
                    }
                }
                switch (Judge(PHands))    //交換するものを判定
                {
                case result.HighCards:    //もっと考えた行動を目標に

                    break;

                case result.OnePair:
                case result.TwoPair:
                case result.ThereeCard:
                case result.FourCard:
                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = i + 1; j < 5; j++)
                        {
                            if (getsuit(DHands[i]) != suit.SUIT_JOKER || getsuit(DHands[j]) != suit.SUIT_JOKER)
                            {
                                if (getrank(DHands[i], 0) == getrank(DHands[j], 0))
                                {
                                    DHolds[i] = true;
                                    DHolds[j] = true;
                                }
                            }
                        }
                    }
                    for (int i = 0; i < 5; i++)
                    {
                        if (DHolds[i] == false)
                        {
                            Snow--;
                            DHands[i] = Stack[Snow];
                        }
                    }
                    break;

                default:
                    for (int i = 0; i < 5; i++)
                    {
                        DHolds[i] = true;
                    }
                    break;
                }
                //終了処理
                lblStackCount.Text = "残り" + Snow.ToString() + "枚";
                btnCall.Enabled    = true;
                btnRaise.Enabled   = true;
                break;

                #endregion
            default:
                break;
            }
            #region 共通する終了処理
            btnDraw.Enabled = false;
            lblDraw.Visible = false;
            #endregion
        }