Open breznak opened 8 years ago
How i have it now: Pick one random distractor from the allowed ones and try it's probability. Then it either applies or not. In next cycle repeat.
How it could be: pick all distractors, try their probability. If one of them is true, apply it. If more are, pick random and apply it. Which would be better?
How i have it now: Pick one random distractor from the allowed ones and try it's probability. Then it either applies or not. In next cycle repeat.
I think this is fine. I imagine it should (in principle) work like this:
// in the simulation loop, so updating each step (1sec?)
for(Distractor d: activeDistractors[]) {
if(rand() > d.probability()) d.apply();
}
So distractions happen at random times, multiple distractions at a time can occur (rarely)
Follow up idea, how to make distractors disappear, is in #61
...Is it true that the distractors appear at a fixed distance
from the car? If so, we should make it random in an interval (given to constructor)
There is always variable called distance_offset
(generates random offset added to the distance value) the range is just not adjustable from constructor, it is fixed. Should i move it to constructor?
that's ok, let's just call the constants public static final int SPAWN_DISTANCE_{MIN,MAX}
to make it clear.
and then it will generate distance as randint(MIN, MAX)
This is being fixed in #48
The distractors are sampled with random probability BUT:
The sampling should use: -[x] variable time intervals for the sampling (not fixed 5s - set min/max interval time) -[ ] each distractor is sampled independently (maybe in a separate thread Timer?)