WEBVTT

00:06.300 --> 00:06.750
Hi.

00:06.750 --> 00:07.440
Welcome back.

00:07.440 --> 00:11.280
How did you go with the challenge that I left you with in the last video?

00:11.310 --> 00:17.100
It takes a little bit to get your mind around what values are where and your preconditions and your

00:17.100 --> 00:21.210
effects and the inventory and all of the world state, doesn't it?

00:21.510 --> 00:28.350
And that's why going through this step by step and adding in the functionality as we require it works

00:28.350 --> 00:32.610
to our benefit as far as getting our minds around all of the logic of the code.

00:32.610 --> 00:34.620
Okay, so let's get going now.

00:34.620 --> 00:42.420
I said that we needed something that was pretty similar to the patients get treated code.

00:42.420 --> 00:47.670
So what I'd like you to do is make a copy of it like we usually do.

00:47.670 --> 00:55.890
And then let's call this one go to cubicle just so that the nurses is different.

00:55.890 --> 00:58.920
I open that up and we'll call it Go to cubicle.

00:59.160 --> 01:01.980
Go to cubicle.

01:02.250 --> 01:02.640
Okay.

01:02.640 --> 01:07.020
So the same thing has to occur up with the target, exactly the same thing.

01:07.020 --> 01:10.890
The target is the cubicle and that's all that we need there.

01:10.890 --> 01:13.950
Now with the world's modified state.

01:13.950 --> 01:17.820
What we're going to put in here instead is treating patient.

01:18.880 --> 01:26.690
Because the nurse is the one that's doing treating patient and the patient who's being treated okay.

01:26.710 --> 01:37.120
We then need to also add a cubicle in our post, perform back into the world's inventory, I guess you

01:37.120 --> 01:37.420
call it.

01:37.420 --> 01:44.380
So all the items that the world has ownership of, we're going to give it back one of the cubicles.

01:44.560 --> 01:47.920
So world instance.

01:49.470 --> 01:57.080
Dot add cubicle and the cubicle we're adding back in is the target like that.

01:57.090 --> 02:04.620
Now as far as removing that same one from the nurses inventory, you also need to do that down there.

02:04.770 --> 02:11.280
And then the last thing that we can do with the nurse, which we haven't done with the patient, is

02:11.280 --> 02:16.410
to set the world status of free cubicle and add another one back in there.

02:16.410 --> 02:29.790
So she will dot instance, dot get world, dot modify state and that will be free cubicle.

02:31.280 --> 02:32.180
And one.

02:32.180 --> 02:35.240
So adding one back to it, it would have gone down to two.

02:35.240 --> 02:37.020
Now it'll go back up to one.

02:37.040 --> 02:45.770
Now the thing such as this you only want to happen by one of the agents involved in the act.

02:45.770 --> 02:54.410
Okay, so it's the nurse and the patient, but it's the nurse only giving back the cubicle and setting

02:54.410 --> 02:59.120
the state of the world because both of them can't do it.

02:59.120 --> 03:01.160
You don't need it to happen twice.

03:01.160 --> 03:02.450
So just be aware of that.

03:02.450 --> 03:08.150
And I guess it makes sort of sense that the nurse being the staff member of the hospital, so to say,

03:08.150 --> 03:13.040
is the one who has the code that's actually releasing those resources.

03:13.550 --> 03:13.880
All right.

03:13.880 --> 03:14.960
So let's save that.

03:14.960 --> 03:16.610
How did you go, by the way?

03:16.760 --> 03:18.740
I hope you had something similar to that.

03:18.740 --> 03:21.740
Now we're going to attach that to our nurse.

03:21.740 --> 03:28.160
So here's the nurse and we just created go to cubicle drag and drop that onto here.

03:28.190 --> 03:32.750
Now we need to work with the pre conditions and the post conditions.

03:32.750 --> 03:37.910
So what is the precondition for going to cubicle.

03:37.910 --> 03:40.130
Well there's a whole bunch of them isn't there.

03:40.550 --> 03:46.430
But in this case, what I'm going to do is link get patient to go to cubicle.

03:46.430 --> 03:56.420
So with get patient down in the after effects, I'm just going to change this treat patient to patient

03:56.990 --> 03:59.390
picked up or something like that.

03:59.690 --> 04:04.220
So patient picked up and then I'll use that exact same condition.

04:04.220 --> 04:11.330
So if I copy that and I'll put it down in my preconditions for go to cubicle, which will link those

04:11.330 --> 04:12.380
together.

04:12.530 --> 04:22.520
Now the reason I've not made go to cubicle a separate action like we did with the patient is that this

04:22.520 --> 04:27.590
go to cubicle is part of this nurse's plan.

04:27.590 --> 04:34.040
So it's get patient, go to cubicle and it's not actually going to happen the whole sequence unless,

04:34.040 --> 04:37.340
you know, there's a patient in a cubicle right at the beginning.

04:37.340 --> 04:38.870
So that's why I'm doing it like this.

04:38.870 --> 04:41.930
And it also saves a lot of extra sort of coding throughout.

04:41.930 --> 04:49.370
Now, the after effect for go to cubicle in this case is going to be the nurse's ultimate goal, which

04:49.370 --> 04:56.000
is is treated, I believe, which is to remind ourselves of what the nurse is are notes, treat patients.

04:56.000 --> 04:57.530
So that's our final goal.

04:58.010 --> 05:05.000
Let's just copy that and go back into unity, add that to the nurse's after effects.

05:05.000 --> 05:12.080
And so the goal will now trigger this one, which is going to follow this full plan without having to

05:12.080 --> 05:14.750
do well, you know, anything else?

05:14.870 --> 05:16.460
Okay, so we're ready.

05:16.460 --> 05:20.270
Let's now press play and see what we get.

05:21.050 --> 05:23.720
So patient comes in again.

05:23.720 --> 05:26.330
I'm just working with one patient.

05:26.510 --> 05:28.580
Makes it so much easier to debug.

05:28.910 --> 05:30.350
He goes and waits.

05:30.380 --> 05:39.320
The nurse will come around and say, I've been allocated to you and we've got a cubicle allocated to

05:39.320 --> 05:41.840
us, so let's go to the cubicle.

05:41.840 --> 05:44.750
Both of them will head off.

05:45.640 --> 05:46.960
To the cubicle.

05:47.890 --> 05:48.340
Great.

05:48.340 --> 05:55.570
And all of the world states have come up and you might notice that your other patients are making a

05:55.570 --> 05:56.410
headway for the door.

05:56.440 --> 05:57.880
Just ignore that for now.

05:58.150 --> 05:58.990
Right now.

05:58.990 --> 06:07.090
Why didn't I assign the agent or the sorry, the patient to the nurse or the nurse could follow the

06:07.090 --> 06:07.900
patient?

06:07.900 --> 06:16.060
Well, it means that the duration of the task for the patient over here in the cubicle could be like

06:16.060 --> 06:18.820
5 seconds and the nurse might take 8 seconds.

06:18.820 --> 06:25.540
So that which means that the patient's free to go after 3 seconds and the nurse kind of stays behind

06:25.540 --> 06:29.170
because she's got to clean up or whatever her task is.

06:29.170 --> 06:36.400
So even though they end up in the same cubicle together, they're not actually linked directly to each

06:36.400 --> 06:39.370
other for that particular task.

06:39.370 --> 06:43.720
And that is fine because it's working the way we want it.

06:43.720 --> 06:50.500
And remember creating computer games and especially A.I. it's all about the behavior that you can get

06:50.500 --> 06:54.820
them to do, not the perfect way to do it or some other way to do it.

06:55.210 --> 07:00.040
However, you get it to work and it works fine for you, then go with it.

07:00.400 --> 07:08.560
So that's my sage advice, I guess at this point, because A.I. is a very complex topic and this system

07:08.710 --> 07:15.460
is complex, but once you figure it out and how it's all working in that and it might take you a while

07:15.460 --> 07:21.280
and a few practices, then you'll start to see just how powerful and flexible it is and that there's

07:21.280 --> 07:23.500
more than one way to do something.
