BeamNG / BeamNGpy

Python API for BeamNG.tech
https://beamng.tech
MIT License
262 stars 47 forks source link

How to increase the randomness of traffic flow? #263

Open yuyuyu223 opened 7 months ago

yuyuyu223 commented 7 months ago

I used the following code to generate traffic flow:

beamng.traffic.spawn(max_amount=5)

But the position of each traffic vehicle is almost fixed. I want to know how to generate a richer traffic flow state.

image

image

Is there an interface for inputting random seeds?

In addition, how to define the conditions for generating traffic flow, such as within a certain vicinity of an ego vehicle?

aivora-beamng commented 7 months ago

Hi, to teleport the traffic away from the player, you can use the beamng.traffic.reset() function.

AFAIK, the parameters for generating traffic flow are not exposed, but you can check the implementation of BeamNG.tech\lua\ge\extensions\gameplay\traffic.lua and (possibly) edit it according to your needs.