Skip to content

Commit

Permalink
Increased time between departures when there is a negative backlog of…
Browse files Browse the repository at this point in the history
… departures
  • Loading branch information
Bombbird2001 committed Aug 17, 2023
1 parent 91a3997 commit 9a4e399
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ configure(subprojects - project(':android')) {
subprojects {
version = '2.0.0-beta'
ext.appName = 'Terminal Control 2'
ext.buildVersion = 8
ext.buildVersion = 9
repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,9 @@ fun calculateAdditionalTimeToNextDeparture(backlog: Int, maxAdvDep: Int): Int {
val threshold1 = (maxAdvDep * 0.5f).roundToInt()
return when {
backlog >= 10 -> 0
backlog >= -threshold1 -> 0 + 120 * (10 - backlog) / (10 + threshold1)
backlog >= -maxAdvDep -> 120 + (320 - 120) * (-threshold1 - backlog) / (maxAdvDep - threshold1)
else -> 320
backlog >= -threshold1 -> 0 + 240 * (10 - backlog) / (10 + threshold1)
backlog >= -maxAdvDep -> 240 + (640 - 240) * (-threshold1 - backlog) / (maxAdvDep - threshold1)
else -> 640
}
}

Expand Down
20 changes: 10 additions & 10 deletions core/src/test/kotlin/TrafficToolsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ object TrafficToolsTest: FunSpec() {
calculateAdditionalTimeToNextDeparture(24, 40) shouldBe 0
calculateAdditionalTimeToNextDeparture(15, 40) shouldBe 0
calculateAdditionalTimeToNextDeparture(10, 40) shouldBe 0
calculateAdditionalTimeToNextDeparture(3, 40) shouldBe 28
calculateAdditionalTimeToNextDeparture(-14, 40) shouldBe 96
calculateAdditionalTimeToNextDeparture(-6, 20) shouldBe 96
calculateAdditionalTimeToNextDeparture(-20, 40) shouldBe 120
calculateAdditionalTimeToNextDeparture(-29, 40) shouldBe 210
calculateAdditionalTimeToNextDeparture(-58, 80) shouldBe 210
calculateAdditionalTimeToNextDeparture(-40, 40) shouldBe 320
calculateAdditionalTimeToNextDeparture(-47, 40) shouldBe 320
calculateAdditionalTimeToNextDeparture(-30, 20) shouldBe 320
calculateAdditionalTimeToNextDeparture(-15, 10) shouldBe 320
calculateAdditionalTimeToNextDeparture(3, 40) shouldBe 56
calculateAdditionalTimeToNextDeparture(-14, 40) shouldBe 192
calculateAdditionalTimeToNextDeparture(-6, 20) shouldBe 192
calculateAdditionalTimeToNextDeparture(-20, 40) shouldBe 240
calculateAdditionalTimeToNextDeparture(-29, 40) shouldBe 420
calculateAdditionalTimeToNextDeparture(-58, 80) shouldBe 420
calculateAdditionalTimeToNextDeparture(-40, 40) shouldBe 640
calculateAdditionalTimeToNextDeparture(-47, 40) shouldBe 640
calculateAdditionalTimeToNextDeparture(-30, 20) shouldBe 640
calculateAdditionalTimeToNextDeparture(-15, 10) shouldBe 640
}
}
}

0 comments on commit 9a4e399

Please sign in to comment.