UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Rock Paper Scissor Challenge

Forums > 100 Days of SwiftUI

@ian  

I am confused about the Rock Paper Scissor Challenge here: https://www.hackingwithswift.com/guide/ios-swiftui/2/3/challenge

Each turn the app will alternate between prompting the player to win or lose.

Why is the app prompting the player to win or loose? You win or loose rock paper scissors based on a comparison between the players choices, as far as I know.

So, if the app chose “Rock” and “Win” the player would need to choose “Paper”, but if the app chose “Rock” and “Lose” the player would need to choose “Scissors”.

Why is the app choosing win or loose?

I am unclear on the game logic, in my mind the computer would pick either rock paper or scissors, and then based on what the user picks either the user would win or loose.

I think I am reading something wrong or just missing the point.

Thanks!

2      

The challenge is asking you to modify your code so that the player scores a point if they match the requested outcome - win or lose the round against the computer.

Otherwise the player loses a point.

2      

Imagine that it's a game of "Simon Says..." - So the app choosing Win/Lose is like "Simon Says Win" or "Simon Says Lose".. So if Simon Says Win and the App chooses Rock, the Player should chose Paper to Win. But if Simon Says Lose, then the player should chose Scissors to lose to Rock.

2      

If you were just making a classic Rock, Paper, Scissors game, then you would be right. You wouldn't want to make the app randomly decide when a player should win or lose. Instead, you would hide the computer's selection until after the player had made their selection, and then let them know if they won or lost.

However, in this project Paul is asking us to create a version of the game with a twist. The player gets to see the computer's selection in advance. So, in order to make the game any kind of challenge at all, the player has to pay attention to whether they should be trying to win or lose to their opponent, and select the appropriate response each time. It still isn't much of a challenge. But it at least makes the player think more than they would have to if they were just playing a game of Rock, Paper, Scissors where they always go second.

2      

@ian  

@FlyOstrich @Azzaknight Thanks for the responses, I almost get but also dont understand why this would be done this way, and cant quite grasp the game logic.

I think I am having trouble wrapping my head around making a rock paper scissors game that isn't a rock paper scissors game.

Is it supposed to be a variation on the Flags game?

2      

There really is no reason to make the game this way other than it was what we were instructed to do.

I think the idea was basically just to give you a new challenge. If you were asked to create a classic "Rock, Paper, Scissors" game then it would have basically been exactly like creating the "Guess the Flag" game. But Paul wanted to throw an extra difference in just to make sure that you understand how the code in the "Guess the Flag" game works well enough to be able to modify it a bit.

I don't think that there is any reason beyond that for why a person would want to make the game work in this way.

2      

@ian  

Thanks, I think I will come back to in a few days and see if it clicks.

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.