如何为我的播放机与计算机骰子游戏正确设置这些确定规则?

我必须建立一个玩家对电脑骰子游戏,每个游戏由3个骰子组成,掷骰将确定哪个“玩家”赢得了本轮比赛。我要努力有效地输入一些决定因素(规则)。

  • 三元组是当所有骰子都具有相同的数字时,三元组的值是它们的共同值。 (我知道的是[[d1 == d2)&&(d1 == d3))
  • 对是指两个骰子具有相同的数字时,对的值是公共值。 (类似于三倍,但相信||)
  • 垃圾不是三重或配对的东西。
  • 任何三人组都击败任何一对。
  • 任何Triple击败任何垃圾。
  • 两个三元组通过各自的值进行比较。
  • 任何一对都跳动和垃圾。
  • 首先对两个对进行比较,然后再根据它们各自的非常规管芯值进行比较。

如果是几个决定,我不会有任何问题,但是由于我们需要所有这些条件来检查每个滚动循环,而我被告知只能使用主类,所以我有点迷失

我相信我已经正确设置了整个程序从确定出发,并且可以每次滚动,计数器工作等获得值。问题在于将确定规则输入到游戏中。我对完成所有其他工作充满信心。

这是我的侧倾和确定区域的DO-WHILE循环。如您所见,我在如何管理和输入确定方面苦苦挣扎。 我得到的基本想法是3!导致6种组合的情况,但我不了解如何正确比较播放器和计算机的值。 在课堂上给了我小费... -数学库 -int d1,d2,d3;

  • int big = Math.max(Math.max(d1,d2),d3)
  • int small = Math.min(Math.min(d1,d2),d3)
  • int medium =(d1 + d2 + d3)-(b + s)

这是检查骰子上的值。我了解这是如何工作的,但是我对于如何将这两个具有3个骰子并将这些整数变量与确定规则一起使用的播放器和计算机的工作方式弄不清楚了。

do
        {   
            System.out.println();
            System.out.println("Do you wish to play again? [y,n]");
            answer = stdIn.next();

            if (answer.equalsIgnoreCase("y")) 
            {
                turnCounter++;

                System.out.println("Player");
                System.out.println("------");
                int d1 = (int)(Math.random() * 6) + 1;
                int d2 = (int)(Math.random() * 6) + 1;
                int d3 = (int)(Math.random() * 6) + 1;
                System.out.println("Roll: " + "\t" + d1 + "\t" + d2 + "\t" + d3 + "\n");
                System.out.println("Computer");
                System.out.println("--------");
                int d4 = (int)(Math.random() * 6) + 1;
                int d5 = (int)(Math.random() * 6) + 1;
                int d6 = (int)(Math.random() * 6) + 1;
                System.out.println("Roll: " + "\t" + d4 + "\t" + d5 + "\t" + d6);

                if ((d1 == d2) && (d1 == d3) && 
                    (d4 == d5) && (d4 == d6)) //Triple (Player & Computer) Tie
                    roundTied++;
                    System.out.println("You tied the round with the Computer!");
                if ((d1 == d2) || (d2 == d3) || (d1 == d3) && 
                    (d4 == d5) || (d4 == d6) || d5 == d6) //Pair (Player & Computer) Tie
                    roundTied++;
                    System.out.println("You tied the round with the Computer!");
                if ()

                if (userWin > compWin) winner = Player;}

                if (compWin > userWin) winner = Computer;

        }while(answer.equalsIgnoreCase("y"));
            System.out.println("\n" + "Game Results");
            System.out.println("------------");
            System.out.println("Rounds Played: " + turnCounter);
            System.out.println("User Wins: " + userWin + "\t" + " User Losses: " + userLoss);
            System.out.println("Computer Wins: " + compWin + "\t" + "Computer Losses: " + compLoss);
            System.out.println("Rounds Tied: " + roundTied);
            System.out.println("------------");
            System.out.println("The " + winner + " has won the game!");
            stdIn.close();
daluoxi 回答:如何为我的播放机与计算机骰子游戏正确设置这些确定规则?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3162665.html

大家都在问