[MUSIC].
Well, I had planned to use a fabulous clip from The Big Bang Theory and have
Sheldon Cooper explain the rules to Rock-paper-scissors-lizard-Spock.
But unfortunately, the Copyright Police told me that was a very bad idea.
So, since my wife thinks that I'm already a lot like Sheldon, I'm going to take my
crack at explaining the rules to Rock-paper-scissors-lizard-Spock ala
Sheldon Cooper. Let's do this.
It's very simple. Scissors cuts paper.
Paper covers rock. Rock crushes lizard.
Lizard poisons Spock. Spock smashes scissors.
Scissors decapitates lizard. The lizard eats paper.
Paper disproves Spock. Spock vaporizes rock.
And as it always has been, rock crushes scissors.
Yeah. Well, I hope you enjoyed that.
our mini-project for the end of week one and the first one that you'll turn in for
a grade, is Rock-paper-scissors-lizard-Spock.
Now, when we were brainstorming on kind of what kind of mini-projects we should
use for this class, our first inclination was to do something on income taxes.
So, I kind of bounced this idea off of my focus group at home consisting of my
three kids, and their reaction was, incomes taxes?
Yuck. Who want to do income taxes?
So, we watch a lot of Big Bang Theory at home.
And so, they came up with the idea, hey, yeah, let's do something on
Rock-paper-scissors-lizard-Spock. So, that's where the idea came from.
In this video, I'm going to do two things.
I'm going to start off by walking you through the rules for
rock-paper-scissors. And then later,
Rock-paper-scissors-lizard-Spock. And I'll show you kind of a clever idea
for how to determine who wins the game of Rock-paper-scissors-lizard-Spock.
And in the second part of the video, I'll walk you through the mini-project, and
then in particular, I'll show you how you can get help if you're having trouble
actually completing the mini-project. We've got kind of some nice support
structures in place in the class, and I'll shown, show you how to use those.
And if you get stuck, you should come back and look at this video because it
will give you some nice hints about how to proceed.
Okay, let's go on and get started. Alright, let's go through the rules of
Rock-paper-scissor-lizard-Spock a little slower.
So, this is just a variant of rock-paper-scissors.
You have rock, paper, and scissors. So, rock smashes scissors.
Scissors cuts paper. Paper covers rock.
The problem with playing rock-paper-scissors is that you tie a lot
and, you know, if you play friends where they kind of know your patterns, they
may, you may tie more than half the time. So, one way to avoid having lots of ties
is to add more items. So, with this variance you add in Lizard
and you add in Spock. And this little poem over here is
actually what Sheldon recites on the Big Bang Theory to describe it, and my kids
love it when I do this. but I don't expect you to actually
program these roles in your first project.
I'm going to tell you a simpler way using surprise, surprise, modular arithmetic.
So over here, I have the Rock-paper-scissor-lizard-Spock wheel,
and in fact, it's really the rock-Spock-paper-lizard-scissors wheel.
And the way to remember this is you put Spock next to rock and lizard next to
scissors. Now why is this wheel useful?
It's because I can figure out who I win and lose to based on where I sit on the
wheel. So, let's consider Spock.
Spock always beats his counterclockwise opponents.
Spock vaporizes rocks. Spock smashes scissors.
But he always loses to his clockwise opponents.
Paper disproves Spock. Lizard poisons Spock.
In fact, this holds for every item on the wheel.
So, if you want to go through and figure out who wins at rock-paper-scissors, we
can take the numbers for each of the items[UNKNOWN] we can look at their
difference. So, we could take paper minus Spock.
Okay. Paper appears to run clockwise, so 2
minus 1 is positive, it's 1, therefore paper beats Spock, okay?
Lizard, 3 minus 1 is 2, it's actually clockwise.
What about let's see, we have scissors minus Spock, so we have 4 minus 1, that's
3. Well let's see, 3 has gone far enough
around that we're actually kind of counterclockwise.
In fact, we have plus rock, rock is 4, so we have 0 minus 1 that's negative 1.
Hm, gosh what do we do there? we could use modular arithmetic
remainders, remainders. We could go through and take minus 1
remainder 5. Remember when I talked about whenever you
have a negative number, you're taking the remainder.
You just think about adding the number you're taking the remainder with as many
times as it takes to get it in the range between 0 and 5.
So here, we take negative one, we add 5 to it, we get 4.
So, the rule is really that if you take the first item minus the second, if the
difference is 1 or 2, the first item wins.
If the difference is 3 or 4, the second item wins.
So, we'll, we'll go and see that in the program template in a second.
But this is a simpler way to actually program[UNKNOWN].
All you're going to need to do is build an else, else if, if else if, else
clause, and use a little modular arithmetic.
So, let's move onto the program template and I'll kind of, will be more tangible.
Alright. Let's walk through building
Rock-paper-scissors-lizard-Spock. You should understand the rules from now.
So, let's go out to the home page and we'll click on the Mini-projects link,
scroll down and we'll go to Rock-paper-scissors-lizard-Spock.
So, just like for Mini-project 0, we have a description of the mini-project, it has
some kind of an overview here, kind of the same thing we talked about in the
previous segment. And then it has a very detailed
step-by-step walkthrough of implementing Rock-paper-scissors-lizard-Spock.
Please read this, this gives you important hints on how to implement the
project. for example, it mentions when you're
doing, generating random numbers, you use random.randrange, so read that, it'll
give you lots of nice hints on there. notice it also includes what the output
of the program should like, okay? So, if you're curious kind of what it
should produce, it should produce something in this format.
it includes a grading rubric that discusses kind of how to handle
deviations and then gives you items for how to evaluate if your implementation is
correct or not. So, it's important that you familiarize
yourself with this. One important point here.
The first rubric item says you need to use CodeSkulptor.
Don't try to cut and paste your code into the Submission box.
I know it's tempting because you want to use a tool like Idle, well, you can
kind of get by with it for this project. But in the future, you're going to need
to be using CodeSkulptor because a lot of the interactivity is going to take place
inside the web browser and it's not going to be able to be implemented inside
Idle. so just get used to it now.
If you use CodeSkulptor, it's going to make your assessment much more reliable
and much more easy. when you're ready to start writing code,
you can scroll up here. We have a template.
Every mini-project has a template. We can click on this.
And this pops up basically in CodeSkulptor you already know which
contains, could contain the starting point for your project.
really if you look at the project, there's really 3 things you need to do.
You need to implement a function number to name, a function name to number, and a
function rpsls. So, you kind of have to fill in these
comments with Python code. at the bottom, there are 5 calls to rpsls
that will essentially test if your implementation is correct or not.
So, when you run your code, you should expect to see some text appear over here.
We've actually echoed that text right here for you.
I'll also show it to you in the video, so you can actually see it in action.
This is my implementation of Rock-paper-scissors-lizard-Spock.
you can see, you might ask well where are my definitions of these functions.
I've used the function, basically a kind of a feature of CodeSkulptor called code
folding. If you right Click on this little column
here, you can actually either fold up and hide code or expose code.
I've actually hid the definitions of number to name, name to number, and
rpsls. If I run this, what you can see here is
the textual output. So, I notice a couple of things about
this that using random numbers, I can make kind of a different response for the
computer on each particular individual game here so I didn't always choose the
same value for the computer. And then if I run this again, I see
different choices for the computer. Notice the players choices are always the
same for every single run and that's because we have these five values here.
so this is a kind of a, kind of a way to get you started on doing
Rock-paper-scissors-lizard-Spock. Now, what I'll do next is I'l walk you
through how to get help if you get stuck implementing the mini-project.
Okay, you're working on your mini-project and you get stuck, it's going to happen.
So, what do you do to get through and finish off the mini-project?
Well, the first thing you can do is, if you're confused about some particular
Python concept, go back and take a look at the appropriate class video.
For example, if you don't understand how conditionals work, take a look at Scott's
video on conditionals. we tried to include in the videos all the
concepts that you need to finish that particular week's mini-project.
Okay, they didn't get you unstuck, alright?
Go back and look at the mini-project description again.
In particular, take a look at the development process.
There are lots of details here about how to actually implement the project.
if you're not following the development process, it's easy to get lost.
so if your having trouble, go back and take a deep look at it.
Okay, that still doesn't help you. You're still confused, don't understand
what to do. You have a tremendous resource available
here. And this is something that only happens
in really large classes. You have the discussion forums.
So, we spent a lot of time in designing the discussion forums.
So, in particular, we have forums for mini-projects and we have a forum for
Rock-paper-scissors-lizard-Spock. And I've already got a couple of, got a,
got a post it here and we'll talk about it in just a second.
But when your peers start working on this project, there are going to be literally
tens of thousands of people trying to do this project.
There will be a blizzard of posts. Lots of posts here on all kinds of topics
related to probably something that you're having trouble with.
So, spend some time in the forums, there's a great search feature here,
we've got a Search box right here. Kind of use the Search box and try to
locate the existing thread that answers your question.
if it's kind of close but not exact, you might actually add another post to that,
or if you know something, how to answer a question, add something there.
You are going to see that most of the threads get lots of posts in them from
people either asking more questions or trying to help.
One nice thing about previous sessions is we have people that are actually fairly
experienced with Python here, that really want to help everybody else learn how to
program in Python. if it turns out that nobody has asked
your question, start a new thread, okay? Be polite.
what'll happen is typically, it won't take too long, maybe 5, 10 minutes at
most and you'll get a few people that are trying to ask your question.
Now, one thing is the class has an Autocode so you can't post the link to
your working or almost working mini project, so you may need to use questions
along the lines of I don't understand how conditionals work.
Or maybe show a little, small portion of your code and say, this particular code,
piece of code doesn't work. if you're stuck and you really don't know
what to do, I'm going to show you one more thing that you can do, and this is
something that's unique to this class and we're going to do our best to help you
out with. So, give me a second and I'll show you
kind of your, your method of last resort. Alright, you've consulted the forums and
you're still stuck. We've still got more help for you.
the next thing I suggest you do is, inside CodeSkulptor, there's a button up
here that says Tips. This links to a particular thread inside
the current week's mini-project forum. So, here we're in the forum for
Rock-paper-scissors-lizard-Spock and I've created a thread called Code Clinic tips
for RPSLS. So, in this thread, I've essentially
posted some information about students' errors and things to help with solving
this particular week's mini-project. for this session, what we're going to do
is we're going to always start off with some essentially testing functions to
help you make sure that the helper functions you're building for your
mini-project are correct. So, remember, you have to implement name
to number and number to name. We've put out here two CodeSkulptor URLs
that you can use to test to see if your implementations of those functions are
correct. So for example, I click on this, it pops
up a CodeSkulptor URL, which has a place for you to pa, paste in your definition
of name to number. And then, it has some test calls to name
to number with appropriate input data. And it tells you what should come out of
that, what the output format should look like.
So, if your implementation of name and number is correct and you paste it in
here, you should see something like this coming out.
This basically gives you a way to check and see if your helper function is
written correctly. If it passes this test, there's a good
chance that implementation is correct. there's also one here for number to name.
the thread also includes observations from previous iterations of the class.
Here's some examples of kind of common errors that I've observed in working with
students things like always capitalize Spock.
Python is sensitive to case. there's one thing I mention here.
What's this thing called a Code Clinic? So, how did I get all these observations?
I, the other instructors and the community TAs have a special e-mail
address that we've set up where you can, as a matter of last resort, send request
for help. For this session, it's
interactivepython@online.rice.edu. Send e-mail to this, we have a
professional help desk that's actually helping us.
You should get an automatic response. If the Code Clinic is over loaded you'll
get a response saying, it's going to take a long time, you may not get a response.
your e-mail will actually be sent to one of the instructors or one of the
community TAs, and they'll have a chance to help you.
Now, this class is going to have many tens of thousands of students.
If you're all trying to do the project at once and there's maybe a dozen of us
trying to answer e-mail, this is only going to work if you use this under the
following circumstances. You've tried all the other ways I've
discussed of help, of trying to seek help.
You only send us an e-mail with a CodeSkulptor URL that's relevant to the
current week's mini-project. This is not a way to get questions
answered about concepts about the class. Post that in the forum, we're going to
ignore all other requests. But if you're stuck, and you think, man,
I know I'm just like just like one little change away from getting the mini-project
done and you're getting frustrated, send it here, we're going to do our best to
help. what will happen is at the end of the
day, we'll try to send you back maybe a modified CodeSkulptor URL that will point
out where your error was, or give you a hand in terms of trying to do it.
it may turn out there are too many requests.
And so, this is something we're doing our best at here.
my wife actually spent so much time in the Code Clinic last time, my wife
actually got me a custom t-shirt for this.
we're going to do our best to help every single one of you.
And so, please be patient with us. Especially on this first first couple of
mini-projects if we get overwhelmed in there.
We've got better technology this time but we're going to do our best.
But again, only use it for code that's sick.
If your code is feeling ill, and not doing very well, send us a URL, we'll
take a shot at helping fix it. Okay, good luck on the mini-project.
You can do it.