StudentShare
Contact Us
Sign In / Sign Up for FREE
Search
Go to advanced search...
Free

Analysis of Stone and Paper Game - Assignment Example

Summary
The paper "Analysis of Stone and Paper Game" tells us about program what enables the user to play the stone/paper/scissors game against the computer. When this game is played between two people, the players simultaneously choose one object (stone, paper, or scissors)…
Download full paper File format: .doc, available for editing
GRAB THE BEST PAPER94.9% of users find it useful

Extract of sample "Analysis of Stone and Paper Game"

Analysis of Stone and Paper Game This program enables the user to play the stone/paper/scissors game against the computer. When this game is playedbetween two people, the players simultaneously choose one object (stone, paper, or scissors). After a count of three, the players make either a fist for a stone, a flat hand for paper, or a ’V’ with two fingers to represent scissors. There is then a matrix for deciding who wins that round: -------- Player 1’s choices-------- Player1‘s choices Player 2‘s choices Stone Paper Scissors Stone Same choice; no one wins Paper (player 1) wins because paper surrounds stone. Stone (player 2) wins because stone smashes scissors. Paper Paper (player 2) wins because paper surrounds stone. Same choice; no one wins Scissors (player 1) wins because scissors cuts paper. Scissors Stone (player 1) wins because stone smashes scissors. Scissors (player 2) wins because scissors cuts paper. Same choice; no one wins Main algorithm for the program: while loop = ‘y’ do prompt the user for how many rounds they want to play initialize the variables sb1 and sb2 to 0 (counts number of wins) for the number of rounds chosen, prompt the user for their choice of paper/scissors/stone = ch use the rand function to get a random number between 0-2 (for the computer’s choice of paper/scissors/stone; store in randomNo) call function chk1 to find who wins print the results of how many games were won (sb1 and sb2) prompt user to play again (store in “loop” variable; if loop not equal to ‘y‘ or ‘Y‘ then while loop is finished) end while loop Algorithm for the function chk1: if user chose paper (variable ch=1) then if the computer chose paper (variable randomNo = 0) then print statement that no one wins (since both made the same choice) if the computer chose scissors (randomNo=1) then print statement that computer wins since scissors cuts paper change count of computer wins (increment variable “sb2”) end if if the computer chose stone (variable randomNo=2) then print statement that the user wins since paper surrounds stone change count of user wins (increment variable “sb1”) end if end if (ch=1) if user chose scissors (variable ch=2) then if the computer chose paper (variable randomNo = 0) then print statement that the user wins since scissors cuts paper change count of user wins (increment variable “sb1”) end if if the computer chose scissors (randomNo=1) then print statement that no one wins (since both made the same choice) if the computer chose stone (variable randomNo=2) then print statement that the computer wins since stone smashes scissors change count of computer wins (increment variable “sb2”) end if end if (ch=2) if user chose stone (variable ch=3) then if the computer chose paper (variable randomNo = 0) then print statement that the computer wins since paper surrounds stone change count of computer wins (increment variable “sb2”) end if if the computer chose scissors (randomNo=1) then print statement that the user wins since stone smashes scissors change count of user wins (increment variable “sb1”) end if if the computer chose stone (variable randomNo=2) then print statement that no one wins (since both made the same choice) end if (ch=3) end function chk1 Flowcharts are as follows: The data storage requirements are as follows: a variable must hold the user’s choice of paper/scissors/stone; another variable must hold the computer’s choice of paper/scissors/stone. If these three choices are represented as integers, then the variables can be integers called “ch” and “randomNo”. Another integer can hold the number of times the user wants to play, this integer is called “roundsnomber”. Integers “sb1” and “sb2” can hold the number of times the user or computer wins. The program detects if the player wants to continue play by reading a character from the keyboard, this is a type char variable called “loop”. The function “chk1” handles the analysis of who wins, by using the logic of the matrix above. Function “chk1” goes over every possible case of combinations of choices that the user and computer may make. This way the main program is mainly free to handle input and output, and make the random choices of the computer. Code for the program (first version) is as follows: #include #include #include #include int randomNo; int ch, sb1, sb2; void chk1(void); void main (void) { char loop=y; int roundsnomber; randomize(); printf("Welcome to the scissors, paper, stone game \n\n\n"); do { printf("How many rounds would you like to play for?"); scanf("%i", &roundsnomber); printf("\n\nGame started....\n\n\n"); sb1=0;sb2=0; for (int i = 1; i Read More

CHECK THESE SAMPLES OF Analysis of Stone and Paper Game

The Stele of Hammurabi

The thesis statement this paper would be holding is that artistic value of objects made before 1400 BC was not appreciated; they made artwork for functional reasons, their artistic elements came by default as modern day art experts discover them many generations later.... This paper investigates the political, cultural, historical and artistic context of The Stele of Hammurabi, to establish its presence in time and place in the kingdom; it further evaluates different approaches to the study of art in ancient times, before modern scholars developed art curriculum and content....
4 Pages (1000 words) Essay

Consequences of Expectations based on The Lottery by Shirley Jackson

As if it were Christmas, little kids would happily gather stones; stuff them in their pockets and in the end, only to play the real game.... However, there could be several reasons why this game might have sustained over the course of time despite its deadly theme.... From Summer's tone here, it could be easily understood that the true colors of the tradition starts to show, especially when he asks to ‘get it over with;' projecting that no one is over the moon to stone someone....
4 Pages (1000 words) Essay

THE LOTTERY

The purpose of the lottery is not explicitly stated in the story though a more detailed analysis of the story would reveal that the lottery is done to ensure a good harvest the next year.... A lottery is a game of chance.... He is the one who prepares the slips of paper and he also brings the stool where the black box is placed....
4 Pages (1000 words) Essay

Why do people behave differently when gaming online vs. offline

A number of research studies reveal that analysis of these indecisive behaviors comes because of interactions.... For instance, online gaming brings out emotions of anger especially when one does not understand the set rules of the game.... Oftentimes, you find some gamers want something like a new hot game from a friend.... Thus, what happens is that, when the host is showing you the new game styles and the likes, you tend to throw insincere and baseless compliments just to make the host find it vital for you to get the new game (Sayre & King, 2009)....
5 Pages (1250 words) Essay

Fiction comparative and contrast

Build upon the parameters of comparison regarding the areas like plot structure, characterization, setting , themes and purpose of the author, symbols, imagery style and tone, the essay shall probe into the transition of the thought processes and cultural backdrops from which the comparative analysis of these seminal works have evolved and operated.... When contrasting Shirley Jackson's short story “The Lottery” and the story “The Most Dangerous game” by Richard Connell are publications from different time frames, this particular understanding becomes quite apparent....
3 Pages (750 words) Essay

Shirley Jackson's 'The Lottery'

The sight of kids gathering stones "Bobby Martin had already stuffed his pockets full of stones, and the other boys soon followed his example, selecting the smoothest and roundest stones" and pilling them into stacks can be dissuaded as a juvenile act however the fact that the men of the village gather away from the stone might bear the seeds of early suspicion in a readers mind....
5 Pages (1250 words) Book Report/Review

English Research Paper #3

Therefore, the analysis of the fiction by Poe confirms that there is tremendous scope for a Freudian psychological interpretation of the various elements in most of his short stories.... The existing psychological studies seem not to cover the true extent of its possibility as a variety of criticisms and analysis of this nature focused on the psychological interpretation of the fiction mainly treating them as unconscious manifestation of the writer's own problems....
5 Pages (1250 words) Essay

Representation of Brutality in Literature

Therefore, a reflective analysis of the works by Shirley Jackson and Norman Cousin suggest that there are various similarities between the works, although they are concerned with different themes and plot.... "analysis of "The Lottery", a Short Story by Shirley Jackson.... Whereas Cousins' essay "Who killed Benny Paret" focuses on the cause and effect of a game, Shirley Jackson's "The Lottery" describes an event through the medium of short story....
2 Pages (500 words) Book Report/Review
sponsored ads
We use cookies to create the best experience for you. Keep on browsing if you are OK with that, or find out how to manage cookies.
Contact Us