任何人都可以从哪里开始解决这个问题? [英] Can any one please from where and how to start to solve this problem?

查看:60
本文介绍了任何人都可以从哪里开始解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GUTSY是两个或更多玩家的桌面游戏。它的目的是通过在克服一点规则的同时投掷一个模具获得101分,而不是那么贪心。每个玩家在转弯时,可以抛出

骰子并累积获得的积分,但如果s(他)获得一个点(一个点),积累的积分

在那一回合丢失(零点)。

规则是:

•玩家可以像s(他)想要的那样多次掷骰子并在s时停止(他)决定。

•每次掷骰子时,积分都会累积。

•一旦玩家决定停止,他/她的积分将计入目标为101

分。转向下一个玩家。

•一个点规则:如果玩家得到一个点,s(他)没有得到任何点(零)

朝着目标积累,转向下一个玩家。

•获得101分以上的玩家获胜。

问题陈述

你的Gutsy解决方案必须自动播放这个游戏并生成统计数据。我们需要

收集统计数据如下:

•获得一个点的可能性。

•获得两个点的概率。

•获得三个点的概率。

•获得四个点的概率。

•获得五个点的概率。

•获得六个点的概率。

•掷骰子以获得定义的累积值的平均次数。

•掷骰子的平均次数101或更多(获胜)。

为了处理统计数据,您的程序需要具有以下功能/方法:

•main()函数控制所有其他人。

•一个功能,playGutsy,提示用户提供Gutsy玩家的数量和他们将玩的游戏数量
。此函数将游戏结果存储在一个或多个适当大小的数组中,并且需要

统计数据。计算机将在没有人为干预的情况下播放给定的

数量的游戏,但在此之前,它会询问用户有关每个玩家的信息



1.玩家姓名,

2.停止掷骰子的最小数量(定义数量)。

•按顺序多次掷骰子的功能达到并累积值到

定义的数字,并返回累计值或零(如果获得一个点),

骰子的次数抛出,以及统计所需的计数器。建议

函数签名:void dieThrown(int dNumber,int * accumValue,int * numTimes,int

* count1to6 [])。

•通过使用前一个功能为玩家转弯并向目标和统计数据累积

值的功能。如果玩家获胜,则此功能返回。建议

函数签名:int playerTurn(int player,int accumValue,int * playerTotal,int

* numTimes101)。

•一个函数打印出玩家名称,定义数量,累计值和总额

点数。建议的函数签名:void playerPrint(int player,char playerName [],int

dNumber,int accumValue,int playerTotal)。

•显示的函数displayTable(打印出来)在一轮结束时每位玩家的所有总数

转(得分表)。该表格将在每场比赛结束时以及

最终结果中显示。

•一个函数统计,相应地存储统计值,以便计算它们

游戏结束。

•一个函数statisticsTotal,用于计算和显示(打印出)最终统计数据。对于

以下问题:

1.获得一个点的可能性,P(1)。 P(1)=#次一个点/#次投掷死亡

2.获得两个点的概率。

3.获得三个点的可能性。

4.获得四个点的概率。

5.获得五个点的概率。

6.获得六个点的可能性。

这些概率的总和应该是1.

7.掷骰子以获得定义的累积值的平均次数(每个玩家需要
)。 $>
8.掷骰子获得101或更多(获胜)的平均次数。

•一个函数sortPlayers,按字母顺序对玩家进行排序。

GUTSY GUI

包含说明的信息必须显示在程序开头。在此之后,

计算机将询问:

请输入玩家数量:2

请输入游戏数量:10

考虑到这些输入必须是有效的,因为它们必须是正值并且大于

零。然后计算机会询问:

玩家1:

姓名:John

转弯时停止的最小数量:10

玩家2:

姓名:玛丽

转弯时停止的最小数量:15

用户可以使用小写或上限输入的情况,但程序将始终转换为上限
的情况。一旦收集到用户的信息,计算机将启动自动游戏。

*****游戏开始*****

该程序将采取转向玩家一,在转弯结束时将显示:

游戏1

玩家1 - 约翰:

停止的最小数量转弯:10

获得的积分:12

总积分:12

然后将继续玩家2,显示:

玩家2 - 玛丽:

转弯时停止的最小数量:15

获得的积分:20

总积分:20

然后一个表格将显示如下:

游戏1 - 表格

玩家转折点总积分

John 12 12

Mary 20 20

当前获胜者:Mary

以下,程序将继续所有转弯,同时存储所需的统计值。在这个游戏结束时,当一个玩家达到101分或更高分时,它将显示:

游戏1 - 表

玩家转折点总积分

约翰福音14 103

Mary 0 98

*****获胜者:John *****
游戏1 - 统计

P(1)= 0.0600

P(2)= 0.2300

P(3)= 0.2400

P(4)= 0.1600

P(5)= 0.1900

P(6)= 0.1200

John - A(15)= 4

Mary - A(20)= 5

A(101)= 22

然后程序将继续播放以下游戏并显示如上所示。最后,它会再次显示最终表格和统计数据(如上所示的类似表格),但

按字母顺序排序。

GUTSY is a table game for two or more players. It aims at getting 101 points by throwing a die
while overcoming the one dot rule, and not being so greedy. Each player, at a turn, can throw the
die and accumulate the obtained points, but if s(he) gets one dot (one point), the accumulated points
in that turn are lost (zero points).
The rules are:
• The player can throw the die as many times as s(he) wants and stops when s(he) decides.
• Each time the die is thrown, the points are accumulated.
• Once a player decides to stop, his/her accumulated points count towards the goal of 101
points. The turn goes to the next player.
• One dot rule: If the player gets one dot, s(he) does not get any point (zero) to be
accumulated towards the goal, and the turn goes to the next player.
• The player who gets 101 or more points wins.
PROBLEM STATEMENT
Your Gutsy solution must play this game automatically and produce its statistics. We will need to
collect statistics as follows:
• Probability of getting one dot.
• Probability of getting two dots.
• Probability of getting three dots.
• Probability of getting four dots.
• Probability of getting five dots.
• Probability of getting six dots.
• Average number of times the die is thrown to get a defined accumulated value.
• Average number of times the die is thrown to get 101 or more (to win).
In order to deal with the statistics, your program is required to have the following function/methods:
• The main() function that controls all of the others.
• A function, playGutsy, that prompts the user for the number of Gutsy players and the
number of games they will play. This function stores the results of the games and required
statistics in one or more appropriately-sized array(s). The computer will play the given
number of games without human intervention, but before, it will ask the user for information
regarding each player:
1. Name of player,
2. Minimum number to stop a turn on the die (defined number).
• A function that throws a die several times in order to reach and accumulate values up to the
defined number, and returns the accumulated value or zero (in case a one dot is obtained),
number of times the die was thrown, and counters required for the statistics. Suggested
function signature: void dieThrown( int dNumber, int *accumValue, int *numTimes, int
*count1to6[]).
• A function that plays a turn for a player by using the previous function and accumulates the
value towards the goal and statistics. This function returns if the player has won. Suggested
function signature: int playerTurn( int player, int accumValue, int *playerTotal, int
*numTimes101).
• A function that prints out the player name, defined number, accumulated value and total
points. Suggested function signature: void playerPrint( int player, char playerName[], int
dNumber, int accumValue, int playerTotal).
• A function, displayTable, that displays (prints out) all totals per player at the end of a round
turn (scores table). This table will be displayed at the end of each game, as well as at the
final results.
• A function, statistics, that stores statistical values accordingly in order to calculate them at
the end of the games.
• A function, statisticsTotal, that calculates and displays (prints out) final statistics. for the
following questions:
1. Probability of getting one dot, P(1). P(1) = # times one dot / # times thrown die
2. Probability of getting two dots.
3. Probability of getting three dots.
4. Probability of getting four dots.
5. Probability of getting five dots.
6. Probability of getting six dots.
The sum of these probabilities should total 1.
7. Average number of times the die is thrown to get the defined accumulated value (per
player).
8. Average number of times the die is thrown to get 101 or more (to win).
• A function, sortPlayers, that sorts alphabetically the players.
GUTSY GUI
A message with instructions must be displayed at the beginning of the program. After this, the
computer will ask:
Please type in the number of players: 2
Please type in the number of games: 10
Take into account that these inputs must be valid as they must be positive values and greater than
zero. Then the computer will ask:
Player 1:
Name: John
Minimum number to stop in a turn: 10
Player 2:
Name: Mary
Minimum number to stop in a turn: 15
The user can use lower case or upper case for inputs, but the program will always convert to upper
case. Once information from the user is gathered, the computer will start the automatic game.
***** GAME STARTING *****
The program will then take the turn for player one and at the end of the turn will display:
Game 1
Player 1 – John:
Minimum number to stop in a turn: 10
Points obtained: 12
Total points: 12
And then will continue with player 2, displaying:
Player 2 – Mary:
Minimum number to stop in a turn: 15
Points obtained: 20
Total points: 20
Then a table will be displayed as follows:
Game 1 - Table
Player Turn points Total points
John 12 12
Mary 20 20
Current winner: Mary
Following, the program will continue all turns while storing the required values for the statistics. At
the end of this game, when one player has reached 101 or more points, it will display:
Game 1 - Table
Player Turn points Total points
John 14 103
Mary 0 98
***** Winner: John *****
Game 1 – Statistics
P(1) = 0.0600
P(2) = 0.2300
P(3) = 0.2400
P(4) = 0.1600
P(5) = 0.1900
P(6) = 0.1200
John – A(15) = 4
Mary – A(20) = 5
A(101) = 22
Then the program will continue playing the following games and displaying as presented above. At
the end, it will display again the final table and statistics (similar tables as presented above), but
sorted alphabetically.

推荐答案

这是一项复杂的任务,是一个大项目。如果你想制作一个这样的软件,你必须开始开发一个模型(一些具有实际状态的对象)并用一个函数实现你的每个规则。重要的是一个清晰的图形表示和一些文本文件中实际状态的保存/读取操作。



使用不同状态的枚举 - 它在开始时很痛苦但是帮助避免烦人的错误。



如果您了解 UML 你应该使用它,尤其是如果它是一些重要的功课。否则在纸上做一些草图以更好地理解问题。
It is a complex task a "big project". If you want to make a software of this, you must start to develop a model (some objects with the actual state) and implement every of your rules with ONE function. Important is also a clear graphical presentation and some save/read operations for the actual state in text files.

Use enums for different states - it is pain at the start but helps avoiding annoying bugs.

If you know about UML you should use it, especially if it some important homework. Else make some sketches on a paper to better understand the problems.


首先编写像playerPrint这样的大多数琐碎的功能,并确保它们有效。



从更简单的开始编写其他函数并且不依赖于尚未实现的其他函数。



同时编写所有必需的函数原型并提供那些空的/最小的实现。



然后绘制状态机的图表,这样你就能看到它应该做什么。



然后实现剩余的功能...



因为你的作业中有很多信息,你应该可以做很多事情甚至在需要任何帮助之前。



无论如何,最好自己动手,因为你会学到更多。
Start by writing most trivial functions like playerPrint and ensure those works.

The write other functions by starting with those that are simpler and do not depends on other functions not yet implemented.

Also write all required functions prototypes and provide an empty/minimal implementation of those.

Then draw diagrams of the state machine so you have a visual representation of what it should do.

Then implement remaining functions...

As there is a lot of information in your homework, you should be able to do a lot even before needing any help.

In any case, it is much better to do it yourself as you will learn much more.


这篇关于任何人都可以从哪里开始解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆