[Solved] CSE 232- Programming Project 03

$25

File Name: CSE_232-_Programming_Project_03.zip
File Size: 292.02 KB

SKU: [Solved] CSE 232- Programming Project 03 Category: Tag:
5/5 - (1 vote)

Assignment Overview

This assignment will give you more experience on the use of loops and conditionals, and introduce the use of functions.

Background

Games have been interesting to computer scientists for, well since there was computer science. Not shoot-em-up, blood-and-gore games, those are just silly. We are talking about games that can be analyzed and their properties understood. In so doing we can design algorithms that do a better job solving a game, and perhaps apply those algorithms to other problems.

Anyway, lets play the game rock-papers-scissors.

Rock-Paper-Scissors

Lets call it RPS, I am a CS person afterall. RPS is a childrens game, a two player game that involves the two players choosing one of three hand gestures to see who wins a round of play, see https://en.wikipedia.org/wiki/Rock-paper-scissors . If you read the link to associated Ken games, https://en.wikipedia.org/wiki/Sansukumi-ken, you would see that its origins are less than child-like. It seems to have started as a game from Asia (in China, in Japan), one of a series of such games, that had to do with brothels and drinking games. How quaint!

The Rules

The rules are pretty simple, as illustrated by the Wikipedia page image shown below.

In this two-player game, each player can make one of three hand gestures. The players simultaneously (usually after the count of three) show their hand gesture and determine a winner. One of two outcomes is possible:

  • both players select the same hand gesture, resulting in a tie.
  • one player wins the round. The rules as shown are:

o rock wins over scissors o scissors wins over paper o paper wins over rock Project Description / Specification

Input and Output

We are going to use integers here to mean different things in different contexts so pay attention: The legal player numbers are 1 or 2 (player1 or player2)

  • For game moves: 1 is rock, 2 is paper, 3 is scissors.
  • For scoring purposes: 0 is a tie, 1 means player1 won, 2 means player2 won.

main

We are going to write some strategies to play RPS, and then run those strategies to see how they fare. We provide a skeleton file to start with that contains a predefined main. You can begin by editing this file and filling in the functions in the provided space. This updated file, with the unchanged predefined main, is what you will turn into Mimir. Do not change the main program! It will mess with the tests and you wont get the credit you deserve! The TAs will check for this during grading. All you do is provide the required functions.

The main program uses a switch statement to determine which functions to run. The first argument to main is the switch input value. Subsequent input values depend on the input needs for the function selected.

We will provide you with some starter code that has the main function written without the functions that you can fill in.

Functions

The 3 functions take the same arguments, even if that particular strategy doesnt need to use the information in all the arguments. Makes calling the functions more standard.

function: strategy1:

  • return is int, the move rock(1), paper(2) or scissors(3) you select for the next round.
  • Arguments are four integers in the following order:
    • player : which player are you (1 or 2).
    • previous_result : 0 if a tie otherwise 1 or 2 indicating player1 or player2 won the last round.
    • previous_play: 1, 2 or 3 if this player (the player of the first argument) played rock(1), paper(2) or scissors(3) in the last round.
    • opponent_previous_play: 1, 2 or 3 if the other player played rock(1), paper(2) or scissors(3) in the last round.

This function represents a simple strategy. It cycles through rock(1), paper(2) or scissors(3) in that exact order. Thus if your previous_play was: 1 you return 2; if 2 returns 3; if 3 returns 1;

function: strategy2:

  • return is int, the move rock(1), paper(2) or scissors(3) you select for the next round.
  • Arguments are four integers in the following order:
    • player : which player are you (1 or 2).
    • previous_result : 0 if a tie otherwise 1 or 2 indicating player1 or player2 won the last round.
    • previous_play: 1,2 or 3 if this player played rock(1), paper(2) or scissors(3) in the last round.
    • opponent_previous_play: 1,2 or 3 if the other player played rock(1), paper(2) or scissors(3) in the last round.

This is the stick-or-switch strategy. If you won or tied the last round return your previous play. Otherwise, return your opponents previous play.

function: strategy3:

  • return is int, the move rock(1), paper(2) or scissors(3) you select for the next round.
  • Arguments are four integers in the following order:
    • player : which player are you (1 or 2).
    • previous_result : 0 if a tie otherwise 1 or 2 indicating player1 or player2 won the last round. o previous_play: 1,2 or 3 if this player played rock(1), paper(2) or scissors(3) in the last round.
    • opponent_previous_play: 1,2 or 3 if the other player played rock(1), paper(2) or scissors(3) in the last round.

This is the stick-or-win strategy. If you won or tied the last round, return your previous play. Otherwise, return a move that would beat your opponents previous play.

function: score_round:

  • return is int. 0 for tie, otherwise 1 or 2 (which player won player1(1) or player2(2) ).
  • Arguments are two integers:
    • player1 move and player2 move (in that order). Each has a value of rock(1), paper(2) or scissors(3), the play made by each player.

Which player (1 or 2) won this round, or a 0 if it was a tie.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE 232- Programming Project 03
$25