This doesn't belong to "Programming Questions", moved.
Learn to format code: How to format code and text and post textual code, instead of image of code: we cannot copy and paste this code in a PDE, and it is not searchable.
The problem is that when one of the agents (5 in my example) reaches the door and wants to go to his next phase to search for the exit, all the other agents act like they found the door too.
that's because you store the info (found the door) in the sketch and not for each person individually (in the class)
I'm sorry how do you do that.
I'll have to take the variable to my room-class or?
A little resume to check if I properly understand all your help: Fase0 en fase 1 can be left in the draw-function in the maintab because that's the same for everyone. But because my fase 2 is something 'personal' for each agent, i'll have to use it in my class (people)?
I'm just not sure if i put it correctly in there (obviously not because of the error:) ) but could you explain what i'll have to do to put it in there correctly?
I'm quite sure it worked, only problem is: when i press 'a' everyone will go towards the door. But after the first one found it and went through it, all the others disappeared...
My amountOfPeople is set on 5.
Haha true! Everything goes good for the first one:
I start the sketch, 5 persons are wandering through their room. (good!)
I press 'a'; when the door is in their view-radius, they'll walk towards it (good!)
When the first one goes through the door in the hallway all the others disappear (bad)
When he is walking through the hallway he'll stop at the emergencyExit (good!)
Sorry I was eating :).
Nope in my People-class this is what i've done for FASE2:
This is my maintab for FASE2:
for (People p: persons) {
if (p.FASE2 == true) {
p.separation(persons);
p.display();
p.bordersHallway();
p.findNearbyExit();
fireHazzard.add(new Fire(new PVector(positionFireX,positionFireY,positionFireZ)));
p.fireEscape();
p.update();
}
}
That's the problem, i've never face that kind of trouble and i don't think there is a variable responsible for it? It was never an option to disappear.
We've got amountOfPeople but that's just a variable with an amount you choose at the start of the sketch.
Maybe processing just acts like 'one went through the door, we can go to the next phase, the others don't mather anymore?' I'm just guessing though because i'm not sure...
You mean for fase0 and 1 i use a setup that's quite similar? It's some code-duplication but i don't think it's a problem for the performance of my program?
If i put a comment before line 199 they all just 'hang out' at the door, i think because they don't realize they're ready for the next phase.
Answers
the fases are global vars
but you want to have them in the class Agent / People instead
so when you loop over the persons say
etc.
also, remember
if (p.FASE0== true) {
can be written asif (p.FASE0) {
;-)
since only one of
FASE0, FASE1, FASE2
can betrue
you might as well sayint fase = 0;
and this can be 0,1 or 2....and then
m
m
m
so 'a' makes the fire start?
the idea is to handle it for each person individually
so make FASE2 part of the class People
no FASE2 in the sketch, only in the class!!!!!!!!!!!
That's correct, when you press 'a' the people will start to 'panic' and a fire will start somewhere. Okay I'll try that first, thanks!
you wrote:
that's because you store the info (found the door) in the sketch and not for each person individually (in the class)
;-)
currPeople.FASE2 = true; cannot be resolved or is not a field is my error... Maybe chat is easier for this conversation?
did you put FASE2 in the class
and removed from the sketch...?
I'm sorry how do you do that. I'll have to take the variable to my room-class or?
A little resume to check if I properly understand all your help: Fase0 en fase 1 can be left in the draw-function in the maintab because that's the same for everyone. But because my fase 2 is something 'personal' for each agent, i'll have to use it in my class (people)?
I'm just not sure if i put it correctly in there (obviously not because of the error:) ) but could you explain what i'll have to do to put it in there correctly?
Thanks!
you understood well
in the People class:
I'm quite sure it worked, only problem is: when i press 'a' everyone will go towards the door. But after the first one found it and went through it, all the others disappeared... My amountOfPeople is set on 5.
that is good, isn't it?
that is bad, right?
Haha true! Everything goes good for the first one: I start the sketch, 5 persons are wandering through their room. (good!) I press 'a'; when the door is in their view-radius, they'll walk towards it (good!) When the first one goes through the door in the hallway all the others disappear (bad) When he is walking through the hallway he'll stop at the emergencyExit (good!)
I guess you got one line setting FASE2 (that is where they flee, right?) to false and instead FASE0 to true
or set FASE1 to true?
maybe in
??
how come, they don't show anymore?
which var does that??
done?
Sorry I was eating :). Nope in my People-class this is what i've done for FASE2:
This is my maintab for FASE2: for (People p: persons) { if (p.FASE2 == true) { p.separation(persons); p.display(); p.bordersHallway(); p.findNearbyExit(); fireHazzard.add(new Fire(new PVector(positionFireX,positionFireY,positionFireZ))); p.fireEscape(); p.update();
} }
p
sorry about the bad layout, it didn't work like i wanted it to do.
how come, they don't show anymore when they reached the door?
which var does that??
That's the problem, i've never face that kind of trouble and i don't think there is a variable responsible for it? It was never an option to disappear. We've got amountOfPeople but that's just a variable with an amount you choose at the start of the sketch. Maybe processing just acts like 'one went through the door, we can go to the next phase, the others don't mather anymore?' I'm just guessing though because i'm not sure...
but you wrote that code....
so what happens when one goes through the door?
show class people.
m
m
is it ok that phases is within the class?
m
do you see that phases in the class is almost the same as what you have in draw()?
that can not be good
also line 199 above: not sure...
maybe make // before this?
You mean for fase0 and 1 i use a setup that's quite similar? It's some code-duplication but i don't think it's a problem for the performance of my program?
If i put a comment before line 199 they all just 'hang out' at the door, i think because they don't realize they're ready for the next phase.
ok, i got 10 more minutes
post your entire code
m
Do you need the other ones too, i guess not because those work?
entire
as I said
clock is ticking....
m
m
m
sorry, I can't run it here....
sorry....
all I can say, that it is weired that you have phases inside the class, because you loop over all people there
and because
sorry, I have to go...
;-)