1
00:00:05,280 --> 00:00:09,280
So continuing on with Dictionaries,
I mentioned in a previous video

2
00:00:09,280 --> 00:00:11,400
after the challenge, there was
a couple of more things to cover.

3
00:00:11,400 --> 00:00:14,800
Before I start that, I just wanted to let
you know that I've changed to a different

4
00:00:14,800 --> 00:00:15,580
theme for my videos.

5
00:00:15,580 --> 00:00:17,250
You can see the background.

6
00:00:17,250 --> 00:00:19,230
We're now using darcula,
and the reason for

7
00:00:19,230 --> 00:00:21,500
that is you've probably noticed
in the last few videos,

8
00:00:21,500 --> 00:00:25,720
whenever a dialogue box Pops up,
the buttons look out of place.

9
00:00:25,720 --> 00:00:27,920
Because what I've done is I've
increased the font size so

10
00:00:27,920 --> 00:00:29,370
that you can see these videos easier.

11
00:00:29,370 --> 00:00:33,840
But there seems to be a bug,
at the moment, in the white background.

12
00:00:33,840 --> 00:00:35,920
A standard thing that comes with IntelliJ.

13
00:00:35,920 --> 00:00:37,950
And if I change to this thing,
that problem goes away.

14
00:00:37,950 --> 00:00:39,840
So we'll see how we go with this color.

15
00:00:39,840 --> 00:00:40,830
Hopefully it's still good.

16
00:00:40,830 --> 00:00:43,330
And give me some feedback,
if you wouldn't mind, please, and

17
00:00:43,330 --> 00:00:46,070
let me know if you're still
being able to see this video.

18
00:00:46,070 --> 00:00:50,240
And still not very clear on your screen
but certainly good to work with.

19
00:00:50,240 --> 00:00:54,700
I think I mentioned earlier in the course
when we're installing intellij that I

20
00:00:54,700 --> 00:00:57,380
actually prefer this for
my everyday development.

21
00:00:57,380 --> 00:01:01,850
Okay moving on we're going to look at two
more dictionary methods that can be really

22
00:01:01,850 --> 00:01:05,340
useful in your everyday path in
programming First one is the update method

23
00:01:05,340 --> 00:01:08,240
and that allows you to combine
two dictionaries together.

24
00:01:08,240 --> 00:01:09,630
So that's really useful.

25
00:01:09,630 --> 00:01:12,220
And the second one is the copy
method which is used to

26
00:01:12,220 --> 00:01:14,320
create a copy of a dictionary.

27
00:01:14,320 --> 00:01:17,050
And I've created a new file
I've called fruit.pie and

28
00:01:17,050 --> 00:01:19,650
I've just pasted in our fruit.

29
00:01:19,650 --> 00:01:23,470
from the original dictionary
videos that we did bout that.

30
00:01:23,470 --> 00:01:25,090
So I've posted those back in again.

31
00:01:25,090 --> 00:01:25,720
And we're gonna do,

32
00:01:25,720 --> 00:01:28,430
what we're gonna do now is we're
gonna store some veggies as well.

33
00:01:28,430 --> 00:01:30,080
So we're gonna put print fruit.

34
00:01:32,490 --> 00:01:36,880
Then we're gonna do veg for
veggies equals, let's add some vegetables.

35
00:01:38,000 --> 00:01:39,390
Cabbage, everyone's favorite.

36
00:01:41,040 --> 00:01:46,870
Especially children,
every child is maybe not every

37
00:01:46,870 --> 00:01:51,630
childs favorite

38
00:01:51,630 --> 00:01:56,040
sprouts, lovely.

39
00:01:57,250 --> 00:01:59,060
That's debatable I think.

40
00:01:59,060 --> 00:02:01,400
And spinach,
which is something I actually do like.

41
00:02:03,220 --> 00:02:07,240
Can I have some more fruit please,

42
00:02:07,240 --> 00:02:09,759
which would be a typical
response from people to spinach.

43
00:02:09,759 --> 00:02:13,380
Okay, so we've added three
entries in our dictionary and

44
00:02:13,380 --> 00:02:15,300
we're just going to
print that out as well.

45
00:02:15,300 --> 00:02:17,520
We can run that.

46
00:02:17,520 --> 00:02:21,180
So at the moment Oops, I need to
cancel out of that, so disconnect.

47
00:02:21,180 --> 00:02:23,890
That does come up and you're wondering
what's going on, it's because challenge is

48
00:02:23,890 --> 00:02:28,930
selected, which was the last path and file
that was run in this project, so I can

49
00:02:28,930 --> 00:02:33,570
right-click the current source file run
fruit, and that will then work and then

50
00:02:33,570 --> 00:02:37,850
subsequently I can come in here and select
fruit or just make sure that's selected.

51
00:02:37,850 --> 00:02:41,070
But okay, in this example you
can see that we've successfully

52
00:02:41,070 --> 00:02:43,910
created two dictionaries and
they're separate as you can see.

53
00:02:43,910 --> 00:02:46,650
One's got fruit and
other has got vegetables.

54
00:02:46,650 --> 00:02:47,660
So that's working fine.

55
00:02:47,660 --> 00:02:50,390
But we can actually
combine those together.

56
00:02:50,390 --> 00:02:54,100
Using the update method, and when we do
that we pass the other one as a parameter.

57
00:02:54,100 --> 00:02:58,100
So we can do something like
this veg.update(fruit) and

58
00:02:59,230 --> 00:03:03,160
that's adding the fruit
dictionary to the veg dictionary.

59
00:03:03,160 --> 00:03:10,620
So we then print that out and run that You
can see now on that third line of output,

60
00:03:10,620 --> 00:03:16,160
you've got all the entries, and you can
see there we've also got sprouts there.

61
00:03:16,160 --> 00:03:18,830
Cabbage there, etcetera.

62
00:03:18,830 --> 00:03:19,970
So we've got both of them combined.

63
00:03:19,970 --> 00:03:23,170
So that's a really handy command
if you've got two dictionaries and

64
00:03:23,170 --> 00:03:24,940
you just want to combine them together.

65
00:03:24,940 --> 00:03:27,380
There of course is nothing
stopping us from also doing this.

66
00:03:27,380 --> 00:03:31,340
We could have done fruit.update And

67
00:03:31,340 --> 00:03:35,860
that is added to the fruit dictionary so
I obviously left this example line 13 add

68
00:03:35,860 --> 00:03:40,800
the veg dictionary to fruit, I am going to
take that again and the entry on line 15,

69
00:03:40,800 --> 00:03:44,770
of course that is adding
the fruit dictionary To veg.

70
00:03:44,770 --> 00:03:46,370
Now, the method returns none.

71
00:03:46,370 --> 00:03:49,800
And if you remember from our
discussions of the list sort method,

72
00:03:49,800 --> 00:03:54,720
a new list isn't returned when you call
sort, and with dictionary update method,

73
00:03:54,720 --> 00:03:56,640
a new dictionary is not returned either.

74
00:03:56,640 --> 00:03:59,910
So, the reason that we've talked about
this and mentioned this a few times

75
00:03:59,910 --> 00:04:03,620
is primarily for people who are used
to other programming languages and

76
00:04:03,620 --> 00:04:05,350
may expect a new object to be returned.

77
00:04:05,350 --> 00:04:07,930
But just to confirm that,
if I do something like this,

78
00:04:09,350 --> 00:04:14,060
Print is what I'll do,
I'll do at the end here, and then here.

79
00:04:15,640 --> 00:04:21,110
I can do, print (fruit.update (veg)),

80
00:04:21,110 --> 00:04:25,880
then I can do print(fruit).

81
00:04:25,880 --> 00:04:30,600
So we actually run that You see
the first line we got none.

82
00:04:30,600 --> 00:04:34,470
And the second line you can see
we've clearly got fruit and

83
00:04:34,470 --> 00:04:36,290
some vegetables in there.

84
00:04:36,290 --> 00:04:38,430
So, very important to remember
it doesn't return anything.

85
00:04:38,430 --> 00:04:42,910
You know if you wanted to create a new
dictionary that contained all the items

86
00:04:42,910 --> 00:04:46,920
say from fruit and veg, but you didn't
wanna modify the original dictionaries.

87
00:04:46,920 --> 00:04:51,160
Then instead of using update it's a better
option to use the copy method instead.

88
00:04:51,160 --> 00:04:54,590
So we could do something like this,
we could put,

89
00:04:54,590 --> 00:04:58,520
nice and nasty equals fruit dot copy.

90
00:04:58,520 --> 00:05:02,630
And we could do nice and nasty dot update.

91
00:05:02,630 --> 00:05:07,540
(veg) print (nice and

92
00:05:07,540 --> 00:05:13,370
nasty) and
just comment some of these lines out, so

93
00:05:14,820 --> 00:05:20,130
if you run that now, you can see that
clearly there we've done the .copy and

94
00:05:20,130 --> 00:05:24,150
then the.update and so that last line you
can see were really got 'sprouts' in there

95
00:05:24,150 --> 00:05:26,310
And fruit, so we've got fruit and
vegetables, so

96
00:05:26,310 --> 00:05:30,870
let's combine them again, creating
a new dictionary called nice and nasty.

97
00:05:30,870 --> 00:05:34,760
And fruit and veg, both of those
dictionaries weren't modified at all, and

98
00:05:34,760 --> 00:05:36,670
so, as confirmation, nice and

99
00:05:36,670 --> 00:05:40,660
nasty, that dictionary now
contains all the items from both.

100
00:05:40,660 --> 00:05:45,530
And just to confirm that,
you can do print veg dot fruit.

101
00:05:46,880 --> 00:05:47,380
And run that.

102
00:05:48,460 --> 00:05:49,360
And that should confirm.

103
00:05:49,360 --> 00:05:52,540
You have vegetables on
the second to last line there.

104
00:05:52,540 --> 00:05:53,500
And it's only vegetables and

105
00:05:53,500 --> 00:05:58,600
then the last line you can see
scrolling over, that's all fruit.

106
00:05:58,600 --> 00:06:01,040
There's no vegetables.

107
00:06:01,040 --> 00:06:02,970
So that's a good way if you wanna copy.

108
00:06:02,970 --> 00:06:05,140
One example,
one that's gonna be extremely useful.

109
00:06:05,140 --> 00:06:08,710
What we're gonna do is make some
improvements to the user interface of our

110
00:06:08,710 --> 00:06:09,890
adventure game.

111
00:06:09,890 --> 00:06:13,400
So I'm gonna go back to the challenge,
and I'm going to copy all of this.

112
00:06:15,940 --> 00:06:19,590
We're just gonna create a new folder just
to preserve that source code if you need

113
00:06:19,590 --> 00:06:23,610
to go back to New > Python,
we'll just call this one game.

114
00:06:25,560 --> 00:06:26,790
I'm gonna paste that code in again,

115
00:06:26,790 --> 00:06:30,540
that was the last code from the challenge
That we did in the last video.

116
00:06:30,540 --> 00:06:33,380
So I think that's something
that would be extremely useful.

117
00:06:33,380 --> 00:06:36,360
We've gotta change the user
interface of this adventure game.

118
00:06:36,360 --> 00:06:39,830
And wouldn't it be useful if players
could enter the name of the location

119
00:06:39,830 --> 00:06:41,430
rather than a direction?

120
00:06:41,430 --> 00:06:45,150
So I'm still allowing them to go there if
there's an exit from the current location.

121
00:06:45,150 --> 00:06:48,050
In other words, an account temper
of the map, but for example,

122
00:06:48,050 --> 00:06:51,180
it would allow them to type hill from the
road instead of west to get to the hill.

123
00:06:51,180 --> 00:06:54,950
So the easiest way to implement the change
with the current count we've got

124
00:06:54,950 --> 00:06:59,100
is to extend the vocabulary dictionary
to include the location names.

125
00:06:59,100 --> 00:07:01,040
So what we're gonna do is extend that.

126
00:07:01,040 --> 00:07:03,480
So we're still gonna leave
in our other directions.

127
00:07:03,480 --> 00:07:08,790
But if we then go back in there and
put in So road 1

128
00:07:12,430 --> 00:07:17,520
and what's this going to be called now?

129
00:07:21,530 --> 00:07:25,530
Hill 2 building

130
00:07:27,330 --> 00:07:32,310
3 valley It's gonna be four and

131
00:07:32,310 --> 00:07:35,990
forest.

132
00:07:35,990 --> 00:07:38,460
Five.

133
00:07:38,460 --> 00:07:41,150
But the thing is we can't use
a direction as the value.

134
00:07:41,150 --> 00:07:44,260
Although Talking road from
the forest moved south

135
00:07:44,260 --> 00:07:47,040
talking road from the building moved west,
and

136
00:07:47,040 --> 00:07:51,290
from the valley north so one solution that
keeps maintenance of the exits dictionary

137
00:07:51,290 --> 00:07:55,620
simple is to use the location number
of street, then For the valley.

138
00:07:55,620 --> 00:07:58,030
Then we have destination of
one of the exits dictionary.

139
00:07:58,030 --> 00:08:00,500
We just had another entry one, one so

140
00:08:00,500 --> 00:08:03,230
we can maintain the exits without
checking the map each time.

141
00:08:03,230 --> 00:08:07,190
And again, that's easy to see and
to not actually describe.

142
00:08:07,190 --> 00:08:08,680
So let's go ahead and update that now.

143
00:08:08,680 --> 00:08:10,300
So what we need to do.

144
00:08:10,300 --> 00:08:12,550
It's for each location we need to
put in the corresponding number.

145
00:08:12,550 --> 00:08:15,150
So for number 2 here we've got west 2.

146
00:08:15,150 --> 00:08:21,870
What we then need to do is put 2:2.

147
00:08:21,870 --> 00:08:27,710
East will be 3:3,

148
00:08:27,710 --> 00:08:34,970
North is going to be 5: five and south.

149
00:08:34,970 --> 00:08:39,909
You guessed it 4:4 then we don't
need to do anything with qui,

150
00:08:39,909 --> 00:08:42,080
so we'll leave that as it is.

151
00:08:42,080 --> 00:08:46,000
So likewise for location two,
we need to also put in a five here.

152
00:08:46,000 --> 00:08:49,700
So five is the key and
five is the location.

153
00:08:50,900 --> 00:08:58,470
The third one, for west we're going
to put 1, 1 for the location.

154
00:08:58,470 --> 00:09:04,240
And for location 4 we're gonna do
the same, we're gonna put 1, column 1.

155
00:09:04,240 --> 00:09:09,430
And the second one after west
we're gonna put 2 column 2,

156
00:09:09,430 --> 00:09:11,830
we're gonna leave quid in there.

157
00:09:11,830 --> 00:09:16,560
And on the last line,
we need to put "2": 2.

158
00:09:16,560 --> 00:09:20,300
"2" being the key, 2 being the location.

159
00:09:20,300 --> 00:09:24,060
And cuz we're going south,
we also need to add a "1": 1, as well.

160
00:09:24,060 --> 00:09:27,750
So essentially,
the corresponding direction, we've

161
00:09:27,750 --> 00:09:32,870
also added that number into it as well, so
that it matches up WIth our vocabulary.

162
00:09:32,870 --> 00:09:35,630
So, if you go ahead now and
run this, and I'm gonna change this,

163
00:09:35,630 --> 00:09:39,400
we need to right-click first,
actually, and click run game.

164
00:09:39,400 --> 00:09:43,070
I think we still should be able
to type in so south, north,

165
00:09:43,070 --> 00:09:46,000
so we should always be
able to type in valley.

166
00:09:46,000 --> 00:09:48,910
That takes us to a valley.

167
00:09:48,910 --> 00:09:53,030
And road,
to take us back to where we were before,

168
00:09:53,030 --> 00:09:58,000
and we can still get--could still So
that's pretty neat.

169
00:09:58,000 --> 00:09:59,870
So providing there's an exit tour,

170
00:09:59,870 --> 00:10:04,670
we're able to type in the destination name
to get there from our current location.

171
00:10:04,670 --> 00:10:06,840
Now there is actually
an issue with this though.

172
00:10:06,840 --> 00:10:09,970
So the list of available
exits from a location,

173
00:10:09,970 --> 00:10:14,350
As you know is built up from the keys of
the exits dictionary for that location.

174
00:10:14,350 --> 00:10:18,200
So now that we've added the extra
entries to the dictionary,

175
00:10:18,200 --> 00:10:20,590
we end up with a load of numbers
in the value of x's list.

176
00:10:20,590 --> 00:10:23,730
And just to run that again, 4352, etc.

177
00:10:23,730 --> 00:10:27,110
You can see these extra numbers
that are being added there.

178
00:10:27,110 --> 00:10:29,050
Now we do have a problem with this,
though.

179
00:10:29,050 --> 00:10:31,910
The list of available x's from a location

180
00:10:31,910 --> 00:10:36,240
As you can see it's built up from
the keys of the exits dictionary.

181
00:10:36,240 --> 00:10:41,700
So we're using this to go through, we're
cycling through the line 42, the keys

182
00:10:41,700 --> 00:10:47,770
dictionary or the exits dictionary and
building up a list of available exits.

183
00:10:47,770 --> 00:10:49,220
So consequently of course when we run it,

184
00:10:49,220 --> 00:10:55,030
which you saw when I run it previously
We've got now all these numbers and

185
00:10:55,030 --> 00:10:58,120
they're 4, 3, 2,
5 as well as valid directions.

186
00:10:58,120 --> 00:11:00,230
Now that's actually a problem,
it doesn't look good.

187
00:11:00,230 --> 00:11:05,360
So what we really need to do is store the
nine destinations in a separate dictionary

188
00:11:05,360 --> 00:11:07,920
then combine then at the point
when we check the players input.

189
00:11:07,920 --> 00:11:10,790
And what we actually wanna do here,
I'll just connect that.

190
00:11:10,790 --> 00:11:13,380
Cuz you really wanna undo those
changes that we've made and

191
00:11:13,380 --> 00:11:14,950
create a combined directory.

192
00:11:14,950 --> 00:11:16,360
So am gonna undo this.

193
00:11:16,360 --> 00:11:20,200
The easiest way for me to fix this,
is to go back and just copy and

194
00:11:20,200 --> 00:11:21,260
paste from our old challenge.

195
00:11:21,260 --> 00:11:26,170
So am gonna copy the old exits And
I'll paste that in.

196
00:11:26,170 --> 00:11:27,910
Go back to our game.

197
00:11:27,910 --> 00:11:29,640
Pi file, paste that in.

198
00:11:29,640 --> 00:11:31,640
So we're left now with our original exits.

199
00:11:31,640 --> 00:11:34,240
So what we want to do is add
a new dictionary called name dex,

200
00:11:34,240 --> 00:11:37,670
that contains those numbers
that we've just removed.

201
00:11:37,670 --> 00:11:41,500
So, name x's equals 1.

202
00:11:41,500 --> 00:11:45,440
2 colon 2.

203
00:11:45,440 --> 00:11:49,360
3 colon three.

204
00:11:49,360 --> 00:11:53,320
Five: five and

205
00:11:53,320 --> 00:11:57,280
four colon four.

206
00:11:57,280 --> 00:12:00,380
So that's our first dictionary for
the location one.

207
00:12:00,380 --> 00:12:05,100
Location two, we only had the one,
and that was to location five.

208
00:12:08,120 --> 00:12:12,370
Location three, we only had one again.

209
00:12:14,870 --> 00:12:18,020
1, 4, we had a couple.

210
00:12:19,760 --> 00:12:22,650
We 1, 1 and also 2, 2.

211
00:12:22,650 --> 00:12:28,920
And lastly, location five Also had 2 so

212
00:12:28,920 --> 00:12:36,540
2:2 1:1 like so, so that's our NamedExits,

213
00:12:36,540 --> 00:12:41,350
so what we wanna do then is create a
combined directory Copy of the location's

214
00:12:41,350 --> 00:12:46,140
exit dictionary and updating it to
include the appropriate named exits.

215
00:12:46,140 --> 00:12:49,430
But there's no point doing all that
work if the player's charging to quit.

216
00:12:49,430 --> 00:12:51,890
So what we're going to do is add
an else clause to the check for

217
00:12:51,890 --> 00:12:55,260
location zero and
prepare our combined dictionary there.

218
00:12:55,260 --> 00:12:57,980
So down here if loc equals zero, break.

219
00:12:57,980 --> 00:13:00,030
And I'm going to add an else.

220
00:13:00,030 --> 00:13:03,460
If it's not location zero, which means
we're still moving to another room.

221
00:13:03,460 --> 00:13:10,640
And we're gonna type
allExits=exits(loc).copy,

222
00:13:10,640 --> 00:13:13,900
so I'm grabbing a copy
of that dictionary and

223
00:13:13,900 --> 00:13:23,070
allExits.update(namedExits[loc]), so

224
00:13:23,070 --> 00:13:25,510
we're grabbing a copy of all the exits

225
00:13:25,510 --> 00:13:28,710
That count in the exits
directory from here.

226
00:13:28,710 --> 00:13:32,790
And then what we're doing, and that's for
that particular location, and then so

227
00:13:32,790 --> 00:13:34,480
we've created a copy of that.

228
00:13:34,480 --> 00:13:34,980
It's on line 55.

229
00:13:34,980 --> 00:13:38,080
And then line 56 what we're
doing is we're updating it.

230
00:13:38,080 --> 00:13:42,230
So we're grabbing a copy of
the appropriate entries from the name

231
00:13:42,230 --> 00:13:46,860
dictionary for that location, and adding
to the new dictionary, which is all x's,

232
00:13:46,860 --> 00:13:48,070
which we've created.

233
00:13:48,070 --> 00:13:53,790
So consequently, now, instead of here on
line 68, checking for the x's location,

234
00:13:53,790 --> 00:13:59,170
at the x's current location,
we can change that and test for all x's.

235
00:14:00,270 --> 00:14:02,770
So we're just checking to see
whether our direction's in allExits.

236
00:14:02,770 --> 00:14:07,590
And of course, allExits contains both
the directions, north, south, east,

237
00:14:07,590 --> 00:14:12,040
west, but also the other locations,
the actual numbers, as well.

238
00:14:12,040 --> 00:14:18,260
And of course allExits again, we confirmed
now is the west, north, east, west, etc.

239
00:14:18,260 --> 00:14:22,250
But also the named exits
as in the numbers as well,

240
00:14:22,250 --> 00:14:25,460
allowing us to use that vocabulary for
that purpose.

241
00:14:25,460 --> 00:14:28,290
And the other thing to note is of course
we don't need to change anything here.

242
00:14:28,290 --> 00:14:32,880
So line 48, the available exits is
now going to correctly look at just

243
00:14:32,880 --> 00:14:36,870
the location, the exits for that
particular location, and it's not going to

244
00:14:36,870 --> 00:14:40,010
include any of those numbers that
we saw when we previously ran it.

245
00:14:40,010 --> 00:14:44,350
So now if we run this, You'll notice
now that the numbers have gone.

246
00:14:44,350 --> 00:14:47,540
We should be able to just
use our normal items.

247
00:14:47,540 --> 00:14:49,430
So what I'll do is we'll quit out of
that again and we'll run it again.

248
00:14:49,430 --> 00:14:51,490
Just to the same as what
we've been doing before.

249
00:14:51,490 --> 00:14:57,250
So south, north, road,
should be at the top road.

250
00:14:57,250 --> 00:15:00,950
Nothing will happen cuz we're already
there, but we can type, valley.

251
00:15:01,950 --> 00:15:04,340
And we got an error there.

252
00:15:04,340 --> 00:15:06,650
So it's probably a good time
to actually debug this.

253
00:15:06,650 --> 00:15:08,630
That's line 69 that's failing.

254
00:15:08,630 --> 00:15:14,090
And I suspect what I've done is I've coded
something incorrectly, one of the keys.

255
00:15:14,090 --> 00:15:17,330
And what I failed to do,
if we look at it, actually line 69,

256
00:15:17,330 --> 00:15:20,060
probably should have looked
at the error straightaway.

257
00:15:20,060 --> 00:15:22,470
If you look at that carefully,
lines 68 and 69,

258
00:15:22,470 --> 00:15:25,390
you can probably see what I've done.

259
00:15:25,390 --> 00:15:28,420
So we're looking in our
dictionary all exits

260
00:15:28,420 --> 00:15:31,450
then trying to retrieve
a location from the exits.

261
00:15:31,450 --> 00:15:35,670
So consequently, the code's gonna
work fine if we use west, north,

262
00:15:35,670 --> 00:15:38,730
east, south etc using
those sorta locations.

263
00:15:38,730 --> 00:15:40,920
But soon as we start typing in
the number it's gonna exit,

264
00:15:40,920 --> 00:15:43,240
it's going to crash rather
Because it doesn't exist.

265
00:15:43,240 --> 00:15:47,500
So what I should have done
there was make that all exits.

266
00:15:47,500 --> 00:15:51,810
And that should fix it, so we should
be able to run that again now, and

267
00:15:51,810 --> 00:15:56,690
still we have to go south, north, but
now we should be able to go valley,

268
00:15:56,690 --> 00:15:59,860
and go back to road.

269
00:16:01,370 --> 00:16:03,890
And if we just type road again we should
get an error because we can't go in

270
00:16:03,890 --> 00:16:04,680
that direction.

271
00:16:04,680 --> 00:16:08,390
So as you can see, update and copy,
really two very useful commands.

272
00:16:08,390 --> 00:16:11,820
So we've covered quite a lot of important
concepts in the discussion overall,

273
00:16:11,820 --> 00:16:12,940
of dictionaries.

274
00:16:12,940 --> 00:16:16,590
And it's gone over, now, quite a few
videos, including the way that we've

275
00:16:16,590 --> 00:16:20,110
related different data structures
by using the location,

276
00:16:20,110 --> 00:16:24,850
the loc variable to access entries in
both the locations and exits structures.

277
00:16:24,850 --> 00:16:29,490
And this is only one was to represent
allocations and keep that in mind.

278
00:16:29,490 --> 00:16:32,250
So our net could be modeled in very
different ways so keep that in mind and

279
00:16:32,250 --> 00:16:35,060
we could have used lists instead
of dictionaries for example.

280
00:16:35,060 --> 00:16:39,450
Now dictionaries have the advantage that
insertion and deletion are extremely fast.

281
00:16:39,450 --> 00:16:41,000
And that's of little relevance here,

282
00:16:41,000 --> 00:16:45,130
because we're not using those operations
but access by key is also extremely fast,

283
00:16:45,130 --> 00:16:47,160
which will be very useful for
a game like this.

284
00:16:47,160 --> 00:16:48,890
So I'm gonna finish the video here now.

285
00:16:48,890 --> 00:16:51,610
In the next video we're going
to go through another challenge.

286
00:16:51,610 --> 00:16:55,270
We're going to challenge around
a standing of dictionaries.

287
00:16:55,270 --> 00:16:56,290
So see you in the next video.

