#100DaysOfCode in Python Transcripts
Chapter: Days 13-15: Text-based games (and classes)
Lecture: Your turn: Day 2
0:00 Second day, is we're going to write standard Rock, Paper, Scissors. And you're going to model this with classes.
0:06 There's going to be a roll and the roll has a name. It knows what rolls defeat it. And, alright, so you store the name
0:18 that other rolls, that the names of the rolls that you can defeat as a roll and the rolls that defeat you. Also, we have player concept.
0:27 And the player is really just going to have a name. So it says, player Sarah rolls this. Player Computer rolls that, and so on.
0:35 Alright, so nothing major there. You could also keep a history of the rolls. You could show like, sort of replay the game if you wanted,
0:42 and each player could remember what they played at each stage, that'd be fun. And then the basic program flow looks like this.
0:48 This is not perfectly exactly what you necessarily need. It's not totally implemented but, we're going to
0:53 print out the header, we're going to initialize the game here by getting the various rolls, in this case there's only the three: Rock, Paper, Scissors.
1:01 And then we're going to get the name of the player, Add the computer and then we'll have an automatic player
1:07 here, and then we're going to run this little game loop, by passing them off. And the game loopers need to go round-and-round, until somebody has won.
1:14 We'll go around three times, and basically just have the computer randomly roll. And then have the real player ask them what they
1:21 want to roll, Rock, Paper, Scissors, and then have them do that roll correctly. And then finally, you can just sort of do this comparison.
1:27 Does the one roll defeat the other? I don't know, right? And then just do a little output here, and increment the count so that you'll know,
1:34 like you just played best of three. So you'll know who won, figure out who won and then print out so-and-so won 2 to 1 or
1:42 3 to 0 or something like that. If you get a tie somewhere in the middle, this doesn't work so, you know,
1:49 maybe once you get it working, not considering ties, then come back and address the possibility there might be ties.