命令式编程作业代写 imperative programming

命令式编程作业代写

imperative programming

命令式编程作业代写 This task is to program a Yatzy-like game. The starting point is the classic Yatzy rules. The Yatzy game in this task is special in

The general rules for the preparation and submission of the assignment are described in the Framework for Exam assignments in Imperative Programming.

 

This task is to program a Yatzy-like game. The starting point is the classic Yatzy rules. The Yatzy game in this task is special in the following ways:  命令式编程作业代写

命令式编程作业代写

More than five dice can be used (let's say here that N dice are played).

The game can be played without dialogue with the users (perhaps except prompt for N).

In each round, the N dice are rolled only once.

The game rounds are completed in a fixed order: the first time you roll the dice after the 1s. Next time after the 2s. Last time it's about achieving yatzy.

In each round, the program selects up to 5 out of the N dice that give the highest possible number of points in the current round.

Thus, N dice are rolled at a time, N ≥ 5. The program selects up to 5 of these, which can be used in the current game. The non-selected dice are ignored.

 

Example with 8 dice showing 2 2 6 5 1 6 2 3:  命令式编程作业代写

 

In a round where you fight for 1s. There is only one 1s and 1 point is posted on the first row.

In a round where 2s are fought for. Since there are three 2s, these are selected and 6 points are posted in the 2nd row.

In a round where two pairs are fought. Since there are two 6s and two 2s, these are selected and 16 pairs are posted in a row.

In a round where fighting is by chance. The 5 highest dice rolls are selected and 22 are posted.

You can choose to enforce that you must have at least three identical dice to get points in rows 1-6.  命令式编程作业代写

 

The game must have a table (score board), which keeps track of the points account (for one player, namely the computer). This table can be a simple, statically allocated int array. When the last round is completed, the game result is calculated according to the current rules, including the bonus rule, a summary of the game is printed on the screen, and the user is offered, iteratively, another game.

 

It is recommended that the eyes of the N dice be printed continuously after each round, together with the number of points that the round gives rise to. In this way, it is possible to check that the points of the game are calculated correctly in each round.  命令式编程作业代写

 

In this game there is a need for a simulation of a dice. This can be easily achieved through a function that uses the edge function from stdlib. (We have already seen such a dice roll feature). As part of the solution, a function roll_multiple_dies is used, which creates an int array and shows N simultaneous dice rolls. We have already programmed roll_multiple_dies in an assignment on courses

北亨内平社区学院代写更多代写:cs代写    计量经济代考   机器学习代写      r语言代写 大数据作业代做

发表评论

客服一号:点击这里给我发消息
客服二号:点击这里给我发消息
微信客服1:essay-kathrine
微信客服2:essay-gloria