I am building a model with anylogic. Here is the code:
victim = null;
for (People p : main.people){
//když je dostatečně daleko
if((distanceTo(p, METER)) < fightDistance){
if( randomTrue( fightProbability ) && !p.equals(victim) ) {
victim = p; //set the victim
break; //stop scan
}
}
}
The fighter is supposed to choose his victim with the probability of 20%. Two fighters can't share the same victim, which is not working. I need to make sure that the choosen people is not the victim already, though && !p.equals(victim)
doesn't help...