; Cars. breed [cars car] ; Patches (track) properties. patches-own [track pit pit-entry pit-exit drs-detection drs-zone finish-line starting-position direction direction-to-pits direction-down-the-track] ; Car properties. cars-own [speed drs tyre-type tyre-wear lap current-patch driving-style pit-stops] ; Global variables. globals [current-lap positions] ; The main procedure to set everything up. to setup clear-all reset-ticks set positions [] set current-lap 0 setup-track "bahrain.txt" setup-cars end ; The main procedure to start the race. to go ask cars [ let in-pits false let on-pit-entry false let on-pit-exit false let on-finish-line false let on-drs-detection false let on-drs-zone false let direction-from-track-to-pits 0 let direction-on-track 0 ask patch-here [ set in-pits pit set on-pit-entry pit-entry set on-pit-exit pit-exit set on-finish-line finish-line set on-drs-detection drs-detection set on-drs-zone drs-zone set direction-from-track-to-pits direction-to-pits set direction-on-track direction-down-the-track ] ; Find a direction the car should be heading. set heading get-direction heading tyre-wear in-pits on-pit-entry on-pit-exit on-finish-line direction-from-track-to-pits direction-on-track ; Get the current speed of the car and move forward. forward get-actual-car-speed speed tyre-type tyre-wear drs on-drs-zone in-pits on-finish-line driving-style ; Check if the car's patch changed. If it did, update it and update its tyre wear and lap number. if (current-patch != patch-here) [ if (in-pits = true and on-finish-line = true) [ ; We're in the pits on on the finish line, change the tyres. change-tyres ] if (on-drs-detection = true) [ ifelse (timer < drs-detection-threshold) [ set drs true ] [ set drs false ] reset-timer ] ; Change the car's patch. set current-patch patch-here ; Update the tyre-wear. change-tyre-wear ; Update the lap number. change-lap-number ] ] end ; Finds a new direction for a car. to-report get-direction [old-direction current-tyre-wear in-pits on-pit-entry on-pit-exit on-finish-line direction-from-track-to-pits direction-on-track] if (current-tyre-wear <= max-tyre-wear and in-pits = false) [ ; Tyre wear is fine and we're not in the pits. Find the way on the track. report get-direction-on-track old-direction on-pit-exit direction-on-track ] ifelse (current-tyre-wear > max-tyre-wear)[ ; Tyre wear is too high. ifelse (in-pits = false) [ ; We're on the track, find a way to the pits. if (current-lap >= amount-of-laps) [ ; Someone has already won the race or is on the last lap. We don't want to end the race in the pits, so let's just find the way on the track till we reach the finish line. report get-direction-on-track old-direction on-pit-exit direction-on-track ] report get-direction-to-pits old-direction on-pit-entry direction-from-track-to-pits on-pit-exit direction-on-track ] [ ; We're in the pits. Drive in the pits until we reach the pit exit. report get-direction-from-pits old-direction on-pit-exit direction-on-track ] ] [ ; Tyre wear is fine. ifelse (in-pits = true) [ ; We're in the pits (we just pitted and changed tyres). Find the way out of pits. report get-direction-from-pits old-direction on-pit-exit direction-on-track ] [ ; We're not in the pits, we should just go ahead. report get-direction-on-track old-direction on-pit-exit direction-on-track ] ] end ; Returns direction a car should be heading to enter the pits. ; If the car is not on the pit entry, this method will keep returning the direction on the track until the car reaches the pit entry. ; If the car follows the direction returned by this method it will eventually get to the pits. to-report get-direction-to-pits [old-direction car-on-pit-entry direction-from-track-to-pits car-on-pit-exit direction-from-pits-to-track] ifelse (car-on-pit-entry = true) [ ; We're on the pit entry. Return the direction to the pits. report direction-from-track-to-pits ] [ ; We're not on the pit entry, continue down the track until we reach it. report get-direction-on-track old-direction car-on-pit-exit direction-from-pits-to-track ] end ; Returns direction a car should be heading to exit the pits. ; If the car is not on the pit exit yet, this method will keep returning the direction in the pits until the car reaches the pit exit. ; If the car follows the direction returned by this method, it will eventually leave the pits. to-report get-direction-from-pits [old-direction car-on-pit-exit direction-on-track] ifelse (car-on-pit-exit = true) [ ; We're on the pit exit. Return the direction down the track. report direction-on-track ] [ ; We're not on the pit exit, continue driving in the pits until we reach it. let pit-exit-found false let pit-found false ask patch-ahead 1 [ set pit-exit-found pit-exit set pit-found pit ] ifelse (pit-exit-found = true) [ ; Pit exit was found on the patch ahead in the old direction, return it. report old-direction ] [ ; Pit exit was not found on the patch ahead in the old direction. if (pit-found = true) [ ; Pit exit wasn't found, but pit itself was found. Continue driving in the pits. report old-direction ] ; Neither pit nor pit exit were found directly ahead. Try turning to different sides to see whether there is pit or pit exit. ifelse (old-direction = 0 or old-direction = 180) [ set heading 90 if (is-pit-or-pit-exit-ahead 90 = true) [report 90] set heading 270 if (is-pit-or-pit-exit-ahead 270 = true) [report 270] ] [ set heading 0 if (is-pit-or-pit-exit-ahead 0 = true) [report 0] set heading 180 if (is-pit-or-pit-exit-ahead 180 = true) [report 180] ] ] report get-direction-in-pits old-direction ] end ; Returns the new direction on track for a car. to-report get-direction-on-track [old-direction on-pit-exit direction-from-pit-exit] if (on-pit-exit = true) [ report direction-from-pit-exit ] let new-direction 0 let track-found false ask patch-ahead 1 [ set track-found track ] if (track-found = true) [ ; Just go ahead. report old-direction ] ifelse (old-direction = 0 or old-direction = 180) [ set heading 90 if (is-track-ahead 90 = true) [report 90] set heading 270 if (is-track-ahead 270 = true) [report 270] ] [ set heading 0 if (is-track-ahead 0 = true) [report 0] set heading 180 if (is-track-ahead 180 = true) [report 180] ] end ; Returns the new direction in pits for a car. to-report get-direction-in-pits [old-direction] let new-direction 0 let pit-exit-found false let pit-found false ask patch-ahead 1 [ set pit-exit-found pit-exit set pit-found pit ] if (pit-exit-found = true) [ report old-direction ] if (pit-found = true) [ ; Just go ahead. report old-direction ] ifelse (old-direction = 0 or old-direction = 180) [ set heading 90 if (is-pit-or-pit-exit-ahead 90 = true) [report 90] set heading 270 if (is-pit-or-pit-exit-ahead 270 = true) [report 270] ] [ set heading 0 if (is-pit-or-pit-exit-ahead 0 = true) [report 0] set heading 180 if (is-pit-or-pit-exit-ahead 180 = true) [report 180] ] end ; Returns true when there is track in the given direction, false otherwise. to-report is-track-ahead [direction-ahead] set heading direction-ahead let track-found false ask patch-ahead 1 [ set track-found track ] report track-found end ; Returns true when there are pits or pit exit in the given direction, false otherwise. to-report is-pit-or-pit-exit-ahead [direction-ahead] set heading direction-ahead let pit-exit-found false let pit-found false ask patch-ahead 1 [ set pit-exit-found pit-exit set pit-found pit ] if (pit-exit-found = true) [ report pit-exit-found ] report pit-found end ; Sets up a track from the given file. to setup-track [filename] ; Read the track data from the given file. file-open filename let track-data [] while [not file-at-end?] [ set track-data lput file-read track-data ] file-close ; Set the track data to patches. let i 0 foreach track-data [ let xcoord item 0 (item i track-data) let ycoord item 1 (item i track-data) let track-property item 2 (item i track-data) ask patches with [pxcor = xcoord and pycor = ycoord] [ ifelse (track-property = 1) [ ; Track. set track true set pit false ] [ ifelse (track-property = 2) [ ; Pit lane. set pit true ] [ ifelse (track-property = 3) [ ; Pit entry (and track). set track true set pit-entry true set pit false set direction-to-pits item 3 (item i track-data) ] [ ifelse (track-property = 4) [ ; Pit exit (and track). set track true set pit false set pit-exit true set direction-down-the-track item 3 (item i track-data) ] [ ifelse (track-property = 5) [ ; DRS detection zone (and track). set track true set pit false set drs-detection true ] [ ifelse (track-property = 6) [ ; DRS zone (and track). set track true set pit false set drs-zone true ] [ ifelse (track-property = 7) [ ; Finish line (and track and DRS zone). set track true set pit false set drs-zone true set finish-line true ] [ ifelse (track-property = 8) [ ; It's a starting position (and track and DRS zone). set track true set pit false set drs-zone true set starting-position item 3 (item i track-data) set direction item 4 (item i track-data) ] [ ifelse (track-property = 9) [ ; Finish line in the pits. set pit true set finish-line true ] [ ]]]]]]]]]] set i i + 1 ] ; Mark everything with different colors. ; Background. ask patches [ set pcolor green ] ; Track. ask patches with [track = true] [ set pcolor grey ] ; Pits. ask patches with [pit-entry = true] [ set pcolor blue ] ask patches with [pit = true] [ set pcolor black ] ask patches with [pit-exit = true] [ set pcolor blue ] ; DRS zones. ask patches with [drs-detection = true] [ set pcolor orange ] ask patches with [drs-zone = true] [ set pcolor yellow ] ; Finish line. ask patches with [finish-line = true] [ set pcolor red ] end ; Procedure for creating cars and placing them on the track. to setup-cars create-cars amount-of-cars let start-position 1 ask cars [ set shape "car" set color get-color-for-car-number who set current-patch nobody set tyre-type random 3 set driving-style random 3 set tyre-wear 0 set pit-stops 0 set lap 0 let speed-range highest-speed - lowest-speed set speed lowest-speed + random-float speed-range let start-position-x-coord 0 let start-position-y-coord 0 let start-position-direction 0 ask patches with [starting-position = start-position] [ set start-position-x-coord pxcor set start-position-y-coord pycor set start-position-direction direction ] setxy start-position-x-coord start-position-y-coord set heading start-position-direction ; Print car info to console. print (word "Position " start-position ": " get-color-name-for-car-number who " car (" who "), " get-tyre-type-name tyre-type " tyre compound (" tyre-type "), " get-driving-style-name driving-style " driving style (" driving-style "), default speed: " precision speed 6 ".") set start-position start-position + 1 ] end ; Sets colors to cars so that we know which are which while simulation is running. to-report get-color-for-car-number [car-number] if (car-number = 0) [report black] if (car-number = 1) [report red] if (car-number = 2) [report blue] if (car-number = 3) [report yellow] if (car-number = 4) [report orange] if (car-number = 5) [report pink] if (car-number = 6) [report green] if (car-number = 7) [report brown] if (car-number = 8) [report violet] if (car-number = 9) [report sky] end ; Returns color name for the given car number. to-report get-color-name-for-car-number [car-number] if (car-number = 0) [report "black"] if (car-number = 1) [report "red"] if (car-number = 2) [report "blue"] if (car-number = 3) [report "yellow"] if (car-number = 4) [report "orange"] if (car-number = 5) [report "pink"] if (car-number = 6) [report "green"] if (car-number = 7) [report "brown"] if (car-number = 8) [report "violet"] if (car-number = 9) [report "sky"] end ; Changes the car's tyre wear. to change-tyre-wear let new-tyre-wear-rate 0 ifelse (tyre-type = 0) [ ; Soft tyre. set new-tyre-wear-rate s-wear-rate ] [ ifelse (tyre-type = 1) [ ; Medium tyre. set new-tyre-wear-rate m-wear-rate ] [ ; Hard tyre. set new-tyre-wear-rate h-wear-rate ] ] ifelse (driving-style = 0) [ ; Conservative driving style. set new-tyre-wear-rate (new-tyre-wear-rate * conservative-style-tyre-wear-adj) ] [ ifelse (driving-style = 1) [ ; Normal driving style. set new-tyre-wear-rate (new-tyre-wear-rate * normal-style-tyre-wear-adj) ] [ ; Aggresive driving style. set new-tyre-wear-rate (new-tyre-wear-rate * aggressive-style-tyre-wear-adj) ] ] set tyre-wear tyre-wear + new-tyre-wear-rate end ; Changes car tyres for some different ones. to change-tyres let new-tyre-type 0 ifelse (tyre-type = 0) [ ; Soft tyres were on, change them to some other compound. set new-tyre-type (random 2) + 1 ] [ ifelse (tyre-type = 1) [ ; Medium tyres are on. set new-tyre-type random 2 if (new-tyre-type = 1) [ ; The new compound is the same as the previous one, change it. set new-tyre-type 2 ] ] [ ; Hard tyres are on. set new-tyre-type random 2 ] ] ifelse (fancy-logs = true) [ print (word "The " get-color-name-for-car-number who " car (" who ") pitted in its " lap "th lap and changed tyres from the " get-tyre-type-name tyre-type " tyre compound (" tyre-type ") to the " get-tyre-type-name new-tyre-type " tyre compound (" new-tyre-type ").") ] [ print (word get-color-name-for-car-number who " " get-tyre-type-name tyre-type " > " get-tyre-type-name new-tyre-type) ] set tyre-type new-tyre-type set tyre-wear 0 set pit-stops pit-stops + 1 end ; Changes the car's lap number when it crosses the finish line. to change-lap-number let on-finish-line false ask current-patch [ if (finish-line = true) [ set on-finish-line true ] ] if (on-finish-line = true) [ set lap lap + 1 if (lap > current-lap) [ set current-lap lap ] put-car-to-list-of-positions length positions ; Change driving style every x laps. if (lap mod driving-style-change-lap = 0 and lap != 0) [ change-driving-style ] ] update-plots end ; Changes the driver's driving style. to change-driving-style let new-driving-style random 3 ifelse (fancy-logs = true) [ print (word "The " get-color-name-for-car-number who " car (" who ") changed its driving style from the " get-driving-style-name driving-style " driving style (" driving-style ") to the " get-driving-style-name new-driving-style " driving style (" new-driving-style ").") ] [ print (word get-color-name-for-car-number who " " get-driving-style-name driving-style " > " get-driving-style-name new-driving-style) ] set driving-style new-driving-style end ; Puts a car to the list of positions. to put-car-to-list-of-positions [amount-of-cars-in-list] ifelse (amount-of-cars-in-list = 0) [ set positions lput who positions ] [ ifelse (member? who positions) [ ; The car already is in the list. move-car-in-positions-list-up position who positions ] [ ; The car is not in the list yet. let last-car-laps 0 ask car item (amount-of-cars-in-list - 1) positions [ ; Ask the last car that crossed the finish line about its amount of laps. set last-car-laps lap ] ifelse (last-car-laps >= lap) [ ; The car that crossed the finish line ahead of this car drove the same amout of laps (or higher) as this car. ifelse (amount-of-cars-in-list = length positions) [ set positions lput who positions ] [ set positions replace-item amount-of-cars-in-list positions who ] ] [ ; The car that crossed the finish line ahead of this car drove fewer laps. Move it back one place in the list. ifelse (amount-of-cars-in-list = length positions) [ set positions lput (item (amount-of-cars-in-list - 1) positions) positions ] [ set positions replace-item amount-of-cars-in-list positions (item (amount-of-cars-in-list - 1) positions) ] put-car-to-list-of-positions (amount-of-cars-in-list - 1) ] ] ] end ; Moves the car in the positions list up so that it has the correct race position. to move-car-in-positions-list-up [car-position] ifelse (car-position = 0) [ set positions replace-item 0 positions who ] [ let laps-of-car-in-front 0 ask car (item (car-position - 1) positions) [ set laps-of-car-in-front lap ] ifelse (laps-of-car-in-front < lap) [ set positions replace-item car-position positions (item (car-position - 1) positions) move-car-in-positions-list-up (car-position - 1) ] [ set positions replace-item car-position positions who ] ] end ; Calculates the speed adjustment for the given tyre wear. to-report get-speed-adjustment-for-tyre-wear [car-tyre-wear] if (car-tyre-wear < 0.1) [ report speed-adjustment-for-wear-0-10 ] if (car-tyre-wear < 0.2) [ report speed-adjustment-for-wear-10-20 ] if (car-tyre-wear < 0.3) [ report speed-adjustment-for-wear-20-30 ] if (car-tyre-wear < 0.4) [ report speed-adjustment-for-wear-30-40 ] if (car-tyre-wear < 0.5) [ report speed-adjustment-for-wear-40-50 ] if (car-tyre-wear < 0.6) [ report speed-adjustment-for-wear-50-60 ] if (car-tyre-wear < 0.7) [ report speed-adjustment-for-wear-60-70 ] if (car-tyre-wear < 0.8) [ report speed-adjustment-for-wear-70-80 ] if (car-tyre-wear < 0.9) [ report speed-adjustment-for-wear-80-90 ] if (car-tyre-wear < 1) [ report speed-adjustment-for-wear-90-100 ] end ; Returns actual car speed (adjusted by tyre type and tyre wear). to-report get-actual-car-speed [car-speed car-tyre-type car-tyre-wear car-drs on-drs-zone in-pits on-finish-line drivers-driving-style] if (current-lap > amount-of-laps and on-finish-line = true) [ report 0 ] if (in-pits = true) [ report pit-speed ] let reported-speed 0 ifelse (car-tyre-type = 0) [ ; Soft tyre compound. set reported-speed (speed * s-speed-adj * (get-speed-adjustment-for-tyre-wear car-tyre-wear)) ] [ ifelse (car-tyre-type = 1) [ ; Medium tyre. set reported-speed (speed * m-speed-adj * (get-speed-adjustment-for-tyre-wear car-tyre-wear)) ] [ ; Hard tyre. set reported-speed (speed * h-speed-adj * (get-speed-adjustment-for-tyre-wear car-tyre-wear)) ] ] ifelse (drivers-driving-style = 0) [ ; Conservative driving style. set reported-speed (reported-speed * conservative-driving-style-speed-adjustment) ] [ ifelse (drivers-driving-style = 1) [ ; Normal driving style. set reported-speed (reported-speed * normal-driving-style-speed-adjustment) ] [ ; Aggresive driving style. set reported-speed (reported-speed * aggressive-driving-style-speed-adjustment) ] ] if (drs = true and on-drs-zone = true) [ report reported-speed * drs-speed-adjustment ] report reported-speed end ; Returns actual car speed for a given car number (used in monitors). to-report get-actual-car-speed-for-car-number [car-number] let reported-speed 0 let on-drs-zone false let in-pits false let on-finish-line false ask cars [ ask patch-here [ set on-drs-zone drs-zone set in-pits pit set on-finish-line finish-line ] if (who = car-number) [ set reported-speed get-actual-car-speed speed tyre-type tyre-wear drs on-drs-zone in-pits on-finish-line driving-style ] ] report reported-speed end ; Reports position of the given car number. to-report get-car-position [car-number] if (member? car-number positions) [ report (position car-number positions) + 1 ] end ; For the given tyre type number returns the tyre type name. to-report get-tyre-type-name [tyre-type-number] if (tyre-type-number = 0) [ report "soft" ] if (tyre-type-number = 1) [ report "medium" ] report "hard" end ; For the given driving style number returns the driving style name. to-report get-driving-style-name [driving-style-number] if (driving-style-number = 0) [ report "conservative" ] if (driving-style-number = 1) [ report "normal" ] report "aggressive" end @#$#@#$#@ GRAPHICS-WINDOW 192 10 1032 578 -1 -1 13.0 1 10 1 1 1 0 1 1 1 0 63 0 42 0 0 1 ticks 30.0 BUTTON 96 349 182 382 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 11 349 96 382 NIL go T 1 T OBSERVER NIL NIL NIL NIL 1 SLIDER 10 65 182 98 amount-of-cars amount-of-cars 1 10 10.0 1 1 NIL HORIZONTAL SLIDER 10 225 182 258 lowest-speed lowest-speed 0.0005 0.001 0.001 0.00005 1 NIL HORIZONTAL SLIDER 10 258 182 291 highest-speed highest-speed 0.001 0.0015 0.00105 0.00005 1 NIL HORIZONTAL SLIDER 1903 130 2044 163 s-speed-adj s-speed-adj 0.9 1.1 1.05 0.01 1 NIL HORIZONTAL SLIDER 2044 130 2185 163 m-speed-adj m-speed-adj 0.9 1.1 1.0 0.01 1 NIL HORIZONTAL TEXTBOX 1904 10 2054 28 Tyres 11 0.0 1 SLIDER 2185 130 2326 163 h-speed-adj h-speed-adj 0.9 1.1 0.95 0.01 1 NIL HORIZONTAL SLIDER 1903 97 2044 130 s-wear-rate s-wear-rate 0 0.0008 4.0E-4 0.00001 1 NIL HORIZONTAL SLIDER 2044 97 2185 130 m-wear-rate m-wear-rate 0 0.0008 2.5E-4 0.00001 1 NIL HORIZONTAL SLIDER 2185 97 2326 130 h-wear-rate h-wear-rate 0 0.0008 1.0E-4 0.00001 1 NIL HORIZONTAL SLIDER 1902 32 2327 65 max-tyre-wear max-tyre-wear 0 1 0.4 0.01 1 NIL HORIZONTAL SLIDER 10 98 182 131 pit-speed pit-speed 0.0001 0.0005 4.0E-4 0.00001 1 NIL HORIZONTAL MONITOR 1041 43 1091 88 Black [lap] of car 0 0 1 11 MONITOR 1041 88 1091 133 Red [lap] of car 1 0 1 11 MONITOR 1041 133 1091 178 Blue [lap] of car 2 0 1 11 MONITOR 1041 178 1091 223 Yellow [lap] of car 3 0 1 11 MONITOR 1041 223 1091 268 Orange [lap] of car 4 0 1 11 MONITOR 1041 268 1091 313 Pink [lap] of car 5 0 1 11 MONITOR 1041 313 1091 358 Green [lap] of car 6 0 1 11 MONITOR 1041 358 1091 403 Brown [lap] of car 7 0 1 11 MONITOR 1041 403 1091 448 Violet [lap] of car 8 0 1 11 MONITOR 1041 448 1091 493 Sky [lap] of car 9 0 1 11 MONITOR 1091 43 1148 88 Black get-tyre-type-name [tyre-type] of car 0 0 1 11 MONITOR 1091 88 1148 133 Red get-tyre-type-name [tyre-type] of car 1 0 1 11 MONITOR 1091 133 1148 178 Blue get-tyre-type-name [tyre-type] of car 2 0 1 11 MONITOR 1091 178 1148 223 Yellow get-tyre-type-name [tyre-type] of car 3 0 1 11 MONITOR 1091 223 1148 268 Orange get-tyre-type-name [tyre-type] of car 4 0 1 11 MONITOR 1091 268 1148 313 Pink get-tyre-type-name [tyre-type] of car 5 0 1 11 MONITOR 1091 313 1148 358 Green get-tyre-type-name [tyre-type] of car 6 0 1 11 MONITOR 1091 358 1148 403 Brown get-tyre-type-name [tyre-type] of car 7 0 1 11 MONITOR 1091 403 1148 448 Violet get-tyre-type-name [tyre-type] of car 8 0 1 11 MONITOR 1091 448 1148 493 Sky get-tyre-type-name [tyre-type] of car 9 0 1 11 TEXTBOX 1044 10 1086 38 Lap\nnumber 11 0.0 1 TEXTBOX 1095 10 1146 52 Tyre\ncompound 11 0.0 1 MONITOR 1280 43 1337 88 Black [tyre-wear] of car 0 4 1 11 MONITOR 1280 88 1337 133 Red [tyre-wear] of car 1 4 1 11 MONITOR 1280 133 1337 178 Blue [tyre-wear] of car 2 4 1 11 MONITOR 1280 178 1337 223 Yellow [tyre-wear] of car 3 4 1 11 MONITOR 1280 223 1337 268 Orange [tyre-wear] of car 4 4 1 11 MONITOR 1280 268 1337 313 Pink [tyre-wear] of car 5 4 1 11 MONITOR 1280 313 1337 358 Green [tyre-wear] of car 6 4 1 11 MONITOR 1280 358 1337 403 Brown [tyre-wear] of car 7 4 1 11 MONITOR 1280 403 1337 448 Violet [tyre-wear] of car 8 4 1 11 MONITOR 1280 448 1337 493 Sky [tyre-wear] of car 9 4 1 11 TEXTBOX 1283 10 1330 38 Tyre\nwear 11 0.0 1 TEXTBOX 1341 10 1427 38 Default\nspeed 11 0.0 1 MONITOR 1337 43 1402 88 Black [speed] of car 0 6 1 11 MONITOR 1337 88 1402 133 Red [speed] of car 1 6 1 11 MONITOR 1337 133 1402 178 Blue [speed] of car 2 6 1 11 MONITOR 1337 178 1402 223 Yellow [speed] of car 3 6 1 11 MONITOR 1337 223 1402 268 Orange [speed] of car 4 6 1 11 MONITOR 1337 268 1402 313 Pink [speed] of car 5 6 1 11 MONITOR 1337 313 1402 358 Green [speed] of car 6 6 1 11 MONITOR 1337 358 1402 403 Brown [speed] of car 7 6 1 11 MONITOR 1337 403 1402 448 Violet [speed] of car 8 6 1 11 MONITOR 1337 448 1402 493 Sky [speed] of car 9 6 1 11 MONITOR 1402 43 1470 88 Black get-actual-car-speed-for-car-number 0 6 1 11 MONITOR 1402 88 1470 133 Red get-actual-car-speed-for-car-number 1 6 1 11 MONITOR 1402 133 1470 178 Blue get-actual-car-speed-for-car-number 2 6 1 11 MONITOR 1402 178 1470 223 Yellow get-actual-car-speed-for-car-number 3 6 1 11 MONITOR 1402 223 1470 268 Orange get-actual-car-speed-for-car-number 4 6 1 11 MONITOR 1402 268 1470 313 Pink get-actual-car-speed-for-car-number 5 6 1 11 MONITOR 1402 313 1470 358 Green get-actual-car-speed-for-car-number 6 6 1 11 MONITOR 1402 358 1470 403 Brown get-actual-car-speed-for-car-number 7 6 1 11 MONITOR 1402 403 1470 448 Violet get-actual-car-speed-for-car-number 8 6 1 11 MONITOR 1402 448 1470 493 Sky get-actual-car-speed-for-car-number 9 6 1 11 TEXTBOX 1406 10 1470 38 Actual\nspeed 11 0.0 1 SLIDER 1903 163 2326 196 speed-adjustment-for-wear-0-10 speed-adjustment-for-wear-0-10 0 1 1.0 0.01 1 NIL HORIZONTAL SLIDER 1903 196 2326 229 speed-adjustment-for-wear-10-20 speed-adjustment-for-wear-10-20 0 1 0.98 0.01 1 NIL HORIZONTAL TEXTBOX 1905 75 2055 93 Soft tyre compound 11 0.0 1 TEXTBOX 2046 75 2196 93 Medium tyre compound 11 0.0 1 TEXTBOX 2188 75 2311 93 Hard tyre compound 11 0.0 1 SLIDER 1903 229 2326 262 speed-adjustment-for-wear-20-30 speed-adjustment-for-wear-20-30 0 1 0.96 0.01 1 NIL HORIZONTAL SLIDER 1903 262 2326 295 speed-adjustment-for-wear-30-40 speed-adjustment-for-wear-30-40 0 1 0.94 0.01 1 NIL HORIZONTAL SLIDER 1903 295 2326 328 speed-adjustment-for-wear-40-50 speed-adjustment-for-wear-40-50 0 1 0.91 0.01 1 NIL HORIZONTAL SLIDER 1903 328 2326 361 speed-adjustment-for-wear-50-60 speed-adjustment-for-wear-50-60 0 1 0.88 0.01 1 NIL HORIZONTAL SLIDER 1903 361 2326 394 speed-adjustment-for-wear-60-70 speed-adjustment-for-wear-60-70 0 1 0.82 0.01 1 NIL HORIZONTAL SLIDER 1903 394 2326 427 speed-adjustment-for-wear-70-80 speed-adjustment-for-wear-70-80 0 1 0.75 0.01 1 NIL HORIZONTAL SLIDER 1903 427 2326 460 speed-adjustment-for-wear-80-90 speed-adjustment-for-wear-80-90 0 1 0.6 0.01 1 NIL HORIZONTAL SLIDER 1903 460 2326 493 speed-adjustment-for-wear-90-100 speed-adjustment-for-wear-90-100 0 1 0.3 0.01 1 NIL HORIZONTAL SLIDER 10 32 182 65 amount-of-laps amount-of-laps 1 100 20.0 1 1 NIL HORIZONTAL TEXTBOX 17 10 167 28 Race parameters 11 0.0 1 TEXTBOX 17 203 167 221 Car parameters 11 0.0 1 SLIDER 10 131 182 164 drs-speed-adjustment drs-speed-adjustment 0 2 1.5 0.1 1 NIL HORIZONTAL MONITOR 950 14 1028 59 Lap number current-lap 0 1 11 SLIDER 10 164 182 197 drs-detection-threshold drs-detection-threshold 0 1 0.5 0.1 1 NIL HORIZONTAL PLOT 1470 43 1893 493 NIL Lap Position 0.0 21.0 0.0 11.0 true false "" "" PENS "Black" 1.0 0 -16777216 true "" "plotxy [lap] of car 0 get-car-position 0" "Red" 1.0 0 -2674135 true "" "plotxy [lap] of car 1 get-car-position 1" "Blue" 1.0 0 -13345367 true "" "plotxy [lap] of car 2 get-car-position 2" "Yellow" 1.0 0 -1184463 true "" "plotxy [lap] of car 3 get-car-position 3" "Orange" 1.0 0 -955883 true "" "plotxy [lap] of car 4 get-car-position 4" "Pink" 1.0 0 -2064490 true "" "plotxy [lap] of car 5 get-car-position 5" "Green" 1.0 0 -10899396 true "" "plotxy [lap] of car 6 get-car-position 6" "Brown" 1.0 0 -6459832 true "" "plotxy [lap] of car 7 get-car-position 7" "Violet" 1.0 0 -8630108 true "" "plotxy [lap] of car 8 get-car-position 8" "Sky" 1.0 0 -13791810 true "" "plotxy [lap] of car 9 get-car-position 9" SLIDER 2341 32 2604 65 conservative-driving-style-speed-adjustment conservative-driving-style-speed-adjustment 0.9 1.1 0.95 0.01 1 NIL HORIZONTAL SLIDER 2604 32 2867 65 normal-driving-style-speed-adjustment normal-driving-style-speed-adjustment 0.9 1.1 1.0 0.01 1 NIL HORIZONTAL SLIDER 2867 32 3130 65 aggressive-driving-style-speed-adjustment aggressive-driving-style-speed-adjustment 0.9 1.1 1.05 0.01 1 NIL HORIZONTAL TEXTBOX 2343 10 2493 28 Driving style effect 11 0.0 1 SLIDER 2341 65 2605 98 conservative-style-tyre-wear-adj conservative-style-tyre-wear-adj 0.8 1.2 0.8 0.01 1 NIL HORIZONTAL SLIDER 2605 65 2867 98 normal-style-tyre-wear-adj normal-style-tyre-wear-adj 0.8 1.2 1.0 0.01 1 NIL HORIZONTAL SLIDER 2867 65 3130 98 aggressive-style-tyre-wear-adj aggressive-style-tyre-wear-adj 0.8 1.2 1.15 0.01 1 NIL HORIZONTAL SLIDER 2342 128 2526 161 driving-style-change-lap driving-style-change-lap 1 100 5.0 1 1 NIL HORIZONTAL TEXTBOX 2344 107 2647 125 Change driving style every laps 11 0.0 1 SWITCH 11 316 182 349 fancy-logs fancy-logs 1 1 -1000 TEXTBOX 18 299 168 317 Simulation 11 0.0 1 TEXTBOX 1156 10 1192 38 Driving\nstyle 11 0.0 1 MONITOR 1148 43 1230 88 Black get-driving-style-name [driving-style] of car 0 17 1 11 MONITOR 1148 88 1230 133 Red get-driving-style-name [driving-style] of car 1 17 1 11 MONITOR 1148 133 1230 178 Blue get-driving-style-name [driving-style] of car 2 17 1 11 MONITOR 1148 178 1230 223 Yellow get-driving-style-name [driving-style] of car 3 17 1 11 MONITOR 1148 223 1230 268 Orange get-driving-style-name [driving-style] of car 4 17 1 11 MONITOR 1148 268 1230 313 Pink get-driving-style-name [driving-style] of car 5 17 1 11 MONITOR 1148 313 1230 358 Green get-driving-style-name [driving-style] of car 6 17 1 11 MONITOR 1148 358 1230 403 Brown get-driving-style-name [driving-style] of car 7 17 1 11 MONITOR 1148 403 1230 448 Violet get-driving-style-name [driving-style] of car 8 17 1 11 MONITOR 1148 448 1230 493 Sky get-driving-style-name [driving-style] of car 9 17 1 11 MONITOR 1230 43 1280 88 Black [pit-stops] of car 0 0 1 11 MONITOR 1230 88 1280 133 Red [pit-stops] of car 1 0 1 11 MONITOR 1230 133 1280 178 Blue [pit-stops] of car 2 0 1 11 MONITOR 1230 178 1280 223 Yellow [pit-stops] of car 3 0 1 11 MONITOR 1230 223 1280 268 Orange [pit-stops] of car 4 0 1 11 MONITOR 1230 268 1280 313 Pink [pit-stops] of car 5 0 1 11 MONITOR 1230 313 1280 358 Green [pit-stops] of car 6 0 1 11 MONITOR 1230 358 1280 403 Brown [pit-stops] of car 7 0 1 11 MONITOR 1230 403 1280 448 Violet [pit-stops] of car 8 0 1 11 MONITOR 1230 448 1280 493 Sky [pit-stops] of car 9 0 1 11 TEXTBOX 1480 10 1595 38 Car positions development 11 0.0 1 TEXTBOX 1234 10 1264 38 Pit\nstops 11 0.0 1 @#$#@#$#@ ## WHAT IS IT? (a general understanding of what the model is trying to show or explain) ## HOW IT WORKS (what rules the agents use to create the overall behavior of the model) ## HOW TO USE IT (how to use the model, including a description of each of the items in the Interface tab) ## THINGS TO NOTICE (suggested things for the user to notice while running the model) ## THINGS TO TRY (suggested things for the user to try to do (move sliders, switches, etc.) with the model) ## EXTENDING THE MODEL (suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.) ## NETLOGO FEATURES (interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features) ## RELATED MODELS (models in the NetLogo Models Library and elsewhere which are of related interest) ## CREDITS AND REFERENCES (a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links) @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 15 Circle -1 true true 203 65 88 Circle -1 true true 70 65 162 Circle -1 true true 150 105 120 Polygon -7500403 true false 218 120 240 165 255 165 278 120 Circle -7500403 true false 214 72 67 Rectangle -1 true true 164 223 179 298 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210 Circle -1 true true 3 83 150 Rectangle -1 true true 65 221 80 296 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210 Polygon -7500403 true false 276 85 285 105 302 99 294 83 Polygon -7500403 true false 219 85 210 105 193 99 201 83 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Polygon -16777216 true false 253 133 245 131 245 133 Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105 Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 6.0.4 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@