simple traffic simulation
Budget: €8 – €30 EUR
A two-dimensional playing field ("vertical cylinder" 60 x 30, attention: NOT "torus") represents in the 1st row a never-ending single-lane roadway with vehicles driving on it (exclusively) from left to right.
After each time step, the patches of all lines are "copied" down by one line, so that the current tick n is visualised in the 1st line, tick n-1 in the 2nd line, tick n-2 in the 3rd line, and so on. This means that in total, the single-lane roadway can be viewed in the two-dimensional playing field at the last 30 consecutive times/ticks.
There are two types of patches on the single-lane roadway:
black patches are patches on which there is no vehicle and coloured patches are patches on which there are vehicles, whereby a maximum of one vehicle can be on a patch at the same time.
The number of vehicles should be selectable within reasonable limits by means of a slider in the interface tab ("initial-density").
At the start, the vehicles randomly have one of three different starting speeds (equal distribution), which is reflected in the colouring of the vehicles. Specifically, vehicles that are currently "standing still" or driving 0 patches per tick (PpT) have the colour red, vehicles that are driving 1 PpT fast have the colour yellow and vehicles that are driving 2 PpT fast have the colour green.
The maximum speed is 2 PpT and this maximum speed is always aimed for by all vehicles. However, vehicles can only accelerate from 0 PpT to 1 PpT or from 1 PpT to 2 PpT (within one tick) if at least two or four patches in front of them are untravelled (i.e. black).
All vehicles must "slow down" (i.e. reduce their speed from 2 PpT to 1 PpT or from 1 PpT to 0 PpT), unless at least two patches or one patch in front of them are/is untravelled (black).
In addition, there is also a global "dawdle-propability", which shall be selectable via slider on the interface tab ("dawdle-propability"), with which the individual vehicles reduce their speed from 2 PpT to 1 PpT or from 1 PpT to 0 PpT. Every change in position and speed of vehicles automatically causes a change in the corresponding colour of the patches (see above).
Use only(!) commands already discussed in class (see below)! Also document the created model in the "Info Tab". Then configure an experiment where the "initial-density" and the "dawdle-propability" are systematically varied (with 30 repetitions per configuration). The experiment should output the current average speed of the vehicles over all time steps (time limit of 150 ticks). Try to solve this task without the option "Measure runs at every step" of BehaviorSpace.
After each time step, the patches of all lines are "copied" down by one line, so that the current tick n is visualised in the 1st line, tick n-1 in the 2nd line, tick n-2 in the 3rd line, and so on. This means that in total, the single-lane roadway can be viewed in the two-dimensional playing field at the last 30 consecutive times/ticks.
There are two types of patches on the single-lane roadway:
black patches are patches on which there is no vehicle and coloured patches are patches on which there are vehicles, whereby a maximum of one vehicle can be on a patch at the same time.
The number of vehicles should be selectable within reasonable limits by means of a slider in the interface tab ("initial-density").
At the start, the vehicles randomly have one of three different starting speeds (equal distribution), which is reflected in the colouring of the vehicles. Specifically, vehicles that are currently "standing still" or driving 0 patches per tick (PpT) have the colour red, vehicles that are driving 1 PpT fast have the colour yellow and vehicles that are driving 2 PpT fast have the colour green.
The maximum speed is 2 PpT and this maximum speed is always aimed for by all vehicles. However, vehicles can only accelerate from 0 PpT to 1 PpT or from 1 PpT to 2 PpT (within one tick) if at least two or four patches in front of them are untravelled (i.e. black).
All vehicles must "slow down" (i.e. reduce their speed from 2 PpT to 1 PpT or from 1 PpT to 0 PpT), unless at least two patches or one patch in front of them are/is untravelled (black).
In addition, there is also a global "dawdle-propability", which shall be selectable via slider on the interface tab ("dawdle-propability"), with which the individual vehicles reduce their speed from 2 PpT to 1 PpT or from 1 PpT to 0 PpT. Every change in position and speed of vehicles automatically causes a change in the corresponding colour of the patches (see above).
Use only(!) commands already discussed in class (see below)! Also document the created model in the "Info Tab". Then configure an experiment where the "initial-density" and the "dawdle-propability" are systematically varied (with 30 repetitions per configuration). The experiment should output the current average speed of the vehicles over all time steps (time limit of 150 ticks). Try to solve this task without the option "Measure runs at every step" of BehaviorSpace.