Skip to content

Commit 42462ed

Browse files
committed
Per Incident Penalty
1 parent b2c6de8 commit 42462ed

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

fission/src/systems/match_mode/RobotDimensionTracker.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import SceneRenderer from "../scene/SceneRenderer"
44
import MatchMode from "./MatchMode"
55
import SimulationSystem from "@/systems/simulation/SimulationSystem"
66

7-
const PENALTY_COOLDOWN = 1000
7+
const BUFFER_HEIGHT = 0.1
88

99
class RobotDimensionTracker {
10-
private static _robotHeightPenalties: Map<number, number> = new Map()
10+
private static _robotLastFramePenalty: Map<number, boolean> = new Map()
1111
private static _ignoreRotation: boolean = true
1212
private static _maxHeight: number = Infinity
1313
private static _heightPenalty: number = 0
@@ -28,11 +28,13 @@ class RobotDimensionTracker {
2828
robots.forEach(robot => {
2929
const dimensions = this._ignoreRotation ? robot.getDimensionsWithoutRotation() : robot.getDimensions()
3030

31-
if (dimensions.height > this._maxHeight) {
32-
if ((this._robotHeightPenalties.get(robot.id) ?? 0) < Date.now() - PENALTY_COOLDOWN) {
33-
this._robotHeightPenalties.set(robot.id, Date.now() + this._heightPenalty)
31+
if (dimensions.height > this._maxHeight + BUFFER_HEIGHT) {
32+
if (!(this._robotLastFramePenalty.get(robot.id) ?? false)) {
3433
SimulationSystem.robotPenalty(robot, this._heightPenalty, "Height Expansion Limit")
3534
}
35+
this._robotLastFramePenalty.set(robot.id, true)
36+
} else {
37+
this._robotLastFramePenalty.set(robot.id, false)
3638
}
3739
})
3840
}

fission/src/test/RobotDimensionsTracker.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ describe("RobotDimensionTracker", () => {
6666
beforeEach(() => {
6767
vi.clearAllMocks()
6868

69-
const tracker = RobotDimensionTracker as unknown as { _robotHeightPenalties?: Map<string, number> }
70-
tracker._robotHeightPenalties?.clear()
69+
const tracker = RobotDimensionTracker as unknown as { _robotLastFramePenalty?: Map<number, boolean> }
70+
tracker._robotLastFramePenalty?.clear()
7171

7272
const robot1Base = Object.create(MirabufSceneObject.prototype)
7373
const robot2Base = Object.create(MirabufSceneObject.prototype)

0 commit comments

Comments
 (0)