my_EM_CW_cpy/0000755000175000017500000000000011327466211011467 5ustar wmbwmbmy_EM_CW_cpy/mySprites/0000755000175000017500000000000011325675352013474 5ustar wmbwmbmy_EM_CW_cpy/JonCaseyCW.dasm~0000644000175000017500000014320011327466140014501 0ustar wmbwmbthis widgets root = (new type = Widget x = 0 y = 0 width is { @window width } height is { @window height } frame = 0 visible = true border = 0 sprite = (new union (@prototypes sprite) frames = 1 columns = 1 rows = 1 filename = "../wgd/emdesk.png" ) children = (@screen = (new)) ); @screen mywindow = (new union (@prototypes window) x = 0 y = 0 width = 790 height = 520 title = "M6 congestion Model" currentMotorwayViewRegion = 0 currentMotorwayViewRegion is { if (@screen mywindow children leftButton click) { .currentMotorwayViewRegion + 400 } else { if (@screen mywindow children rightButton click) { .currentMotorwayViewRegion - 400 } else .currentMotorwayViewRegion } } #Animation Tick Event (at most every 0.05 seconds) = 20fps ticktime is { if (.tick) { @root time } else { .ticktime } } tick is { if (@root time - (.ticktime) > 0.05 ) { true } else { false } } ); #Left/Right naviation buttons + @screen mywindow children leftButton = (new union (@prototypes button) x = 20 y is { @screen mywindow height - (.height) - 20 } width = 80 caption = "<<" ); @screen mywindow children rightButton = (new union (@prototypes button) x is { @screen mywindow width - (.width) - 20 } y is { @screen mywindow height - (.height) - 20 } width = 80 caption = ">>" ); @screen mywindow children leftLabel = (new union (@prototypes label) x = 10 y is { @screen mywindow height - 20 } caption is { @screen mywindow currentMotorwayViewRegion * -1 / 2 } ); @screen mywindow children rightLabel = (new union (@prototypes label) x is { @screen mywindow width - 80 } y is { @screen mywindow height - 20 } caption is { @screen mywindow currentMotorwayViewRegion * -1 / 2 + (790 / 2) } ); @screen mywindow children centerLabel = (new union (@prototypes label) x is { @screen mywindow width / 2 - 170 } y is { @screen mywindow height - 20 } caption is { "<-------------------- (measured in meters) ------------------->" } ); #Motorway Properties @screen mywindow children MotorwayProperties = (new # Real length from Junction 12 to junction 4 via M6 is 40,925 meters # Distances are scaled down 1:10 so the modelled distance is 4,093m M6Length = 1000 # 4093 # Distances from J12 to J4 via M6 is slightly shorter than by M6 Toll. # But as model doesn't support curves, the distances is assumed to be equal. # Real length from Junction 12 to junction 11 via M6 is 3,750 meters M6TollRelativeStart = 375 #Distace from start of M6 to where M6 Toll starts # Real length from Junction 12 to junction 4 via M6 is 37,355 meters M6TollRelativeEnd = 800 # 3736 #Distance from start of M6 where M6 Toll rejoins it SpeedLimit = 31.3 # 31.3 meters/s == 70 miles/h ); #M6 Motorway Lines @screen mywindow children M6_Line1 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y = 450 # This sets the verticle offset of the entire motorway system. (horisontal is always zero) width is { @screen mywindow children MotorwayProperties M6TollRelativeStart * 2 } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Line1_b = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line4 x } y = 450 # This sets the verticle offset of the entire motorway system. (horisontal is always zero) width is { @screen mywindow children M6_Toll_Junc2_Line1 x - ( @screen mywindow children M6_Toll_Junc_Line4 x ) } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Line1_c = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line4 x } y = 450 # This sets the verticle offset of the entire motorway system. (horisontal is always zero) width is { 2 * ( @screen mywindow children MotorwayProperties M6Length - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Line2 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y is { @screen mywindow children M6_Line1 y + 10 } width is { @screen mywindow children MotorwayProperties M6Length * 2 } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Line3 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y is { @screen mywindow children M6_Line1 y + 20 } width is { @screen mywindow children MotorwayProperties M6Length * 2 } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Line4 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y is { @screen mywindow children M6_Line1 y + 30 } width is { @screen mywindow children MotorwayProperties M6Length * 2 } height = 2 filename = "mySprites/blackSprite.png" ); #M6 -> M6 Toll Junction Lines @screen mywindow children JunctionLabel = (new union (@prototypes label) x is { @screen mywindow currentMotorwayViewRegion + ( 2 * ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) - 20 } y is { @screen mywindow children M6_Line1 y - ( @screen mywindow children M6_Toll_Junc_Line1 height ) - 50 } caption is { "M6 Toll" } ); @screen mywindow children M6_Toll_Junc_Line1 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion + ( 2 * ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) } y is { @screen mywindow children M6_Line1 y - ( @screen mywindow children M6_Toll_Junc_Line1 height ) } width = 2 height = 150 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Junc_Line2 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x + 10 } y is { @screen mywindow children M6_Toll_Junc_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc_Line3 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x + 20 } y is { @screen mywindow children M6_Toll_Junc_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc_Line4 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x + 30 } y is { @screen mywindow children M6_Toll_Junc_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/blackSprite.png" ); #M6 Toll Motorway Lines @screen mywindow children M6_Toll_Line1 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x } y is { @screen mywindow children M6_Toll_Junc_Line1 y - 30 } width is { 2 * (@screen mywindow children MotorwayProperties M6TollRelativeEnd - ( @screen mywindow children MotorwayProperties M6TollRelativeStart)) } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Line2 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Line1 x } y is { @screen mywindow children M6_Toll_Line1 y + 10 } width is { @screen mywindow children M6_Toll_Line1 width } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Line3 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Line1 x } y is { @screen mywindow children M6_Toll_Line1 y + 20 } width is { @screen mywindow children M6_Toll_Line1 width } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Line4 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Line1 x + 30 } y is { @screen mywindow children M6_Toll_Line1 y + 30 } width is { @screen mywindow children M6_Toll_Line1 width - 60 } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Line_StartCAP = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x } y is { @screen mywindow children M6_Toll_Junc_Line1 y - 30 } width = 2 height = 30 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Line_EndCAP = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line4 x } y is { @screen mywindow children M6_Toll_Junc2_Line1 y - 30 } width = 2 height = 30 filename = "mySprites/blackSprite.png" ); #M6 Toll -> M6 Junction Lines @screen mywindow children M6_Toll_Junc2_Line1 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion + ( @screen mywindow children MotorwayProperties M6TollRelativeEnd * 2 ) - 30 } y is { @screen mywindow children M6_Line1 y - ( @screen mywindow children M6_Toll_Junc_Line1 height ) } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Junc2_Line2 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line1 x + 10 } y is { @screen mywindow children M6_Toll_Junc2_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc2_Line3 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line1 x + 20 } y is { @screen mywindow children M6_Toll_Junc2_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc2_Line4 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line1 x + 30 } y is { @screen mywindow children M6_Toll_Junc2_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/blackSprite.png" ); #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #!!!!!!!!!!!!!!!!! CAR AGENTS !!!!!!!!!!!!!!!!!!!!! #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #Car Speed of car 1: @screen mywindow children car1SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car1 x + 20 } y is { @screen mywindow children Car1 y - 40 } caption is { @screen mywindow children Car1 Speed } visible is { @screen mywindow children Car1 visible } ); @screen mywindow children Car1 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 70) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (60 == (.TickCounter))) { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == 1) and (@screen mywindow children Car2 Motorway == 1) and (10 > (@screen mywindow children Car2 Distance))) { false } else if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == 1) and (@screen mywindow children Car3 Motorway == 1) and (10 > (@screen mywindow children Car3 Distance))) { false } else if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == 1) and (@screen mywindow children Car4 Motorway == 1) and (10 > (@screen mywindow children Car4 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = true Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { true #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 #} else if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront) and (.TimeSplitWithCarInLaneAbove > (.TimeSplitWithCarInfront)) and (.Lane < 3)) { # .Lane + 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 60 RateToAccelerate = 4.5 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar2 = 10 TimeSplitWithCar2 is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3 = 10 TimeSplitWithCar3 is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4 = 10 TimeSplitWithCar4 is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar2 < (.TimeSplitWithCar3) and (.TimeSplitWithCar2 < (.TimeSplitWithCar4))) { .TimeSplitWithCar2 } else if (.TimeSplitWithCar3 < (.TimeSplitWithCar2) and (.TimeSplitWithCar3 < (.TimeSplitWithCar4))) { .TimeSplitWithCar3 } else if (.TimeSplitWithCar4 < (.TimeSplitWithCar2) and (.TimeSplitWithCar4 < (.TimeSplitWithCar3))) { .TimeSplitWithCar4 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car2 Active) and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car2 Distance - (.Distance))) and (-4 < (@screen mywindow children Car2 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car3 Active) and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car3 Distance - (.Distance))) and (-4 < (@screen mywindow children Car3 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car4 Active) and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car4 Distance - (.Distance))) and (-4 < (@screen mywindow children Car4 Distance - (.Distance)))) { true } else { .Crashed } } TimeSplitWithCar2LaneAbove = 10 TimeSplitWithCar2LaneAbove is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane + 1)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (-8 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3LaneAbove = 10 TimeSplitWithCar3LaneAbove is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane + 1)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (-8 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4LaneAbove = 10 TimeSplitWithCar4LaneAbove is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane + 1)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (-8 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInLaneAbove = 10 TimeSplitWithCarInLaneAbove is { if (.TimeSplitWithCar2LaneAbove < (.TimeSplitWithCar3LaneAbove) and (.TimeSplitWithCar2LaneAbove < (.TimeSplitWithCar4LaneAbove))) { .TimeSplitWithCar2LaneAbove } else if (.TimeSplitWithCar3LaneAbove < (.TimeSplitWithCar2LaneAbove) and (.TimeSplitWithCar3LaneAbove < (.TimeSplitWithCar4LaneAbove))) { .TimeSplitWithCar3LaneAbove } else if (.TimeSplitWithCar4LaneAbove < (.TimeSplitWithCar2LaneAbove) and (.TimeSplitWithCar4LaneAbove < (.TimeSplitWithCar3LaneAbove))) { .TimeSplitWithCar4LaneAbove } else { 10 } } ); #Car Speed of car 2: @screen mywindow children car2SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car2 x + 20 } y is { @screen mywindow children Car2 y - 40 } caption is { @screen mywindow children Car2 Speed } visible is { @screen mywindow children Car2 visible } ); @screen mywindow children Car2 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 400) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (50 == (.TickCounter))) { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == 1) and (@screen mywindow children Car1 Motorway == 1) and (10 > (@screen mywindow children Car1 Distance))) { false } else if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == 1) and (@screen mywindow children Car3 Motorway == 1) and (10 > (@screen mywindow children Car3 Distance))) { false } else if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == 1) and (@screen mywindow children Car4 Motorway == 1) and (10 > (@screen mywindow children Car4 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = false Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { false #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 20 RateToAccelerate = 3.6 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar1 = 10 TimeSplitWithCar1 is { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car1 Distance - (.Distance)))) { @screen mywindow children Car1 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3 = 10 TimeSplitWithCar3 is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4 = 10 TimeSplitWithCar4 is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar1 < (.TimeSplitWithCar3) and (.TimeSplitWithCar1 < (.TimeSplitWithCar4))) { .TimeSplitWithCar1 } else if (.TimeSplitWithCar3 < (.TimeSplitWithCar1) and (.TimeSplitWithCar3 < (.TimeSplitWithCar4))) { .TimeSplitWithCar3 } else if (.TimeSplitWithCar4 < (.TimeSplitWithCar1) and (.TimeSplitWithCar4 < (.TimeSplitWithCar3))) { .TimeSplitWithCar4 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car1 Active) and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car1 Distance - (.Distance))) and (-4 < (@screen mywindow children Car1 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car3 Active) and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car3 Distance - (.Distance))) and (-4 < (@screen mywindow children Car3 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car4 Active) and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car4 Distance - (.Distance))) and (-4 < (@screen mywindow children Car4 Distance - (.Distance)))) { true } else { .Crashed } } ); #Car Speed of car 3: @screen mywindow children car3SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car3 x + 20 } y is { @screen mywindow children Car3 y - 40 } caption is { @screen mywindow children Car3 Speed } visible is { @screen mywindow children Car3 visible } ); @screen mywindow children Car3 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 400) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (150 == (.TickCounter))) { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == 1) and (@screen mywindow children Car1 Motorway == 1) and (10 > (@screen mywindow children Car1 Distance))) { false } else if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == 1) and (@screen mywindow children Car2 Motorway == 1) and (10 > (@screen mywindow children Car2 Distance))) { false } else if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == 1) and (@screen mywindow children Car4 Motorway == 1) and (10 > (@screen mywindow children Car4 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = true Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { true #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 5 RateToAccelerate = 3.2 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar1 = 10 TimeSplitWithCar1 is { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car1 Distance - (.Distance)))) { @screen mywindow children Car1 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar2 = 10 TimeSplitWithCar2 is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4 = 10 TimeSplitWithCar4 is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar1 < (.TimeSplitWithCar2) and (.TimeSplitWithCar1 < (.TimeSplitWithCar4))) { .TimeSplitWithCar1 } else if (.TimeSplitWithCar2 < (.TimeSplitWithCar1) and (.TimeSplitWithCar2 < (.TimeSplitWithCar4))) { .TimeSplitWithCar2 } else if (.TimeSplitWithCar4 < (.TimeSplitWithCar1) and (.TimeSplitWithCar4 < (.TimeSplitWithCar2))) { .TimeSplitWithCar4 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car2 Active) and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car2 Distance - (.Distance))) and (-4 < (@screen mywindow children Car2 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car1 Active) and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car1 Distance - (.Distance))) and (-4 < (@screen mywindow children Car1 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car4 Active) and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car4 Distance - (.Distance))) and (-4 < (@screen mywindow children Car4 Distance - (.Distance)))) { true } else { .Crashed } } ); #Car Speed of car 4: @screen mywindow children car4SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car4 x + 20 } y is { @screen mywindow children Car4 y - 40 } caption is { @screen mywindow children Car4 Speed } visible is { @screen mywindow children Car4 visible } ); @screen mywindow children Car4 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 400) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (200 == (.TickCounter))) { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == 1) and (@screen mywindow children Car1 Motorway == 1) and (10 > (@screen mywindow children Car1 Distance))) { false } else if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == 1) and (@screen mywindow children Car2 Motorway == 1) and (10 > (@screen mywindow children Car2 Distance))) { false } else if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == 1) and (@screen mywindow children Car3 Motorway == 1) and (10 > (@screen mywindow children Car3 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = true Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { true #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 15 RateToAccelerate = 2.8 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar1 = 10 TimeSplitWithCar1 is { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car1 Distance - (.Distance)))) { @screen mywindow children Car1 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar2 = 10 TimeSplitWithCar2 is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3 = 10 TimeSplitWithCar3 is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar1 < (.TimeSplitWithCar2) and (.TimeSplitWithCar1 < (.TimeSplitWithCar3))) { .TimeSplitWithCar1 } else if (.TimeSplitWithCar2 < (.TimeSplitWithCar1) and (.TimeSplitWithCar2 < (.TimeSplitWithCar3))) { .TimeSplitWithCar2 } else if (.TimeSplitWithCar3 < (.TimeSplitWithCar1) and (.TimeSplitWithCar3 < (.TimeSplitWithCar2))) { .TimeSplitWithCar3 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car2 Active) and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car2 Distance - (.Distance))) and (-4 < (@screen mywindow children Car2 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car3 Active) and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car3 Distance - (.Distance))) and (-4 < (@screen mywindow children Car3 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car1 Active) and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car1 Distance - (.Distance))) and (-4 < (@screen mywindow children Car1 Distance - (.Distance)))) { true } else { .Crashed } } ); my_EM_CW_cpy/JonCaseyCW.dasm0000644000175000017500000014320011327466156014312 0ustar wmbwmbthis widgets root = (new type = Widget x = 0 y = 0 width is { @window width } height is { @window height } frame = 0 visible = true border = 0 sprite = (new union (@prototypes sprite) frames = 1 columns = 1 rows = 1 filename = "../wgd/emdesk.png" ) children = (@screen = (new)) ); @screen mywindow = (new union (@prototypes window) x = 0 y = 0 width = 790 height = 520 title = "M6 congestion Model" currentMotorwayViewRegion = 0 currentMotorwayViewRegion is { if (@screen mywindow children leftButton click) { .currentMotorwayViewRegion + 400 } else { if (@screen mywindow children rightButton click) { .currentMotorwayViewRegion - 400 } else .currentMotorwayViewRegion } } #Animation Tick Event (at most every 0.05 seconds) = 20fps ticktime is { if (.tick) { @root time } else { .ticktime } } tick is { if (@root time - (.ticktime) > 0.05 ) { true } else { false } } ); #Left/Right naviation buttons + @screen mywindow children leftButton = (new union (@prototypes button) x = 20 y is { @screen mywindow height - (.height) - 20 } width = 80 caption = "<<" ); @screen mywindow children rightButton = (new union (@prototypes button) x is { @screen mywindow width - (.width) - 20 } y is { @screen mywindow height - (.height) - 20 } width = 80 caption = ">>" ); @screen mywindow children leftLabel = (new union (@prototypes label) x = 10 y is { @screen mywindow height - 20 } caption is { @screen mywindow currentMotorwayViewRegion * -1 / 2 } ); @screen mywindow children rightLabel = (new union (@prototypes label) x is { @screen mywindow width - 80 } y is { @screen mywindow height - 20 } caption is { @screen mywindow currentMotorwayViewRegion * -1 / 2 + (790 / 2) } ); @screen mywindow children centerLabel = (new union (@prototypes label) x is { @screen mywindow width / 2 - 170 } y is { @screen mywindow height - 20 } caption is { "<-------------------- (measured in meters) ------------------->" } ); #Motorway Properties @screen mywindow children MotorwayProperties = (new # Real length from Junction 12 to junction 4 via M6 is 40,925 meters # Distances are scaled down 1:10 so the modelled distance is 4,093m M6Length = 1000 # 4093 # Distances from J12 to J4 via M6 is slightly shorter than by M6 Toll. # But as model doesn't support curves, the distances is assumed to be equal. # Real length from Junction 12 to junction 11 via M6 is 3,750 meters M6TollRelativeStart = 375 #Distace from start of M6 to where M6 Toll starts # Real length from Junction 12 to junction 4 via M6 is 37,355 meters M6TollRelativeEnd = 800 # 3736 #Distance from start of M6 where M6 Toll rejoins it SpeedLimit = 31.3 # 31.3 meters/s == 70 miles/h ); #M6 Motorway Lines @screen mywindow children M6_Line1 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y = 450 # This sets the verticle offset of the entire motorway system. (horisontal is always zero) width is { @screen mywindow children MotorwayProperties M6TollRelativeStart * 2 } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Line1_b = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line4 x } y = 450 # This sets the verticle offset of the entire motorway system. (horisontal is always zero) width is { @screen mywindow children M6_Toll_Junc2_Line1 x - ( @screen mywindow children M6_Toll_Junc_Line4 x ) } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Line1_c = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line4 x } y = 450 # This sets the verticle offset of the entire motorway system. (horisontal is always zero) width is { 2 * ( @screen mywindow children MotorwayProperties M6Length - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Line2 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y is { @screen mywindow children M6_Line1 y + 10 } width is { @screen mywindow children MotorwayProperties M6Length * 2 } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Line3 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y is { @screen mywindow children M6_Line1 y + 20 } width is { @screen mywindow children MotorwayProperties M6Length * 2 } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Line4 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion } y is { @screen mywindow children M6_Line1 y + 30 } width is { @screen mywindow children MotorwayProperties M6Length * 2 } height = 2 filename = "mySprites/blackSprite.png" ); #M6 -> M6 Toll Junction Lines @screen mywindow children JunctionLabel = (new union (@prototypes label) x is { @screen mywindow currentMotorwayViewRegion + ( 2 * ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) - 20 } y is { @screen mywindow children M6_Line1 y - ( @screen mywindow children M6_Toll_Junc_Line1 height ) - 50 } caption is { "M6 Toll" } ); @screen mywindow children M6_Toll_Junc_Line1 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion + ( 2 * ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) } y is { @screen mywindow children M6_Line1 y - ( @screen mywindow children M6_Toll_Junc_Line1 height ) } width = 2 height = 150 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Junc_Line2 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x + 10 } y is { @screen mywindow children M6_Toll_Junc_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc_Line3 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x + 20 } y is { @screen mywindow children M6_Toll_Junc_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc_Line4 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x + 30 } y is { @screen mywindow children M6_Toll_Junc_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/blackSprite.png" ); #M6 Toll Motorway Lines @screen mywindow children M6_Toll_Line1 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x } y is { @screen mywindow children M6_Toll_Junc_Line1 y - 30 } width is { 2 * (@screen mywindow children MotorwayProperties M6TollRelativeEnd - ( @screen mywindow children MotorwayProperties M6TollRelativeStart)) } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Line2 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Line1 x } y is { @screen mywindow children M6_Toll_Line1 y + 10 } width is { @screen mywindow children M6_Toll_Line1 width } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Line3 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Line1 x } y is { @screen mywindow children M6_Toll_Line1 y + 20 } width is { @screen mywindow children M6_Toll_Line1 width } height = 2 filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Line4 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Line1 x + 30 } y is { @screen mywindow children M6_Toll_Line1 y + 30 } width is { @screen mywindow children M6_Toll_Line1 width - 60 } height = 2 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Line_StartCAP = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc_Line1 x } y is { @screen mywindow children M6_Toll_Junc_Line1 y - 30 } width = 2 height = 30 filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Line_EndCAP = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line4 x } y is { @screen mywindow children M6_Toll_Junc2_Line1 y - 30 } width = 2 height = 30 filename = "mySprites/blackSprite.png" ); #M6 Toll -> M6 Junction Lines @screen mywindow children M6_Toll_Junc2_Line1 = (new union (@prototypes image) x is { @screen mywindow currentMotorwayViewRegion + ( @screen mywindow children MotorwayProperties M6TollRelativeEnd * 2 ) - 30 } y is { @screen mywindow children M6_Line1 y - ( @screen mywindow children M6_Toll_Junc_Line1 height ) } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/blackSprite.png" ); @screen mywindow children M6_Toll_Junc2_Line2 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line1 x + 10 } y is { @screen mywindow children M6_Toll_Junc2_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc2_Line3 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line1 x + 20 } y is { @screen mywindow children M6_Toll_Junc2_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/greySprite.png" ); @screen mywindow children M6_Toll_Junc2_Line4 = (new union (@prototypes image) x is { @screen mywindow children M6_Toll_Junc2_Line1 x + 30 } y is { @screen mywindow children M6_Toll_Junc2_Line1 y } width = 2 height is { @screen mywindow children M6_Toll_Junc_Line1 height } filename = "mySprites/blackSprite.png" ); #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #!!!!!!!!!!!!!!!!! CAR AGENTS !!!!!!!!!!!!!!!!!!!!! #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #Car Speed of car 1: @screen mywindow children car1SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car1 x + 20 } y is { @screen mywindow children Car1 y - 40 } caption is { @screen mywindow children Car1 Speed } visible is { @screen mywindow children Car1 visible } ); @screen mywindow children Car1 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 70) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (60 == (.TickCounter))) { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == 1) and (@screen mywindow children Car2 Motorway == 1) and (10 > (@screen mywindow children Car2 Distance))) { false } else if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == 1) and (@screen mywindow children Car3 Motorway == 1) and (10 > (@screen mywindow children Car3 Distance))) { false } else if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == 1) and (@screen mywindow children Car4 Motorway == 1) and (10 > (@screen mywindow children Car4 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = true Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { true #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 #} else if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront) and (.TimeSplitWithCarInLaneAbove > (.TimeSplitWithCarInfront)) and (.Lane < 3)) { # .Lane + 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 60 RateToAccelerate = 4.5 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar2 = 10 TimeSplitWithCar2 is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3 = 10 TimeSplitWithCar3 is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4 = 10 TimeSplitWithCar4 is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar2 < (.TimeSplitWithCar3) and (.TimeSplitWithCar2 < (.TimeSplitWithCar4))) { .TimeSplitWithCar2 } else if (.TimeSplitWithCar3 < (.TimeSplitWithCar2) and (.TimeSplitWithCar3 < (.TimeSplitWithCar4))) { .TimeSplitWithCar3 } else if (.TimeSplitWithCar4 < (.TimeSplitWithCar2) and (.TimeSplitWithCar4 < (.TimeSplitWithCar3))) { .TimeSplitWithCar4 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car2 Active) and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car2 Distance - (.Distance))) and (-4 < (@screen mywindow children Car2 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car3 Active) and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car3 Distance - (.Distance))) and (-4 < (@screen mywindow children Car3 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car4 Active) and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car4 Distance - (.Distance))) and (-4 < (@screen mywindow children Car4 Distance - (.Distance)))) { true } else { .Crashed } } TimeSplitWithCar2LaneAbove = 10 TimeSplitWithCar2LaneAbove is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane + 1)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (-8 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3LaneAbove = 10 TimeSplitWithCar3LaneAbove is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane + 1)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (-8 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4LaneAbove = 10 TimeSplitWithCar4LaneAbove is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane + 1)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (-8 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInLaneAbove = 10 TimeSplitWithCarInLaneAbove is { if (.TimeSplitWithCar2LaneAbove < (.TimeSplitWithCar3LaneAbove) and (.TimeSplitWithCar2LaneAbove < (.TimeSplitWithCar4LaneAbove))) { .TimeSplitWithCar2LaneAbove } else if (.TimeSplitWithCar3LaneAbove < (.TimeSplitWithCar2LaneAbove) and (.TimeSplitWithCar3LaneAbove < (.TimeSplitWithCar4LaneAbove))) { .TimeSplitWithCar3LaneAbove } else if (.TimeSplitWithCar4LaneAbove < (.TimeSplitWithCar2LaneAbove) and (.TimeSplitWithCar4LaneAbove < (.TimeSplitWithCar3LaneAbove))) { .TimeSplitWithCar4LaneAbove } else { 10 } } ); #Car Speed of car 2: @screen mywindow children car2SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car2 x + 20 } y is { @screen mywindow children Car2 y - 40 } caption is { @screen mywindow children Car2 Speed } visible is { @screen mywindow children Car2 visible } ); @screen mywindow children Car2 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 400) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (50 == (.TickCounter))) { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == 1) and (@screen mywindow children Car1 Motorway == 1) and (10 > (@screen mywindow children Car1 Distance))) { false } else if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == 1) and (@screen mywindow children Car3 Motorway == 1) and (10 > (@screen mywindow children Car3 Distance))) { false } else if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == 1) and (@screen mywindow children Car4 Motorway == 1) and (10 > (@screen mywindow children Car4 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = false Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { false #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 20 RateToAccelerate = 3.6 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar1 = 10 TimeSplitWithCar1 is { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car1 Distance - (.Distance)))) { @screen mywindow children Car1 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3 = 10 TimeSplitWithCar3 is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4 = 10 TimeSplitWithCar4 is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar1 < (.TimeSplitWithCar3) and (.TimeSplitWithCar1 < (.TimeSplitWithCar4))) { .TimeSplitWithCar1 } else if (.TimeSplitWithCar3 < (.TimeSplitWithCar1) and (.TimeSplitWithCar3 < (.TimeSplitWithCar4))) { .TimeSplitWithCar3 } else if (.TimeSplitWithCar4 < (.TimeSplitWithCar1) and (.TimeSplitWithCar4 < (.TimeSplitWithCar3))) { .TimeSplitWithCar4 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car1 Active) and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car1 Distance - (.Distance))) and (-4 < (@screen mywindow children Car1 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car3 Active) and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car3 Distance - (.Distance))) and (-4 < (@screen mywindow children Car3 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car4 Active) and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car4 Distance - (.Distance))) and (-4 < (@screen mywindow children Car4 Distance - (.Distance)))) { true } else { .Crashed } } ); #Car Speed of car 3: @screen mywindow children car3SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car3 x + 20 } y is { @screen mywindow children Car3 y - 40 } caption is { @screen mywindow children Car3 Speed } visible is { @screen mywindow children Car3 visible } ); @screen mywindow children Car3 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 400) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (150 == (.TickCounter))) { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == 1) and (@screen mywindow children Car1 Motorway == 1) and (10 > (@screen mywindow children Car1 Distance))) { false } else if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == 1) and (@screen mywindow children Car2 Motorway == 1) and (10 > (@screen mywindow children Car2 Distance))) { false } else if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == 1) and (@screen mywindow children Car4 Motorway == 1) and (10 > (@screen mywindow children Car4 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = true Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { true #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 5 RateToAccelerate = 3.2 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar1 = 10 TimeSplitWithCar1 is { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car1 Distance - (.Distance)))) { @screen mywindow children Car1 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar2 = 10 TimeSplitWithCar2 is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar4 = 10 TimeSplitWithCar4 is { if (@screen mywindow children Car4 Active and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car4 Distance - (.Distance)))) { @screen mywindow children Car4 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar1 < (.TimeSplitWithCar2) and (.TimeSplitWithCar1 < (.TimeSplitWithCar4))) { .TimeSplitWithCar1 } else if (.TimeSplitWithCar2 < (.TimeSplitWithCar1) and (.TimeSplitWithCar2 < (.TimeSplitWithCar4))) { .TimeSplitWithCar2 } else if (.TimeSplitWithCar4 < (.TimeSplitWithCar1) and (.TimeSplitWithCar4 < (.TimeSplitWithCar2))) { .TimeSplitWithCar4 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car2 Active) and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car2 Distance - (.Distance))) and (-4 < (@screen mywindow children Car2 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car1 Active) and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car1 Distance - (.Distance))) and (-4 < (@screen mywindow children Car1 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car4 Active) and (@screen mywindow children Car4 Lane == (.Lane)) and (@screen mywindow children Car4 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car4 Distance - (.Distance))) and (-4 < (@screen mywindow children Car4 Distance - (.Distance)))) { true } else { .Crashed } } ); #Car Speed of car 4: @screen mywindow children car4SpeedLabel = (new union (@prototypes label) x is { @screen mywindow children Car4 x + 20 } y is { @screen mywindow children Car4 y - 40 } caption is { @screen mywindow children Car4 Speed } visible is { @screen mywindow children Car4 visible } ); @screen mywindow children Car4 = (new union (@prototypes image) TickCounter = 0 TickCounter is { if (@screen mywindow tick) { if (.TickCounter < 400) { .TickCounter + 1 } else { 0 } } else { .TickCounter } } Initilising = false DeActivating = false Active = false Active is { if (.Initilising) { true } else if (.DeActivating) { false } else { .Active } } visible is { if (.Crashed) { if (.visible) { #Make flash on/off. false } else { true } } else { .Active } } Initilising is { if (.Active == false and (200 == (.TickCounter))) { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == 1) and (@screen mywindow children Car1 Motorway == 1) and (10 > (@screen mywindow children Car1 Distance))) { false } else if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == 1) and (@screen mywindow children Car2 Motorway == 1) and (10 > (@screen mywindow children Car2 Distance))) { false } else if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == 1) and (@screen mywindow children Car3 Motorway == 1) and (10 > (@screen mywindow children Car3 Distance))) { false } else { true #Make things initilse when this is true } } else { false } } DeActivating is { if (.Active and (.Distance > (@screen mywindow children MotorwayProperties M6Length))) { true } else { false } } x is { if (.Motorway == 1) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) } else if (.Motorway == 2) { @screen mywindow children M6_Toll_Junc_Line1 x + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 3) { @screen mywindow currentMotorwayViewRegion + ( .Distance * 2 ) - ( @screen mywindow children M6_Toll_Junc_Line1 height) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Junc2_Line4 x - (6 + ( 10 * ( .Lane - 1 )) ) } } y is { if (.Motorway == 1) { @screen mywindow children M6_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 2) { @screen mywindow children M6_Line1 y - ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeStart ) ) ) } else if (.Motorway == 3) { @screen mywindow children M6_Toll_Line1 y + 4 + ( 10 * ( .Lane - 1 ) ) } else if (.Motorway == 4) { @screen mywindow children M6_Toll_Line4 y + ( 2 * (.Distance - ( @screen mywindow children MotorwayProperties M6TollRelativeEnd ) ) - ( @screen mywindow children M6_Toll_Junc2_Line1 height) ) } } width is { if (.Motorway == 1) { 8 } else if (.Motorway == 2) { 4 } else if (.Motorway == 3) { 8 } else if (.Motorway == 4) { 4 } } height is { if (.Motorway == 1) { 4 } else if (.Motorway == 2) { 8 } else if (.Motorway == 3) { 4 } else if (.Motorway == 4) { 8 } } filename = "mySprites/Vehicle(4x2meters).png" WantsToUseToll = true Lane = 1 Motorway = 1 WantsToUseToll is { if (.Initilising) { true #this should depend on random driver/car settings } else { .WantsToUseToll } } Lane is { if (.Initilising) { 1 } else { .Lane } } Motorway is { if (.Initilising) { 1 } else if (.Motorway == 1) { if (.WantsToUseToll and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart)) and (.Distance < (@screen mywindow children MotorwayProperties M6TollRelativeEnd))) { 2 } else { .Motorway } } else if (.Motorway == 2) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeStart + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 3 } else { .Motorway } } else if (.Motorway == 3) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (0.5 * (@screen mywindow children M6_Toll_Junc_Line1 height)))) { 4 } else { .Motorway } } else if (.Motorway == 4) { if (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc_Line1 height))) { 1 } else { .Motorway } } } PercentToExceedSpeedLimit = 15 RateToAccelerate = 2.8 #3.1 meters/second/second = average of doing 0 to 60mph in 8.4seconds (an average car's top acceleration) RateToDecelerate = 13.1 #13.1 meters/second/second = from average breaking distance (not including reaction time) of 54meters by car doing 60mph TargetTimeSplitFromCarInfront = 1.5 #seconds taken to reach car infronts CURRENT possition. #targetSpeed = motorway speed limit + PercentToExceedSpeedLimit to exceed by TargetSpeed is { @screen mywindow children MotorwayProperties SpeedLimit + ( .PercentToExceedSpeedLimit * ( @screen mywindow children MotorwayProperties SpeedLimit ) / 100 ) } Break = false Break is { if (.TimeSplitWithCarInfront < (.TargetTimeSplitFromCarInfront)) { true } else { false } } Speed = 0.0 Speed is { if (.Crashed == true) { 0.0 } else if (.Initilising) { 0.0 } else if (@screen mywindow tick) { if (.Break) { if (.Speed > 0) { .Speed - ( .RateToDecelerate * (@root time - (@screen mywindow ticktime)) ) } else { 0.0 } } else { if (.Speed < (.TargetSpeed)) { .Speed + ( .RateToAccelerate * (@root time - (@screen mywindow ticktime)) ) } else { .Speed } } } else { .Speed } } Distance = 0.0 Distance is { if (.Initilising) { 0.0 } else if (.WantsToUseToll and (.Motorway == 4) and (.Distance > (@screen mywindow children MotorwayProperties M6TollRelativeEnd + (@screen mywindow children M6_Toll_Junc2_Line1 height)))) { @screen mywindow children MotorwayProperties M6TollRelativeEnd } else if (@screen mywindow tick) { .Distance + ( .Speed * (@root time - (@screen mywindow ticktime)) ) } else { .Distance } } TimeSplitWithCar1 = 10 TimeSplitWithCar1 is { if (@screen mywindow children Car1 Active and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car1 Distance - (.Distance)))) { @screen mywindow children Car1 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar2 = 10 TimeSplitWithCar2 is { if (@screen mywindow children Car2 Active and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car2 Distance - (.Distance)))) { @screen mywindow children Car2 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCar3 = 10 TimeSplitWithCar3 is { if (@screen mywindow children Car3 Active and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (0 < (@screen mywindow children Car3 Distance - (.Distance)))) { @screen mywindow children Car3 Distance / (.Speed) - (.Distance / (.Speed)) } else { 10 #10 seconds = very long distance and thus irelevent } } TimeSplitWithCarInfront = 10 TimeSplitWithCarInfront is { if (.TimeSplitWithCar1 < (.TimeSplitWithCar2) and (.TimeSplitWithCar1 < (.TimeSplitWithCar3))) { .TimeSplitWithCar1 } else if (.TimeSplitWithCar2 < (.TimeSplitWithCar1) and (.TimeSplitWithCar2 < (.TimeSplitWithCar3))) { .TimeSplitWithCar2 } else if (.TimeSplitWithCar3 < (.TimeSplitWithCar1) and (.TimeSplitWithCar3 < (.TimeSplitWithCar2))) { .TimeSplitWithCar3 } else { 10 } } Crashed = false Crashed is { if (.Active and (@screen mywindow children Car2 Active) and (@screen mywindow children Car2 Lane == (.Lane)) and (@screen mywindow children Car2 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car2 Distance - (.Distance))) and (-4 < (@screen mywindow children Car2 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car3 Active) and (@screen mywindow children Car3 Lane == (.Lane)) and (@screen mywindow children Car3 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car3 Distance - (.Distance))) and (-4 < (@screen mywindow children Car3 Distance - (.Distance)))) { true } else if (.Active and (@screen mywindow children Car1 Active) and (@screen mywindow children Car1 Lane == (.Lane)) and (@screen mywindow children Car1 Motorway == (.Motorway)) and (4 > (@screen mywindow children Car1 Distance - (.Distance))) and (-4 < (@screen mywindow children Car1 Distance - (.Distance)))) { true } else { .Crashed } } ); my_EM_CW_cpy/config.dasm0000644000175000017500000000051011325232331013566 0ustar wmbwmbthis notations dasm run = (new type=LocalFile filename = "../wgd/wgd.dasm"); select (this os) { win32: { @dasm run = (new type=LocalFile filename = "../wgd/modules-win32.dasm") } linux: { @dasm run = (new type=LocalFile filename = "../wgd/modules-linux.dasm") } }; @dasm run = (new type=LocalFile filename="JonCaseyCW.dasm") my_EM_CW_cpy/config.dasm~0000644000175000017500000000116511325232010013765 0ustar wmbwmbthis notations dasm run = (new type=LocalFile filename = "../wgd/wgd.dasm"); select (this os) { win32: { @dasm run = (new type=LocalFile filename = "../wgd/modules-win32.dasm") } linux: { @dasm run = (new type=LocalFile filename = "../wgd/modules-linux.dasm") } }; this widgets root = (new type = Widget x = 0 y = 0 width is { @window width } height is { @window height } frame = 0 visible = true border = 0 sprite = (new union (@prototypes sprite) frames = 1 columns = 1 rows = 1 filename = "../wgd/emdesk.png" ) children = (@screen = (new)) ); @dasm run = (new type=LocalFile filename="JonCaseyCW.dasm") my_EM_CW_cpy/loadTK.sh0000777000175000017500000000016111325652701013205 0ustar wmbwmbexport LD_LIBRARY_PATH="/usr/local/share/wgd/modules" ../doste-eden/EDEN/tkeden -l ../doste-eden/EDEN/lib-tkeden my_EM_CW_cpy/mySprites/greySprite.png0000644000175000017500000000021111325675352016331 0ustar wmbwmb‰PNG  IHDRýÔšs pHYs  šœtEXtCommentCreated with GIMPWIDAT™clhh````b`````*„©òÎIEND®B`‚my_EM_CW_cpy/mySprites/blackSprite.xcf0000644000175000017500000000120711325235231016425 0ustar wmbwmbgimp xcf fileBBG gimp-commentCreated with GIMPgimp-image-grid(style solid) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches) ® Backgroundÿ     ]qmy_EM_CW_cpy/mySprites/blackSprite.png0000644000175000017500000000025411325656551016446 0ustar wmbwmb‰PNG  IHDRýÔšssRGB®Îé pHYs  šœtIMEÚ--æÿg"tEXtCommentCreated with GIMPWIDATñÿw§!ìIEND®B`‚my_EM_CW_cpy/mySprites/Vehicle(4x2meters).png0000644000175000017500000000013411325655166017457 0ustar wmbwmb‰PNG  IHDR¨}csBIT|dˆIDAT™cüÏÀðŸ 01 ?'v¨ü`IEND®B`‚