1
00:00:05,760 --> 00:00:09,120
Hi, welcome to this new week.

2
00:00:09,120 --> 00:00:12,210
We're going to continue
working on a new project.

3
00:00:12,210 --> 00:00:14,560
This is going to
be our Project 4,

4
00:00:14,560 --> 00:00:17,515
and we're going to be working
on a pathfinding system.

5
00:00:17,515 --> 00:00:20,080
We are going to be understanding

6
00:00:20,080 --> 00:00:22,380
first what a
pathfinding system is.

7
00:00:22,380 --> 00:00:24,800
A pathfinding, it's a
computational problem

8
00:00:24,800 --> 00:00:27,890
solving approach where we
would actually have agreed.

9
00:00:27,890 --> 00:00:29,840
In this case, as you
can see on the right,

10
00:00:29,840 --> 00:00:32,220
we're going to
have a start note,

11
00:00:32,220 --> 00:00:34,460
and we're going to try to
figure out what would be

12
00:00:34,460 --> 00:00:38,905
the path that would take us
to an end node or a target.

13
00:00:38,905 --> 00:00:44,060
That maybe straightforward
if we're doing it visually,

14
00:00:44,060 --> 00:00:45,800
but we want to
calculate what would be

15
00:00:45,800 --> 00:00:49,160
the optimal path
between these units,

16
00:00:49,160 --> 00:00:51,460
e specially if we
consider things like

17
00:00:51,460 --> 00:00:55,110
obstacles or certain tiles
that might not be accessible.

18
00:00:55,110 --> 00:00:57,220
It's a really interesting
algorithm that

19
00:00:57,220 --> 00:00:59,580
might able to solve a labyrinth
or something like that,

20
00:00:59,580 --> 00:01:01,925
but it has a whole
range of applications.

21
00:01:01,925 --> 00:01:03,340
Also, we learned that there's

22
00:01:03,340 --> 00:01:04,760
different computational
techniques

23
00:01:04,760 --> 00:01:06,180
of how to solve this problem.

24
00:01:06,180 --> 00:01:08,500
Some of them are maybe
more brute force,

25
00:01:08,500 --> 00:01:10,020
and they actually take

26
00:01:10,020 --> 00:01:11,540
a lot of time to
actually calculate,

27
00:01:11,540 --> 00:01:13,040
and some others actually taking

28
00:01:13,040 --> 00:01:15,580
consideration some
methods that may

29
00:01:15,580 --> 00:01:17,580
speed up the computation
and make it to

30
00:01:17,580 --> 00:01:20,210
a solution very quickly.

31
00:01:20,210 --> 00:01:22,695
There's a whole range
of interesting ideas

32
00:01:22,695 --> 00:01:25,915
that could be learned
from this project.

33
00:01:25,915 --> 00:01:29,080
We will start in the
first few lessons,

34
00:01:29,080 --> 00:01:31,000
building an environment
that we can customize,

35
00:01:31,000 --> 00:01:35,460
something that we could actually
adapt, paint, and draw.

36
00:01:35,460 --> 00:01:38,220
It's very similar to what
we've been doing with grits.

37
00:01:38,220 --> 00:01:39,740
But we're going
to be structuring

38
00:01:39,740 --> 00:01:41,980
that as an environment
in which we could use as

39
00:01:41,980 --> 00:01:44,500
a playground for our
pathfinding algorithm

40
00:01:44,500 --> 00:01:46,670
to play and execute.

41
00:01:46,670 --> 00:01:49,750
Let's start building
it up from scratch.

42
00:01:49,750 --> 00:01:52,430
I'm going to jump
into our code here.

43
00:01:52,430 --> 00:01:54,220
I'm starting from
an empty project.

44
00:01:54,220 --> 00:01:55,830
As you can see here, we have

45
00:01:55,830 --> 00:01:59,010
mostly our template
starting point.

46
00:01:59,010 --> 00:02:01,140
We have been using
this template before,

47
00:02:01,140 --> 00:02:03,015
and I'm going to
start with a new tab,

48
00:02:03,015 --> 00:02:06,670
which I'm going to call tiles.

49
00:02:07,910 --> 00:02:11,830
Let's import randomness.

50
00:02:14,840 --> 00:02:17,190
This is going to be a class,

51
00:02:17,190 --> 00:02:19,920
but it's going to
be a class called

52
00:02:19,920 --> 00:02:29,050
tile and it's going
to be a constructor.

53
00:02:29,050 --> 00:02:31,380
Basically, what the tile is

54
00:02:31,380 --> 00:02:35,440
is each cell in the grids
going to be a tile.

55
00:02:35,440 --> 00:02:37,920
It's going to be useful to
have this tile because we

56
00:02:37,920 --> 00:02:40,180
can embed information
like, are you a wall?

57
00:02:40,180 --> 00:02:41,640
Are you a floor?

58
00:02:41,640 --> 00:02:43,480
Are you a resource?
Are you water?

59
00:02:43,480 --> 00:02:45,280
We might not use
all those types,

60
00:02:45,280 --> 00:02:46,960
but we could actually
start thinking, oh,

61
00:02:46,960 --> 00:02:50,100
this could be actually a
tiling system as it's been

62
00:02:50,100 --> 00:02:54,465
used in video games or
other environments.

63
00:02:54,465 --> 00:02:57,260
Some of those tiles might
have a property of being

64
00:02:57,260 --> 00:02:59,725
an obstacle or not
being an obstacle,

65
00:02:59,725 --> 00:03:01,595
being something that
you can walk on.

66
00:03:01,595 --> 00:03:03,720
We will eventually be

67
00:03:03,720 --> 00:03:05,320
able to store data
in this file like,

68
00:03:05,320 --> 00:03:08,050
has this style been visited
or not, or things like that.

69
00:03:08,050 --> 00:03:14,220
Let's just start this constructor
by defining a position.

70
00:03:14,220 --> 00:03:16,375
What's going to be important?

71
00:03:16,375 --> 00:03:24,010
We're going to define a
cell size and a type.

72
00:03:24,010 --> 00:03:27,520
For now, that type might
be just two types,

73
00:03:27,520 --> 00:03:29,550
but we might have
different ones.

74
00:03:29,550 --> 00:03:33,080
Self taught position
equals position.

75
00:03:40,490 --> 00:03:43,185
It's a cell size.

76
00:03:43,185 --> 00:03:45,750
That's two types.

77
00:03:45,750 --> 00:03:50,660
Here, I'm going to
create a variable

78
00:03:50,660 --> 00:03:51,880
of the possible types,

79
00:03:51,880 --> 00:03:55,430
and I'm going to define
that as a tuple.

80
00:03:55,980 --> 00:04:01,050
Types plural, we're
going to say this could

81
00:04:01,050 --> 00:04:06,130
be floor or this
could be a wall,

82
00:04:06,710 --> 00:04:11,560
or this could be a resource,

83
00:04:13,190 --> 00:04:18,225
or this could be water
just to give some ideas.

84
00:04:18,225 --> 00:04:20,850
Again, if you think again of

85
00:04:20,850 --> 00:04:25,190
a 2D overview of an environment,

86
00:04:25,190 --> 00:04:27,710
you could start
imagining all tile types

87
00:04:27,710 --> 00:04:29,255
that you might
want to have here.

88
00:04:29,255 --> 00:04:32,910
What we're going to call
the self.current_type.

89
00:04:35,540 --> 00:04:38,160
It's going to be provided
by the constructor.

90
00:04:38,160 --> 00:04:40,395
Type is going to be

91
00:04:40,395 --> 00:04:44,085
the current type of
tile that we're using.

92
00:04:44,085 --> 00:04:45,820
If we say zero, it's
going to be floor,

93
00:04:45,820 --> 00:04:48,520
if we say one, it's going
to be wall, and so on.

94
00:04:48,520 --> 00:04:50,960
Let's also anticipate that

95
00:04:50,960 --> 00:04:52,580
we're going to be using
this a bit later,

96
00:04:52,580 --> 00:04:56,940
but we're going to
say is obstacle.

97
00:05:01,020 --> 00:05:03,640
This is going to be a Boolean,

98
00:05:03,640 --> 00:05:09,655
we're going to say it false
at the moment. That's it.

99
00:05:09,655 --> 00:05:12,610
We're going to continue
adding some variables

100
00:05:12,610 --> 00:05:15,550
to this class later
down the line.

101
00:05:15,550 --> 00:05:17,830
But I think for something
that we could actually see in

102
00:05:17,830 --> 00:05:20,665
the screen, this
should be enough.

103
00:05:20,665 --> 00:05:23,575
Let's just do one function
that will run the tiles.

104
00:05:23,575 --> 00:05:28,960
The run function as we have
been doing for many others.

105
00:05:28,960 --> 00:05:31,225
I'd like here using
this as an outline

106
00:05:31,225 --> 00:05:33,445
of the functions that
I'm going to be using.

107
00:05:33,445 --> 00:05:36,550
I'm going to just use
self taught display,

108
00:05:36,550 --> 00:05:38,860
which is a function
that we don't have yet,

109
00:05:38,860 --> 00:05:39,940
so let's just write it.

110
00:05:39,940 --> 00:05:43,670
So def display.

111
00:05:48,090 --> 00:05:51,460
Here, what we want
to do is just to

112
00:05:51,460 --> 00:05:54,160
have a very simple distinction.

113
00:05:54,160 --> 00:05:56,600
We want to do a rectangle.

114
00:05:56,700 --> 00:06:00,565
Most grid systems actually
operate with a rectangle.

115
00:06:00,565 --> 00:06:02,965
I mean, you could be thinking
of an hexagonal grid.

116
00:06:02,965 --> 00:06:04,210
I mean, this algorithm
should be able to

117
00:06:04,210 --> 00:06:06,220
work with any kind of
grid configuration,

118
00:06:06,220 --> 00:06:07,570
and it could actually work for

119
00:06:07,570 --> 00:06:09,565
any kind of graph configuration.

120
00:06:09,565 --> 00:06:11,665
We'll see that if
you have a graph,

121
00:06:11,665 --> 00:06:13,495
we can think of this
grid as a graph.

122
00:06:13,495 --> 00:06:15,730
You could also think
of the algorithm

123
00:06:15,730 --> 00:06:17,290
running in a graph as

124
00:06:17,290 --> 00:06:19,510
long as you have sales

125
00:06:19,510 --> 00:06:21,550
or entities notes
that have neighbors.

126
00:06:21,550 --> 00:06:23,800
This should actually
be possible.

127
00:06:23,800 --> 00:06:32,140
Let's just say self.
position.x, self.

128
00:06:32,140 --> 00:06:41,365
position.y. Self.cell_ size

129
00:06:41,365 --> 00:06:44,900
and self size.

130
00:06:48,270 --> 00:06:52,135
We're drawing the rectangle,

131
00:06:52,135 --> 00:06:56,350
but we want to differentiate
it maybe just a feel.

132
00:06:56,350 --> 00:07:00,370
First is to a stroke of 0,50,

133
00:07:00,370 --> 00:07:04,105
which is zero black
50 transparency.

134
00:07:04,105 --> 00:07:05,830
You might want to
increase this a little

135
00:07:05,830 --> 00:07:07,315
bit if you want more contrast.

136
00:07:07,315 --> 00:07:11,920
But let's say if the self.

137
00:07:11,920 --> 00:07:15,480
types, because we're checking

138
00:07:15,480 --> 00:07:21,370
the types, self.current type.

139
00:07:24,420 --> 00:07:27,160
The current type is an index.

140
00:07:27,160 --> 00:07:29,140
It's an index to

141
00:07:29,140 --> 00:07:33,010
the different typologies
of tiles that we have.

142
00:07:33,010 --> 00:07:36,590
We're going to say
it's equals to floor,

143
00:07:36,960 --> 00:07:39,985
are we equal to floor?

144
00:07:39,985 --> 00:07:45,280
Then the feel will be white.

145
00:07:45,280 --> 00:07:47,710
Here we could say else.

146
00:07:47,710 --> 00:07:52,405
But I would like to
do an elif statement.

147
00:07:52,405 --> 00:07:54,340
Let's just copy
paste this because I

148
00:07:54,340 --> 00:07:56,350
think that this is something
that could be expanded.

149
00:07:56,350 --> 00:07:57,970
We might not expand
it too much here,

150
00:07:57,970 --> 00:07:59,380
but it's something that
I want to leave open

151
00:07:59,380 --> 00:08:00,820
for you to explore,

152
00:08:00,820 --> 00:08:04,790
if you want to expand
different tile types drawings.

153
00:08:06,240 --> 00:08:08,695
If the current type,

154
00:08:08,695 --> 00:08:11,690
in this case is wall.

155
00:08:11,700 --> 00:08:17,065
The wall, we're going to
draw them as a black tile,

156
00:08:17,065 --> 00:08:19,615
meaning that there's
kind of some visibility

157
00:08:19,615 --> 00:08:23,150
of the wall system.

158
00:08:24,840 --> 00:08:27,550
You could invert that
relationship if you want,

159
00:08:27,550 --> 00:08:30,700
if you're going to change
the color scheme to

160
00:08:30,700 --> 00:08:34,810
black over white,
that's your choice.

161
00:08:34,810 --> 00:08:38,995
We have a class, which is
our tile that is ready to be

162
00:08:38,995 --> 00:08:44,035
used by a system
or a environment.

163
00:08:44,035 --> 00:08:44,800
We're actually going to create

164
00:08:44,800 --> 00:08:45,865
a second class that's going to

165
00:08:45,865 --> 00:08:49,720
control and create a grid out
of a series of these tiles.

166
00:08:49,720 --> 00:08:52,390
We're going to create
that. Let's save,

167
00:08:52,390 --> 00:08:54,580
make sure that we're
saving what we're doing.

168
00:08:54,580 --> 00:08:58,160
We're going to create another
tab called environment.

169
00:09:00,660 --> 00:09:04,885
The environment is going to
be yet again another class.

170
00:09:04,885 --> 00:09:14,870
Let's import a randomness first.

171
00:09:17,790 --> 00:09:20,725
We are also going to be

172
00:09:20,725 --> 00:09:22,390
importing the tile because

173
00:09:22,390 --> 00:09:23,860
we're going to use the
tile for the grid.

174
00:09:23,860 --> 00:09:25,240
Let's just do that right away.

175
00:09:25,240 --> 00:09:27,025
From tiles.

176
00:09:27,025 --> 00:09:34,760
Remember that we call the file
tiles and the class tile.

177
00:09:36,300 --> 00:09:42,170
From tiles, it's
important class tile.

178
00:09:42,570 --> 00:09:46,670
Let's create our
class environment.

179
00:09:48,660 --> 00:09:53,950
This class, if you've
gone through this course,

180
00:09:53,950 --> 00:09:55,480
you know that we
have constructed

181
00:09:55,480 --> 00:09:57,590
things like this before.

182
00:09:59,940 --> 00:10:02,110
It's going to have a columns and

183
00:10:02,110 --> 00:10:05,380
rows and some reference
to the world,

184
00:10:05,380 --> 00:10:08,000
so we know how we can match

185
00:10:08,000 --> 00:10:11,770
our grid size to the
entirety of the screen.

186
00:10:11,770 --> 00:10:13,740
Let's start with self.

187
00:10:13,740 --> 00:10:17,620
We're going to need columns,
going to need rows,

188
00:10:17,620 --> 00:10:19,380
and we're going to
need a reference to

189
00:10:19,380 --> 00:10:23,000
the world size in x,

190
00:10:23,000 --> 00:10:27,240
and the world size in y.

191
00:10:28,670 --> 00:10:36,370
Now we can use prepare
those variables.

192
00:10:59,300 --> 00:11:02,940
Here, this is a very
important variable that

193
00:11:02,940 --> 00:11:05,760
it doesn't necessarily need
to come from the constructor,

194
00:11:05,760 --> 00:11:10,065
but we're going to
create our cells.

195
00:11:10,065 --> 00:11:13,110
The cells, it's going to be

196
00:11:13,110 --> 00:11:16,305
representing the list
of all the tiles.

197
00:11:16,305 --> 00:11:19,410
We can call them cells,
we can call them nodes.

198
00:11:19,410 --> 00:11:24,150
But for now, it's going
to be a single array,

199
00:11:24,150 --> 00:11:27,435
but we're going to use
slightly different structure

200
00:11:27,435 --> 00:11:28,470
from what we've been doing in

201
00:11:28,470 --> 00:11:31,230
the vector field exercise
where we were actually doing

202
00:11:31,230 --> 00:11:32,490
a flat array or

203
00:11:32,490 --> 00:11:34,620
flight list for the
entirety of the vectors.

204
00:11:34,620 --> 00:11:37,140
We're going to be
using a nested list.

205
00:11:37,140 --> 00:11:39,270
That's really to practice

206
00:11:39,270 --> 00:11:41,775
different forms of organizing
the data structure,

207
00:11:41,775 --> 00:11:43,890
and I think that it's going
to become a little bit more

208
00:11:43,890 --> 00:11:45,000
intuitive when we start doing

209
00:11:45,000 --> 00:11:46,840
a lot of work with neighbors.

210
00:11:46,840 --> 00:11:50,510
Hopefully, that serves

211
00:11:50,510 --> 00:11:54,200
for practicing different
ways of organizing agreed.

212
00:11:54,200 --> 00:11:56,290
I think we've covered
this difference,

213
00:11:56,290 --> 00:11:58,380
but I just wanted
to make sure that

214
00:11:58,380 --> 00:12:01,305
we have some explicit
description of that.

215
00:12:01,305 --> 00:12:06,270
In the self-run, we're
going to write the run I

216
00:12:06,270 --> 00:12:07,995
just always write
this function by

217
00:12:07,995 --> 00:12:11,370
default here. What
do we want to do?

218
00:12:11,370 --> 00:12:15,280
We want to basically
run the tiles, right?

219
00:12:21,320 --> 00:12:24,765
So we'll need a
function for that.

220
00:12:24,765 --> 00:12:27,870
But let's just come back
to this in a moment.

221
00:12:27,870 --> 00:12:31,065
I think I'm getting
ahead of myself.

222
00:12:31,065 --> 00:12:32,910
The first thing we need to do is

223
00:12:32,910 --> 00:12:36,330
make a function that
would initiate the cells.

224
00:12:36,330 --> 00:12:40,395
Because that cell array or
that cell list is empty.

225
00:12:40,395 --> 00:12:43,270
Let's just create that function.

226
00:12:43,640 --> 00:12:46,990
Initiate the cells.

227
00:12:47,150 --> 00:12:50,530
As we have done before,

228
00:12:51,110 --> 00:12:53,490
we need to do a four loop or

229
00:12:53,490 --> 00:12:54,840
a nested four loop that goes

230
00:12:54,840 --> 00:12:56,985
through egg columns and rows.

231
00:12:56,985 --> 00:13:00,270
But what would be useful here is

232
00:13:00,270 --> 00:13:04,995
to calculate the cell size.

233
00:13:04,995 --> 00:13:08,410
Let's start by that.
The cell size.

234
00:13:11,660 --> 00:13:15,930
It's going to do

235
00:13:15,930 --> 00:13:22,080
a float we're going

236
00:13:22,080 --> 00:13:25,680
to take a float version
of the size of the world,

237
00:13:25,680 --> 00:13:31,690
and we're going to divide it
by in the number of columns.

238
00:13:32,990 --> 00:13:36,360
I'm going to assume at this
point that the ratio of

239
00:13:36,360 --> 00:13:37,950
the screen and it's

240
00:13:37,950 --> 00:13:40,605
going to allow us to
do a square grid,

241
00:13:40,605 --> 00:13:43,770
you'll see that
we could actually

242
00:13:43,770 --> 00:13:46,830
have the tiles be asymmetric,

243
00:13:46,830 --> 00:13:49,390
but I'm going to work
with square tiles.

244
00:13:50,150 --> 00:13:53,355
Again, the system could be
a bit better prepared to do

245
00:13:53,355 --> 00:13:56,910
non-symmetrical tiles
or not square tiles.

246
00:13:56,910 --> 00:13:59,100
But for now, I think I'm
going to just stick to that.

247
00:13:59,100 --> 00:14:00,690
I'm only going to
calculate the cell size

248
00:14:00,690 --> 00:14:02,400
for one of the axes.

249
00:14:02,400 --> 00:14:05,310
So the world x divided
by the number of column.

250
00:14:05,310 --> 00:14:06,420
So we're dividing the size of

251
00:14:06,420 --> 00:14:08,160
the screen by the
number of columns

252
00:14:08,160 --> 00:14:13,905
we have, in range,

253
00:14:13,905 --> 00:14:19,770
so we're going to look
through the number of

254
00:14:19,770 --> 00:14:26,350
columns that we have as
create a bit more space here.

255
00:14:30,290 --> 00:14:39,780
In range, so self dot spend.

256
00:14:39,780 --> 00:14:43,120
We're going to append
an empty list.

257
00:14:45,170 --> 00:14:49,620
Here, instead of just going
through the loop twice,

258
00:14:49,620 --> 00:14:52,500
we're going to inside firstly,

259
00:14:52,500 --> 00:14:56,010
we're going to append
an empty list,

260
00:14:56,010 --> 00:14:57,855
and now we're going to

261
00:14:57,855 --> 00:15:11,910
do for range rose.

262
00:15:11,910 --> 00:15:15,910
The position, it's
going to be P vector.

263
00:15:17,380 --> 00:15:19,625
The vector that we really want

264
00:15:19,625 --> 00:15:23,045
to for the position of the tile,

265
00:15:23,045 --> 00:15:30,120
we have to think that it's
going to be in x j in y.

266
00:15:31,790 --> 00:15:37,500
But both of those ones to be
multiplied by the cell size.

267
00:15:37,500 --> 00:15:39,000
Because we want to give

268
00:15:39,000 --> 00:15:42,220
some separation
between those tiles.

269
00:15:44,410 --> 00:15:47,915
That's the position of the tile.

270
00:15:47,915 --> 00:15:49,220
Now we can actually construct

271
00:15:49,220 --> 00:15:51,540
the new tile. We
can say new tile.

272
00:15:52,030 --> 00:15:56,375
Because we've imported the
class tile, we can use it.

273
00:15:56,375 --> 00:15:57,515
So I say tile.

274
00:15:57,515 --> 00:15:59,855
If you remember the
constructor of the tile,

275
00:15:59,855 --> 00:16:04,295
requires a position a cell size,

276
00:16:04,295 --> 00:16:07,290
which we already
calculated here.

277
00:16:07,870 --> 00:16:10,970
Also requires a type.

278
00:16:10,970 --> 00:16:13,085
We're going to say zero for now.

279
00:16:13,085 --> 00:16:15,380
Because remember that
the type is an index,

280
00:16:15,380 --> 00:16:24,470
zero stands for the floor
and one stands for the wall.

281
00:16:24,470 --> 00:16:33,500
Let's just finally
say self.cells [i].

282
00:16:33,500 --> 00:16:37,230
append new tile.

283
00:16:37,870 --> 00:16:40,355
What we're doing here is saying,

284
00:16:40,355 --> 00:16:43,820
from this entry list that we
created within the columns,

285
00:16:43,820 --> 00:16:46,025
we are going to be appending

286
00:16:46,025 --> 00:16:50,105
an entry that is going
to be one of the rows.

287
00:16:50,105 --> 00:16:52,295
In this way, what
we're going to end up

288
00:16:52,295 --> 00:16:54,230
having is that
we're going to have

289
00:16:54,230 --> 00:16:57,290
two indices and the first index

290
00:16:57,290 --> 00:16:59,405
is accessing within the row,

291
00:16:59,405 --> 00:17:01,370
and the next one
is for the column,

292
00:17:01,370 --> 00:17:02,945
and then the next
one for the row.

293
00:17:02,945 --> 00:17:06,770
That would actually make
it a lot simpler to

294
00:17:06,770 --> 00:17:08,735
start looking at

295
00:17:08,735 --> 00:17:11,970
neighborhood calculations,
neighbor calculations.

296
00:17:12,010 --> 00:17:14,810
But let's see if this
is actually working.

297
00:17:14,810 --> 00:17:18,770
We're going to be calling
this initiate cells.

298
00:17:18,770 --> 00:17:22,175
Let's just call
it this function.

299
00:17:22,175 --> 00:17:25,745
Call it straight from
the constructor here.

300
00:17:25,745 --> 00:17:29,660
Initiate cells. Now,

301
00:17:29,660 --> 00:17:31,610
the only thing that
we're actually missing.

302
00:17:31,610 --> 00:17:33,725
Let's imagine that is
all working perfectly.

303
00:17:33,725 --> 00:17:35,870
We have initiated the cells,

304
00:17:35,870 --> 00:17:40,340
and now we want every
frame in processing,

305
00:17:40,340 --> 00:17:42,665
draw those cells
into the screen.

306
00:17:42,665 --> 00:17:46,880
Let's just do def run_tiles.

307
00:17:46,880 --> 00:17:50,885
Run cells. I think that
I'm using interchangeably.

308
00:17:50,885 --> 00:17:53,640
Cells and tiles.

309
00:17:54,940 --> 00:17:57,995
You might want to be a bit
more rigorous in your naming,

310
00:17:57,995 --> 00:18:00,350
but what we want to do,

311
00:18:00,350 --> 00:18:04,130
this type we have a
nested, at least,

312
00:18:04,130 --> 00:18:11,090
so for column in self.cells.

313
00:18:13,150 --> 00:18:15,935
The cell list contains,

314
00:18:15,935 --> 00:18:18,140
first of all, what we're
going to call a column,

315
00:18:18,140 --> 00:18:23,780
which is a list and
for cell in column.

316
00:18:23,780 --> 00:18:27,590
Within that column,
which is a list,

317
00:18:27,590 --> 00:18:34,920
we have entities that we would
call cells and cell.run.

318
00:18:35,440 --> 00:18:41,135
This would be finally
be this line here.

319
00:18:41,135 --> 00:18:45,515
Let's just execute the
running of the tiles.

320
00:18:45,515 --> 00:18:48,470
I think at this point, we
might have everything we need,

321
00:18:48,470 --> 00:18:54,065
we initiate the cells
using this empty list.

322
00:18:54,065 --> 00:18:58,655
Then every frame we
execute the run function,

323
00:18:58,655 --> 00:19:00,650
which is, if you remember here,

324
00:19:00,650 --> 00:19:02,840
is basically just their
display function,

325
00:19:02,840 --> 00:19:09,275
but we might be adding
more execution here later.

326
00:19:09,275 --> 00:19:11,690
In order to see if
this would work,

327
00:19:11,690 --> 00:19:16,505
let's just first of
all, import here.

328
00:19:16,505 --> 00:19:24,630
From environment,
import environment.

329
00:19:28,330 --> 00:19:34,620
We're going to call this
to global my environment.

330
00:19:36,730 --> 00:19:43,100
My environment, let's create
a new environment that

331
00:19:43,100 --> 00:19:53,040
is the environment of how
many columns, 120 by 60.

332
00:19:53,050 --> 00:19:56,975
I'm using basically one fraction

333
00:19:56,975 --> 00:19:58,670
of the size of the screen,

334
00:19:58,670 --> 00:20:03,305
just to have a good
match between those two.

335
00:20:03,305 --> 00:20:06,740
Here we can actually use the
variables of Canvas width,

336
00:20:06,740 --> 00:20:08,270
which is the size of the wall,

337
00:20:08,270 --> 00:20:12,645
Canvas width and Canvas height.

338
00:20:12,645 --> 00:20:14,590
I think that's everything
that the environment

339
00:20:14,590 --> 00:20:17,140
requires really to operate.

340
00:20:17,140 --> 00:20:20,870
Now, within the run,

341
00:20:21,210 --> 00:20:26,555
we can basically just
run the environment.

342
00:20:26,555 --> 00:20:29,810
Let's see where we
wrote some errors.

343
00:20:29,810 --> 00:20:31,850
We have some errors.

344
00:20:31,850 --> 00:20:34,710
Let's just figure those out.

345
00:20:35,770 --> 00:20:38,585
Yeah, so I found I think

346
00:20:38,585 --> 00:20:40,925
the errors were in
a couple of typos.

347
00:20:40,925 --> 00:20:46,255
I think that we had
misspelled here cells.

348
00:20:46,255 --> 00:20:48,920
It should be columns.

349
00:20:49,080 --> 00:20:54,760
The second one was here in I
think we're missing the Z.

350
00:20:54,760 --> 00:20:57,650
We had something like that.

351
00:20:57,940 --> 00:21:02,435
Finally, I did a small
change to the stroke

352
00:21:02,435 --> 00:21:05,270
transparency 50-150
just to make sure

353
00:21:05,270 --> 00:21:09,150
that we have some
visibility of the grid.

354
00:21:09,250 --> 00:21:11,975
Here, this is the environment.

355
00:21:11,975 --> 00:21:14,000
The resolution of this
environment now could

356
00:21:14,000 --> 00:21:16,640
change if you want
to use half of

357
00:21:16,640 --> 00:21:18,770
the resolution you
want to use and will

358
00:21:18,770 --> 00:21:22,590
be changing this resolution.

359
00:21:23,200 --> 00:21:28,385
It should always to
match the screen size.

360
00:21:28,385 --> 00:21:30,500
We're going to be
learning how to customize

361
00:21:30,500 --> 00:21:33,800
this environment further and

362
00:21:33,800 --> 00:21:36,140
start running the algorithm
in the videos that come.

363
00:21:36,140 --> 00:21:39,360
I'll see you in the next video.