breznak / openDS-oss

Mirror of the OpenDS.de car driving simulator
17 stars 12 forks source link

Improve distractor sampling #42

Open breznak opened 8 years ago

breznak commented 8 years ago

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?)

JohnnyMarek commented 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?

breznak commented 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.

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)

breznak commented 8 years ago

Follow up idea, how to make distractors disappear, is in #61

breznak commented 8 years ago

...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)

JohnnyMarek commented 8 years ago

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?

breznak commented 8 years ago

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)

breznak commented 8 years ago

This is being fixed in #48