Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.1 Getting player's choice Start by preparing a MARIE program which requests from the user a choice of rock,scissors or paper (represents with integers). You

2.1 Getting player's choice

Start by preparing a MARIE program which requests from the user a choice of rock,scissors or paper (represents with integers). You should use 1 to represent 'rock', 2 to represent 'scissors' and 3 to represent 'paper'.

2.2 Print string

Prepare a MARIE program which will print a string (string at a given location and zero terminated). Extend you previous work to be a routine that accpets the player number (1 or 2) and prints whose turn it is before accepting the choice. It should stroe the result from the user somewhere appropriate.

2.3 Comparisons

Prepare MARIE routines called RockScissors , ScissorsPaper , PaperRock which each take two numbers as input (represent the choice of the two players) and checks if the numbers correspond to the name of the routing (eg. ScissorsPaper would determine if one player chose scissors and the other player chose paper). Ensure each of these routines pass back 0 where they do not match and 1 where they do but player 1 would win from this and -1 where they match but player 2 would win from this.

2.4 Win counting

Prepare a MARIE routine called playerWin which accepts a player number and a count of previous wins and uses your string printing code to display that the given player number has won (a round). This routine should also pass back the new number of wins for that player (one more than before). For example:

1

'

s

t

u

r

n

3

2

'

s

t

u

r

n

1

1

w

i

n

s

[program ends]

rewritten for conciseness:

1's turn

3

2's turn

1

1 wins

In the above, the total number of wins for player 1 is increased by 1 (but this is not displayed)

2.5 Best of three

Now prepare a MARIE program which uses all of the previous routines to allow the two players to play a best two out of three game (rst player to two points wins). For example, it may look as below:

[formatted for conciseness]

1's turn

3

2's turn

1

1 wins

1's turn

2

2's turn

1

2 wins

1's turn

3

2's turn

2

2 wins

2 wins

2.6 Best of N (4 marks)

Finally, modify your program so that it is not limited to 3 games maximum. Allow the user to enter the maximum number of games to play.

Hint: for N max games, the points required to win is ceiling(N=2) ! eg. 4 for a game of 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

define what is meant by the term human resource management

Answered: 1 week ago