1
00:00:05,240 --> 00:00:08,080
Hi, welcome to this new video

2
00:00:08,080 --> 00:00:10,620
on our ecosystem
simulation series.

3
00:00:10,620 --> 00:00:13,130
This is Week 3.

4
00:00:13,130 --> 00:00:15,180
We're going to
continue working on

5
00:00:15,180 --> 00:00:17,080
the behavior of our organisms.

6
00:00:17,080 --> 00:00:18,920
In this case, we're working
with the herbivore,

7
00:00:18,920 --> 00:00:22,970
and we're going to be
writing the wander behavior.

8
00:00:22,970 --> 00:00:26,460
You can probably find a
wander behavior online.

9
00:00:26,460 --> 00:00:29,140
There's lots of great
references of how to use

10
00:00:29,140 --> 00:00:32,475
a steering behavior to
define a wander motion,

11
00:00:32,475 --> 00:00:35,490
which is a form of randomness,

12
00:00:35,490 --> 00:00:37,290
but it has some oscillation,

13
00:00:37,290 --> 00:00:40,510
and it creates the
pattern of movement

14
00:00:40,510 --> 00:00:44,190
that might seem natural or a
sense of wandering around.

15
00:00:44,190 --> 00:00:45,910
But we're actually going to use

16
00:00:45,910 --> 00:00:48,600
the opportunity to write a
specific kind of wander that

17
00:00:48,600 --> 00:00:53,250
discretizes the different states

18
00:00:53,250 --> 00:00:55,770
that we can have

19
00:00:55,770 --> 00:00:58,210
to create something a
bit more expressive,

20
00:00:58,210 --> 00:01:01,885
something that might have
a sense of movement,

21
00:01:01,885 --> 00:01:06,930
hesitation, rotating,
moving again.

22
00:01:06,930 --> 00:01:09,610
We're going to look at
how we can actually

23
00:01:09,610 --> 00:01:12,205
start combining the
notion of a state machine

24
00:01:12,205 --> 00:01:18,285
just to move between
the wander state.

25
00:01:18,285 --> 00:01:20,510
The wander state is part
of the decision tree,

26
00:01:20,510 --> 00:01:22,010
we reach to the leaf node,

27
00:01:22,010 --> 00:01:24,075
which is an action wander.

28
00:01:24,075 --> 00:01:25,890
There's no reason
why that action

29
00:01:25,890 --> 00:01:27,230
needs to be one function.

30
00:01:27,230 --> 00:01:31,740
We can actually break it down
into its own state machine.

31
00:01:31,740 --> 00:01:34,110
A few states. The states
that we're going to be

32
00:01:34,110 --> 00:01:37,410
considering is idle,
so stay still.

33
00:01:37,410 --> 00:01:42,185
Then move forward for a few
seconds or a few frames,

34
00:01:42,185 --> 00:01:44,255
and then maybe
stand still again,

35
00:01:44,255 --> 00:01:46,125
rotate, move again.

36
00:01:46,125 --> 00:01:51,630
This loop between movement,
stopping, rotating.

37
00:01:51,630 --> 00:01:55,500
That would also similarly
create a wander behavior.

38
00:01:55,500 --> 00:01:57,590
I think that this
is where the design

39
00:01:57,590 --> 00:02:00,370
of your behaviors and the
expressivity that you want

40
00:02:00,370 --> 00:02:02,290
to achieve is very much part of

41
00:02:02,290 --> 00:02:03,810
your own design intuition

42
00:02:03,810 --> 00:02:06,200
and what you want
to communicate.

43
00:02:06,200 --> 00:02:08,610
If you're going for realism,

44
00:02:08,610 --> 00:02:11,420
this would be a very
different function.

45
00:02:11,420 --> 00:02:13,290
But we're going to use

46
00:02:13,290 --> 00:02:15,870
the opportunity to mix the
decision tree we been building

47
00:02:15,870 --> 00:02:21,050
and embed within a very
simple state machine

48
00:02:21,050 --> 00:02:23,060
to dictate the wander motion.

49
00:02:23,060 --> 00:02:25,950
Let's jump into processing
and see how we can do this.

50
00:02:25,950 --> 00:02:27,590
Let me bring you
to your attention.

51
00:02:27,590 --> 00:02:30,290
I'm working continuing
on the project.

52
00:02:30,290 --> 00:02:34,510
In the same project, we are
on the herbivore script.

53
00:02:34,510 --> 00:02:38,270
Mostly, we're going to be
doing most of the work here.

54
00:02:38,270 --> 00:02:44,010
We're at a point where the
decision tree takes us to

55
00:02:44,010 --> 00:02:46,890
the current function and by

56
00:02:46,890 --> 00:02:50,880
default because the
herbivore is not hungry.

57
00:02:50,880 --> 00:02:53,090
Currently, it's not hungry.

58
00:02:53,090 --> 00:02:55,625
It will default into wandering.

59
00:02:55,625 --> 00:02:58,835
The wander will go

60
00:02:58,835 --> 00:03:01,750
for a while until it
reaches a hunger level,

61
00:03:01,750 --> 00:03:04,350
and it transitions to sick food.

62
00:03:04,670 --> 00:03:07,810
For now, just because
we want to evaluate

63
00:03:07,810 --> 00:03:11,950
the wander behavior without
transitioning out of hunger,

64
00:03:11,950 --> 00:03:16,860
we can comment out
the transition.

65
00:03:16,860 --> 00:03:18,690
This is the line that

66
00:03:18,690 --> 00:03:21,250
resets and executes
the decision tree.

67
00:03:21,250 --> 00:03:22,520
We're going to bring
this back later.

68
00:03:22,520 --> 00:03:25,390
When we start moving to
the sick food function,

69
00:03:25,390 --> 00:03:27,760
which we're going to write
in the next few videos.

70
00:03:27,760 --> 00:03:31,760
But for now, we want to
write the wander state.

71
00:03:32,330 --> 00:03:37,560
Let's go up here and let's
declare a few variables that

72
00:03:37,560 --> 00:03:41,950
we're going to need to
work on the wander state.

73
00:03:41,950 --> 00:03:46,950
Wander states. Again,

74
00:03:46,950 --> 00:03:48,285
I'm going to be using some of

75
00:03:48,285 --> 00:03:51,165
a topple as a state machine.

76
00:03:51,165 --> 00:03:53,920
We're going to say
idle. It's going

77
00:03:53,920 --> 00:03:55,820
to be one of the
possible states.

78
00:03:55,820 --> 00:03:58,460
Another one will be moving,

79
00:03:58,840 --> 00:04:02,400
and another one
will be rotating.

80
00:04:07,700 --> 00:04:11,650
Then I'm also going to define

81
00:04:11,650 --> 00:04:17,370
the current action within
that state machine, self dot.

82
00:04:19,090 --> 00:04:22,310
I'm going to call
it current action.

83
00:04:22,310 --> 00:04:25,330
But maybe if you want
to be more explicit,

84
00:04:25,330 --> 00:04:29,325
you could say current wander
action. Let's just do that.

85
00:04:29,325 --> 00:04:33,960
Let's say the current
wander state.

86
00:04:33,960 --> 00:04:36,400
Zero means that
the current wander

87
00:04:36,400 --> 00:04:37,770
under state is going to be idle.

88
00:04:37,770 --> 00:04:41,080
Just stand still
for a few seconds.

89
00:04:41,360 --> 00:04:48,820
Then we're going to say
self.action duration.

90
00:04:53,220 --> 00:04:55,760
Let's start with a duration of

91
00:04:55,760 --> 00:05:04,380
200 and self.action count.

92
00:05:04,380 --> 00:05:06,580
Similar to what we've
been doing before,

93
00:05:06,580 --> 00:05:08,360
we're going to be

94
00:05:08,360 --> 00:05:10,790
counting. We're going
to start counting.

95
00:05:10,790 --> 00:05:15,310
When we reach to this
kind of threshold of 200,

96
00:05:15,310 --> 00:05:17,070
we're going to transition to

97
00:05:17,070 --> 00:05:20,510
the next state. We
could do random.

98
00:05:20,510 --> 00:05:22,290
But I think that in this case,

99
00:05:22,290 --> 00:05:23,610
because we have
such a simple loop,

100
00:05:23,610 --> 00:05:26,630
it's like we're going to
go from idle to moving to

101
00:05:26,630 --> 00:05:32,355
rotating to idle to moving
to rotating and so on.

102
00:05:32,355 --> 00:05:34,710
We're going to execute this kind

103
00:05:34,710 --> 00:05:37,770
of transition between states,

104
00:05:37,770 --> 00:05:39,870
and each one of
those are going to

105
00:05:39,870 --> 00:05:41,265
be very simple motions.

106
00:05:41,265 --> 00:05:43,050
This is going to be
just standing still.

107
00:05:43,050 --> 00:05:44,925
This is going to
be moving forward,

108
00:05:44,925 --> 00:05:47,520
and then it's just a rotation,

109
00:05:47,520 --> 00:05:49,950
basically changing
the orientation of

110
00:05:49,950 --> 00:05:53,070
our velocity into a
new random vector.

111
00:05:53,070 --> 00:05:56,415
We've broken down the behavior

112
00:05:56,415 --> 00:05:59,640
to such a degree that those
functions become very,

113
00:05:59,640 --> 00:06:02,860
very easy to write.

114
00:06:03,740 --> 00:06:08,025
We will start by
writing something,

115
00:06:08,025 --> 00:06:12,130
let's go down here,
we have wonder.

116
00:06:13,100 --> 00:06:15,690
Here, we're going to
define what we're going to

117
00:06:15,690 --> 00:06:20,170
call the wander actions.

118
00:06:25,250 --> 00:06:27,450
This is the function
that we're going to

119
00:06:27,450 --> 00:06:28,980
call here in the wander.

120
00:06:28,980 --> 00:06:33,120
But the wander actions
is going to help

121
00:06:33,120 --> 00:06:38,040
us change between the
different states.

122
00:06:38,040 --> 00:06:42,255
So we're going to say
if self.wander_states.

123
00:06:42,255 --> 00:06:48,195
Wander states are all
the possible states,

124
00:06:48,195 --> 00:06:52,080
and we're going to evaluate
the current one, so self,

125
00:06:52,080 --> 00:06:57,550
which is an index,
current_wander_state

126
00:07:00,680 --> 00:07:04,330
equals idle.

127
00:07:04,970 --> 00:07:10,305
If the current idle
state we're in is idle,

128
00:07:10,305 --> 00:07:14,010
we do something if

129
00:07:14,010 --> 00:07:20,500
we can copy the same
structure again here,

130
00:07:26,480 --> 00:07:33,310
and once more and then else,

131
00:07:37,280 --> 00:07:43,875
which shouldn't be an else

132
00:07:43,875 --> 00:07:46,335
because we're going
to look between them.

133
00:07:46,335 --> 00:07:50,520
The first condition is
the current state idle.

134
00:07:50,520 --> 00:07:52,065
The second one is moving,

135
00:07:52,065 --> 00:07:56,290
and the third one is rotating.

136
00:07:56,570 --> 00:07:59,430
That's what we spelled out,

137
00:07:59,430 --> 00:08:04,260
just make sure that rotating.

138
00:08:04,260 --> 00:08:08,290
If we didn't want to
have that problem,

139
00:08:09,320 --> 00:08:12,780
basically, what we could

140
00:08:12,780 --> 00:08:15,345
do much simpler than this is say

141
00:08:15,345 --> 00:08:18,580
if current wander state
is zero, one and two.

142
00:08:20,630 --> 00:08:27,375
But we're just trying to
connect the index with

143
00:08:27,375 --> 00:08:30,555
the actual behavior so
that we can actually have

144
00:08:30,555 --> 00:08:35,290
a more readable expression
of the code here.

145
00:08:36,950 --> 00:08:41,430
Here, we could say we're
going to need something

146
00:08:41,430 --> 00:08:46,330
like it's going to be self.idle.

147
00:08:46,970 --> 00:08:52,360
Here, it's going
to be self.move,

148
00:08:52,400 --> 00:09:04,750
and self.new_rotation.

149
00:09:09,710 --> 00:09:13,260
Those are going to be functions
we're going to write.

150
00:09:13,260 --> 00:09:15,900
The other thing that
will need to happen,

151
00:09:15,900 --> 00:09:17,160
and I think that
I'm going to try to

152
00:09:17,160 --> 00:09:19,215
extrapolate this to all of them,

153
00:09:19,215 --> 00:09:21,090
all of them have a very
similar condition.

154
00:09:21,090 --> 00:09:23,880
So we're going to create a
function here which is going

155
00:09:23,880 --> 00:09:27,610
to be trigger_action_change,

156
00:09:28,490 --> 00:09:35,070
so a function that would
generalize action change,

157
00:09:35,070 --> 00:09:42,520
if self.action_count.

158
00:09:46,520 --> 00:09:48,930
Because what we're
trying to say is

159
00:09:48,930 --> 00:09:52,545
idle take maybe 200
frames in Idle,

160
00:09:52,545 --> 00:09:57,250
so count until 200 and then
reset and do the next action.

161
00:09:58,610 --> 00:10:04,035
We're going to say increase
that by one every frame,

162
00:10:04,035 --> 00:10:07,990
and if that action count,

163
00:10:10,940 --> 00:10:17,590
it's bigger than this
self.action_duration.

164
00:10:19,070 --> 00:10:23,895
What do we do? Well,

165
00:10:23,895 --> 00:10:28,690
the few things, we're going
to say, go to next state,

166
00:10:43,820 --> 00:10:48,130
and the action count
should be reset.

167
00:10:51,920 --> 00:10:55,420
We start the count over.

168
00:10:55,670 --> 00:10:58,005
We could also change
the duration.

169
00:10:58,005 --> 00:10:59,550
Before the duration could be

170
00:10:59,550 --> 00:11:01,350
by default, we could say 200.

171
00:11:01,350 --> 00:11:05,530
But we could say
that the duration,

172
00:11:10,910 --> 00:11:13,770
we could make it a new to

173
00:11:13,770 --> 00:11:16,235
give it a little bit
more variations.

174
00:11:16,235 --> 00:11:17,530
Sometimes it could be 200,

175
00:11:17,530 --> 00:11:20,265
but sometimes it could
be lower at 150 or 250.

176
00:11:20,265 --> 00:11:21,990
The amount of time it
will take you to do

177
00:11:21,990 --> 00:11:24,620
an action might be
slightly different,

178
00:11:24,620 --> 00:11:27,490
so you can play
with these numbers.

179
00:11:28,130 --> 00:11:32,710
Between something like 150,250.

180
00:11:35,510 --> 00:11:40,905
But what we are missing here
is the go to next action.

181
00:11:40,905 --> 00:11:43,095
If you remember, we have

182
00:11:43,095 --> 00:11:47,025
a tuple that is idle
moving and rotating.

183
00:11:47,025 --> 00:11:49,530
So we basically need to
create a function that

184
00:11:49,530 --> 00:11:52,860
allows us to move to the
next current action.

185
00:11:52,860 --> 00:11:54,480
Let's also do another function

186
00:11:54,480 --> 00:11:56,230
for that;
next_wander_state(self).

187
00:12:04,100 --> 00:12:08,220
Here what we're saying is,

188
00:12:08,220 --> 00:12:11,670
let's evaluate the
current action state.

189
00:12:11,670 --> 00:12:15,150
Basically, this function
is as simple as

190
00:12:15,150 --> 00:12:24,730
saying your current action
state which is 0 is a plus 1.

191
00:12:27,500 --> 00:12:33,105
Plus 1 would be this one.
But if you are in the tuple,

192
00:12:33,105 --> 00:12:34,785
go back to the first one.

193
00:12:34,785 --> 00:12:36,765
Let's do that.

194
00:12:36,765 --> 00:12:43,440
So self.current.wander_state
+= 1.

195
00:12:43,440 --> 00:12:48,060
If that is bigger than 2,

196
00:12:48,060 --> 00:12:54,990
because that's how big our
list is, it's actually 0.

197
00:12:54,990 --> 00:12:57,360
This is the loop
that we're creating.

198
00:12:57,360 --> 00:13:00,120
This is a very silly function.

199
00:13:00,120 --> 00:13:01,830
In a way it's just
looping through

200
00:13:01,830 --> 00:13:04,950
the entities of the list.

201
00:13:04,950 --> 00:13:06,945
So let's just put this together.

202
00:13:06,945 --> 00:13:14,370
We're going to say
self.next_wander_state().

203
00:13:14,370 --> 00:13:18,510
We're saying, spend 200
frames doing one action.

204
00:13:18,510 --> 00:13:21,315
If you reach those 200 frames,

205
00:13:21,315 --> 00:13:24,195
go to the next state
and reset the counter.

206
00:13:24,195 --> 00:13:27,810
Do that action for
now maybe 150 frames;

207
00:13:27,810 --> 00:13:29,220
somewhere in-between 150 and

208
00:13:29,220 --> 00:13:32,310
250 and then go to the next
one and then start over.

209
00:13:32,310 --> 00:13:35,280
So it's like a loop
but it's a loop that

210
00:13:35,280 --> 00:13:38,580
is delayed by a certain
number of frames.

211
00:13:38,580 --> 00:13:41,440
Two-hundred frames, go to next.

212
00:13:42,470 --> 00:13:45,690
We're introducing a little
bit of variability to

213
00:13:45,690 --> 00:13:51,960
those 200 frames. That's great.

214
00:13:51,960 --> 00:13:56,430
That is the trigger action.

215
00:13:56,430 --> 00:14:01,150
We want to do it in
basically all of them.

216
00:14:01,420 --> 00:14:06,120
Self.trigger_action_change().
Spend 200 frames here,

217
00:14:14,270 --> 00:14:17,880
spend 200 frames here,

218
00:14:17,880 --> 00:14:21,150
and then spend 200 frames here.

219
00:14:21,150 --> 00:14:25,425
If you think about it, the
idle is not doing anything.

220
00:14:25,425 --> 00:14:28,770
We don't really need this.idle.

221
00:14:28,770 --> 00:14:33,180
We just need to wait
those 200 frames.

222
00:14:33,180 --> 00:14:36,525
Our idle is going to
be not do anything.

223
00:14:36,525 --> 00:14:39,670
Let's just call it stay still.

224
00:14:50,960 --> 00:14:56,265
The movement, it's
a single line.

225
00:14:56,265 --> 00:15:06,550
Let's just say, def mov(self).

226
00:15:11,600 --> 00:15:18,120
Sorry, self.pos.add(self.vel).

227
00:15:18,120 --> 00:15:20,670
That's going to be
our move function.

228
00:15:20,670 --> 00:15:25,480
Just add your velocity to
your current position.

229
00:15:25,880 --> 00:15:29,530
Let's just actually
spell it right.

230
00:15:30,020 --> 00:15:32,730
Self.move() exists. If we are in

231
00:15:32,730 --> 00:15:35,580
this moving state,
you move forward.

232
00:15:35,580 --> 00:15:37,395
That might be too fast.

233
00:15:37,395 --> 00:15:40,470
We could reduce the speed.

234
00:15:40,470 --> 00:15:41,820
Currently, the speed is set by

235
00:15:41,820 --> 00:15:44,460
a random value, but should work.

236
00:15:44,460 --> 00:15:48,510
Then the rotate which is the
only one that we're really

237
00:15:48,510 --> 00:15:52,140
missing which is a new rotation.

238
00:15:52,140 --> 00:15:55,170
I think I called
it new rotation.

239
00:15:55,170 --> 00:15:58,480
Let's just write this function.

240
00:16:05,120 --> 00:16:08,730
The new rotation again,

241
00:16:08,730 --> 00:16:09,870
it's going to be
the simplest way we

242
00:16:09,870 --> 00:16:12,330
can define a new rotation.

243
00:16:12,330 --> 00:16:19,770
We're going to define a new
angle which is going to

244
00:16:19,770 --> 00:16:27,550
be random from 0-360.

245
00:16:32,600 --> 00:16:37,470
Here, we're going to
say self.velocity.

246
00:16:37,470 --> 00:16:39,945
How do we create a new vector

247
00:16:39,945 --> 00:16:42,270
or how do we pick a vector
and rotate the vector?

248
00:16:42,270 --> 00:16:44,310
We don't have a rotate
vector function.

249
00:16:44,310 --> 00:16:46,410
So it would be nice to at

250
00:16:46,410 --> 00:16:50,220
this point just pick the
velocity as it is and rotate it.

251
00:16:50,220 --> 00:16:54,270
We can actually create
a handy function of

252
00:16:54,270 --> 00:17:03,960
rotate_vector that takes
a vector and an angle.

253
00:17:04,780 --> 00:17:08,070
Let's call it vec.

254
00:17:11,920 --> 00:17:17,420
The angle. If we're giving
the angle in degrees before,

255
00:17:17,420 --> 00:17:19,550
we could say this is going to be

256
00:17:19,550 --> 00:17:22,850
a function that needs
to operate as radiance.

257
00:17:22,850 --> 00:17:31,850
We're going to say
radiance of the angle.

258
00:17:31,850 --> 00:17:33,830
If I give you like 360,

259
00:17:33,830 --> 00:17:35,765
it's going to convert
it into radiance.

260
00:17:35,765 --> 00:17:38,600
The x, this is a
function that is

261
00:17:38,600 --> 00:17:43,850
just a bit of trigonometry.

262
00:17:43,850 --> 00:17:47,090
But let's just go through
it and understand.

263
00:17:47,090 --> 00:17:51,240
We use the cosine of the angle.

264
00:17:54,660 --> 00:17:59,590
I think I call it vec, vec.x

265
00:17:59,590 --> 00:18:06,380
minus vec.y times the
sine of the angle.

266
00:18:06,380 --> 00:18:17,040
Y would be vec.x times
sine of the angle.

267
00:18:17,230 --> 00:18:23,555
Because this is not like
trigonometry kind of a course,

268
00:18:23,555 --> 00:18:27,020
and these are vector functions

269
00:18:27,020 --> 00:18:29,585
that might be really useful
and you can come across.

270
00:18:29,585 --> 00:18:32,390
It's good to just, first,

271
00:18:32,390 --> 00:18:34,250
use them and internalize them,

272
00:18:34,250 --> 00:18:35,540
and if you really
want to go into

273
00:18:35,540 --> 00:18:37,235
the trigonometry inside them,

274
00:18:37,235 --> 00:18:41,370
I invite you to revise
how it's calculated.

275
00:18:45,250 --> 00:18:48,920
But most often you're
going to be remembering,

276
00:18:48,920 --> 00:18:52,550
I had a rotate vector function
somewhere and come back

277
00:18:52,550 --> 00:18:57,920
to it and use it.

278
00:18:57,920 --> 00:19:00,365
X and y now.

279
00:19:00,365 --> 00:19:04,025
This rotate vector
takes the vector,

280
00:19:04,025 --> 00:19:07,055
and it gives us
back a new vector.

281
00:19:07,055 --> 00:19:11,450
There's going to be the rotated
version of that vector.

282
00:19:11,450 --> 00:19:18,780
We can call that function
here, self.rotate vector,

283
00:19:19,300 --> 00:19:25,780
giving the self.velocity and

284
00:19:25,780 --> 00:19:29,330
the new angle that
we just calculated.

285
00:19:29,330 --> 00:19:31,565
We calculated an
angle with a random.

286
00:19:31,565 --> 00:19:36,125
We're saying maybe
180 or 175, whatever.

287
00:19:36,125 --> 00:19:40,535
We are providing the vector
velocity and the new angle.

288
00:19:40,535 --> 00:19:45,920
We're updating the
velocity by its rotation.

289
00:19:45,920 --> 00:19:47,570
We're going to be
rotating it with

290
00:19:47,570 --> 00:19:50,795
this function. That's it.

291
00:19:50,795 --> 00:19:53,795
We basically have
the new rotation,

292
00:19:53,795 --> 00:19:56,510
basically, rotates
the velocity vector

293
00:19:56,510 --> 00:19:59,670
by a random amount.

294
00:20:06,070 --> 00:20:11,420
One thing that is interesting

295
00:20:11,420 --> 00:20:14,825
here is that the
rotation action,

296
00:20:14,825 --> 00:20:17,780
if you think about it is 200
frames we want to be idle,

297
00:20:17,780 --> 00:20:19,400
200 frames we want to be moving.

298
00:20:19,400 --> 00:20:20,915
But when we rotate,
we don't want to

299
00:20:20,915 --> 00:20:24,140
spend 200 frames rotating.

300
00:20:24,140 --> 00:20:26,240
What we could do here is instead

301
00:20:26,240 --> 00:20:27,770
of triggering the
action, that is,

302
00:20:27,770 --> 00:20:35,090
the delayed version
of next wander state.

303
00:20:35,090 --> 00:20:38,540
We take 200 frames or a
certain number of frames

304
00:20:38,540 --> 00:20:41,300
to activate the next
state in the function.

305
00:20:41,300 --> 00:20:44,060
We're going to just
call it right away.

306
00:20:44,060 --> 00:20:46,190
Meaning skip the timing.

307
00:20:46,190 --> 00:20:49,160
This is going to be
a one-off execution.

308
00:20:49,160 --> 00:20:51,230
Rotate the vector and instantly

309
00:20:51,230 --> 00:20:53,735
move to the next one.
This is very quick.

310
00:20:53,735 --> 00:20:57,215
It happens in a
fraction in one frame.

311
00:20:57,215 --> 00:20:58,610
This one will take 200 frames,

312
00:20:58,610 --> 00:21:01,320
this one will take 200
frames. This is quick.

313
00:21:01,390 --> 00:21:06,230
That gives us that
flexibility of saying,

314
00:21:06,230 --> 00:21:08,630
some actions are one-off action

315
00:21:08,630 --> 00:21:11,090
instantly triggers
in the next state.

316
00:21:11,090 --> 00:21:13,235
I know that's been a lot.

317
00:21:13,235 --> 00:21:16,740
Let's see how this is running.

318
00:21:19,630 --> 00:21:25,620
We are not executing
these wander actions yet,

319
00:21:26,020 --> 00:21:28,925
because we have to
place them here,

320
00:21:28,925 --> 00:21:34,920
so self.wander actions.

321
00:21:36,880 --> 00:21:40,650
Here's where we would run into.

322
00:21:41,020 --> 00:21:44,340
There we go. It's moving.

323
00:21:44,500 --> 00:21:48,885
It stops, looks in a
different direction.

324
00:21:48,885 --> 00:21:56,010
Moves, stops, and looks
in a different direction.

325
00:21:56,010 --> 00:21:58,225
Moves, stops.

326
00:21:58,225 --> 00:22:00,925
Because we're not triggering
the decision tree,

327
00:22:00,925 --> 00:22:03,205
currently, it's
always wandering.

328
00:22:03,205 --> 00:22:04,900
This is going to be
the wander state.

329
00:22:04,900 --> 00:22:06,940
You can reintroduce a lot of

330
00:22:06,940 --> 00:22:10,435
herbivores and all of them
should behave in this way.

331
00:22:10,435 --> 00:22:11,860
Again, we're going to create

332
00:22:11,860 --> 00:22:13,150
some visualization to really

333
00:22:13,150 --> 00:22:16,970
understand their brain
a little bit further.

334
00:22:17,670 --> 00:22:20,185
But we have, basically,

335
00:22:20,185 --> 00:22:21,280
a little state machine that

336
00:22:21,280 --> 00:22:22,525
dictates this wander behavior,

337
00:22:22,525 --> 00:22:24,165
and we're really mixing

338
00:22:24,165 --> 00:22:25,790
decision trees and
state machines to

339
00:22:25,790 --> 00:22:29,630
actually start constructing
the behavior of this entity.

340
00:22:29,630 --> 00:22:31,220
We're going to continue going in

341
00:22:31,220 --> 00:22:34,190
the seek hunger function.

342
00:22:34,190 --> 00:22:36,750
I'll see you in the
next video for that.