Hi.
Welcome back.
How did you go with the challenge that I left you with in the last video?
It takes a little bit to get your mind around what values are where and your preconditions and your
effects and the inventory and all of the world state, doesn't it?
And that's why going through this step by step and adding in the functionality as we require it works
to our benefit as far as getting our minds around all of the logic of the code.
Okay, so let's get going now.
I said that we needed something that was pretty similar to the patients get treated code.
So what I'd like you to do is make a copy of it like we usually do.
And then let's call this one go to cubicle just so that the nurses is different.
I open that up and we'll call it Go to cubicle.
Go to cubicle.
Okay.
So the same thing has to occur up with the target, exactly the same thing.
The target is the cubicle and that's all that we need there.
Now with the world's modified state.
What we're going to put in here instead is treating patient.
Because the nurse is the one that's doing treating patient and the patient who's being treated okay.
We then need to also add a cubicle in our post, perform back into the world's inventory, I guess you
call it.
So all the items that the world has ownership of, we're going to give it back one of the cubicles.
So world instance.
Dot add cubicle and the cubicle we're adding back in is the target like that.
Now as far as removing that same one from the nurses inventory, you also need to do that down there.
And then the last thing that we can do with the nurse, which we haven't done with the patient, is
to set the world status of free cubicle and add another one back in there.
So she will dot instance, dot get world, dot modify state and that will be free cubicle.
And one.
So adding one back to it, it would have gone down to two.
Now it'll go back up to one.
Now the thing such as this you only want to happen by one of the agents involved in the act.
Okay, so it's the nurse and the patient, but it's the nurse only giving back the cubicle and setting
the state of the world because both of them can't do it.
You don't need it to happen twice.
So just be aware of that.
And I guess it makes sort of sense that the nurse being the staff member of the hospital, so to say,
is the one who has the code that's actually releasing those resources.
All right.
So let's save that.
How did you go, by the way?
I hope you had something similar to that.
Now we're going to attach that to our nurse.
So here's the nurse and we just created go to cubicle drag and drop that onto here.
Now we need to work with the pre conditions and the post conditions.
So what is the precondition for going to cubicle.
Well there's a whole bunch of them isn't there.
But in this case, what I'm going to do is link get patient to go to cubicle.
So with get patient down in the after effects, I'm just going to change this treat patient to patient
picked up or something like that.
So patient picked up and then I'll use that exact same condition.
So if I copy that and I'll put it down in my preconditions for go to cubicle, which will link those
together.
Now the reason I've not made go to cubicle a separate action like we did with the patient is that this
go to cubicle is part of this nurse's plan.
So it's get patient, go to cubicle and it's not actually going to happen the whole sequence unless,
you know, there's a patient in a cubicle right at the beginning.
So that's why I'm doing it like this.
And it also saves a lot of extra sort of coding throughout.
Now, the after effect for go to cubicle in this case is going to be the nurse's ultimate goal, which
is is treated, I believe, which is to remind ourselves of what the nurse is are notes, treat patients.
So that's our final goal.
Let's just copy that and go back into unity, add that to the nurse's after effects.
And so the goal will now trigger this one, which is going to follow this full plan without having to
do well, you know, anything else?
Okay, so we're ready.
Let's now press play and see what we get.
So patient comes in again.
I'm just working with one patient.
Makes it so much easier to debug.
He goes and waits.
The nurse will come around and say, I've been allocated to you and we've got a cubicle allocated to
us, so let's go to the cubicle.
Both of them will head off.
To the cubicle.
Great.
And all of the world states have come up and you might notice that your other patients are making a
headway for the door.
Just ignore that for now.
Right now.
Why didn't I assign the agent or the sorry, the patient to the nurse or the nurse could follow the
patient?
Well, it means that the duration of the task for the patient over here in the cubicle could be like
5 seconds and the nurse might take 8 seconds.
So that which means that the patient's free to go after 3 seconds and the nurse kind of stays behind
because she's got to clean up or whatever her task is.
So even though they end up in the same cubicle together, they're not actually linked directly to each
other for that particular task.
And that is fine because it's working the way we want it.
And remember creating computer games and especially A.I. it's all about the behavior that you can get
them to do, not the perfect way to do it or some other way to do it.
However, you get it to work and it works fine for you, then go with it.
So that's my sage advice, I guess at this point, because A.I. is a very complex topic and this system
is complex, but once you figure it out and how it's all working in that and it might take you a while
and a few practices, then you'll start to see just how powerful and flexible it is and that there's
more than one way to do something.