Hello there, John Balwit here
with the complexity course.
And we are going to going to look at
the homework assignment,
for the information theory,
the intermediate level.
we've been asked in question number two
to modify SlotMachine.nlogo model
to include following macro states: exactly
two the of same kind; no lemons;
and two lemons and one orange.
So here's how I'll do this:
I'm going to first copy that.
We are going to look
at the selector here
that picks which cases are available,
and we're going to add these states.
So I'll edit that, and I will go like this. (typing)
So now we've added
"Exactly two of the same kind."
Now we go into to the code and
we see how the other selectors work.
We find those right here.
Now here's one that's very similar
that's called "at least two of the same kind"
and that uses the measurement
of the shape of all-reels
and it measures the length of that list
after we've removed any duplicates.
So just to refresh ourselves,
let's ask it to show
what this shape of all reels is.
So im just modifying this
"at least two of the same kind"
so that it shows us what
this shape of all-reels is.
So I'm going to look down
here in the command center.
I'll make this a little bit smaller
temporarily
so we can see that command center.
Okay now when I select
"At least two of the same kind,"
I reset, and I pull the lever,
and we see, down here,
that is the list.
I'll halt this now.
That's what that list looks like.
Okay?
So that list is just
three strings in the list.
So now that we remember
what the shape of that looks like
we can say, Let's just copy
this one here, and rename it
to what we had here, which was
"Exactly two of the same kind."
I'm just going to
edit this here.
It's always a good idea to cut and paste
when you have a chance.
So I'm going to capture that and copy.
Okay.
And put that in this code here.
If we're looking
for exactly two of the same kind
that means that when we take this list
with the three names of the fruits,
if it has a duplicate, if any of the two
are the same, and
we remove those duplicates,
then the length of this will be
exactly equal to 2.
So we just say that this is equal to 2.
Okay.
So i'll try to make this
so we can see it.
There we go.
So "exactly two of the same kind "
should pick out the states
where the reel is exactly equal to two.
Lets try it.
Set "exactly two of the same kind," we reset,
pull the lever...
Well that's not helping us very much.
Let's halt that.
Let's throw in some debugging code so we
can actually see...
So I'm just going to throw a stop in here,
so whenever it hits, it's going to stop.
So we can see what it has stopped at.
"exactly two of the same kind"
Yep... two pears... two pears...
two pears again... two cherries...
It appears to be working.
Okay.
I'm going to go back in the code and
remove my little debugging stop.
Flipping back over here, we're looking for
"no lemons" as our next challenge.
So I'm going to copy and paste this again.
Copy that, and this
one will be called:
"No lemons".
So that's "No lemons".
For this one I think we're going to
use this member.
Here's one that is asking
for at least one lemon,
and we're asking if "lemon" is a member of this.
So we can basically just say:
Look, it's "no lemons" if
it's not the case that the
shape "lemon" is in there.
So that says "not member?"
That's a boolean when it ends in a "?"
And lets again use our little stop
so that we can debug this.
And lets not forget
to remove this other
part that was left over
from the cut and paste.
So, "not member? lemon"
So that's just saying that in this list
"lemon" is not a member. Okay.
And we will stop if we hit that.
Flipping over to the interface,
pull the lever,
No lemon, no lemon,
So it seems to be working.
Next challenge is "Two lemons
and one orange."
Okay so I want to copy that.
We'll add it here as a string.
Then we'll go into the code
and place that string.
And make another cut and paste.
Oops I don't think I've copied enough
here. Don't do this.
We going to grab this whole thing,
copy that there.
Copy the string.
Okay, so what are we going to put for
this one?
Clearly, we're going to want
to determine if there's an orange.
So we're going to say:
We've removed an orange from this list.
Since there's only one orange allowed,
when we remove an orange from this list,
the length of that list will have to be 2.
So the length of the removed orange
would be 2.
We can also say: and if we
remove the lemons,
then we would expect the length
of that list to be 1.
Right? There's just an orange left.
Okay. So when you put those two together,
That should let us
correctly identify those.
So let's remove my debugging code
from the previous one.
Let's see if this catches it.
We'll leave that stop in there.
Okay so let's test it.
Reset. Pull the lever.
Stops on an orange and two lemons.
Play again.
Orange and two lemons.
Two lemons and an orange.
Okay seems like it works.
Double check the code here.
Remove that and we are finished with that
final part of problem number two.