@adatechnology/game-vehicles-proving 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -148,6 +148,8 @@ interface RangeTable {
148
148
  accelerationSeconds: ReadonlyArray<readonly [number, number]>;
149
149
  /** 0-100 km/h seconds by the card's acceleration rating, per class (`cars`, `suvs`, `motorcycles`): the rating places the model between the class's slowest and fastest real figure. */
150
150
  accelerationByClass: Readonly<Record<string, ReadonlyArray<readonly [number, number]>>>;
151
+ /** 0-100 km/h seconds, as a [fastest, slowest] pair, by the card's body type (`bicycle`): what the real riders of the type do, for a type the class band does not describe. A band here ignores the rating and the spread. */
152
+ accelerationSpanByType?: Readonly<Record<string, readonly [number, number]>>;
151
153
  /** Accepted spread around the expected 0-100 time (0.35 = ±35 %). */
152
154
  accelerationSpread: number;
153
155
  /** Accepted spread around the card's top speed. */
@@ -168,6 +170,10 @@ interface RangeTable {
168
170
  * suvs: slowest 12.7 s, Toyota Land Cruiser Prado 2.8 D-4D 177 hp automatic (https://www.auto-data.net/en/toyota-land-cruiser-prado-j150-facelift-2017-5-door-2.8-d-4d-177hp-4wd-automatic-32878, a database, not the maker);
169
171
  * fastest 6.7 s, Toyota Land Cruiser 300 (Toyota's figure, via https://www.motor1.com/news/515260/2022-toyota-land-cruiser-acceleration-test/).
170
172
  * motorcycles: slowest 19.5 s, Honda PCX 160 (measured, https://www.autofun.co.id/berita-motor/mana-paling-gesit-akselerasinya-honda-pcx-160-2022-atau-yamaha-nmax-155-2022-48474); fastest 4.35 s, Kawasaki Ninja 400 (https://motostatz.com/?p=369).
173
+ * bicycle (body type, not a class: it sits in `motorcycles`, whose band is of engines): an everyday rider, not an engine. Slowest 120 s per 100 km/h (24 s to 20 km/h), the mean acceleration of observed riders on
174
+ * the flat, 0.231 m/s^2 over an acceleration phase of about 26 s at about 120 W (Parkin and Rotheram 2010, Transport Policy 17(5) 335-341, https://doi.org/10.1016/j.tranpol.2010.03.001, abstract at
175
+ * https://uwe-repository.worktribe.com/output/987466); fastest 36 s per 100 km/h (7.2 s to 20 km/h), "an everyday rider needs 9 to 14 s to 25 km/h", 0.5 to 0.8 m/s^2 (https://myvelo.net/blogs/ebike-blog/wie-schnell-beschleunigt-ein-e-bike-motor-gewicht-realitaet:
176
+ * a shop's article, the rider's power not stated: a weak source, taken at its fastest edge).
171
177
  * pickups, vans, heavy, agricultural, military: no verified pair of figures (a Hilux 2.8 is 10.0 s, Toyota Europe, one point only), so they keep `accelerationSeconds`.
172
178
  */
173
179
  declare const defaultRangeTable: RangeTable;
@@ -1141,13 +1141,14 @@ var GameVehiclesProving = (() => {
1141
1141
  return { gauge: tracks.gauge, rearX: tracks.rearX - middle, frontX: tracks.frontX - middle, roadWheels: tracks.roadWheels, roadRadius: tracks.radius };
1142
1142
  };
1143
1143
  var RIDER_MASS_KG = 75;
1144
- var MOTORCYCLE_POWER_FACTOR = 1.3;
1145
1144
  var MOTORCYCLE_POWER_RATING_1 = 11800 / (132 + RIDER_MASS_KG);
1146
1145
  var MOTORCYCLE_POWER_RATING_10 = 33400 / (168 + RIDER_MASS_KG);
1147
- var motorcyclePower = (rating) => MOTORCYCLE_POWER_FACTOR * (MOTORCYCLE_POWER_RATING_1 + (MOTORCYCLE_POWER_RATING_10 - MOTORCYCLE_POWER_RATING_1) * (rating - 1) / 9);
1146
+ var motorcyclePower = (rating) => MOTORCYCLE_POWER_RATING_1 + (MOTORCYCLE_POWER_RATING_10 - MOTORCYCLE_POWER_RATING_1) * (rating - 1) / 9;
1147
+ var PHYSICS_TORQUE_SCALE = { car: 1.45, motorcycle: 1.3 };
1148
1148
  var carPower = (rating) => (0.06 + 0.015 * rating) * (defaultSemiSpec.engine.peakRpm * 2 * Math.PI / 60);
1149
+ var TRACKED_POWER = 20.05;
1149
1150
  var peakTorqueOf = (type, rating, mass, peakRpm) => {
1150
- const power = type === "motorcycle" ? motorcyclePower(rating) : carPower(rating);
1151
+ const power = type === "motorcycle" ? motorcyclePower(rating) : type === "tracked" ? TRACKED_POWER : carPower(rating);
1151
1152
  return mass * power * 60 / (2 * Math.PI * peakRpm);
1152
1153
  };
1153
1154
  var cyclistFor = (top, wheelRadius) => {
@@ -1203,6 +1204,7 @@ var GameVehiclesProving = (() => {
1203
1204
  gears,
1204
1205
  drag,
1205
1206
  brakeForce,
1207
+ ...type === "car" || type === "motorcycle" ? { physicsTorqueScale: PHYSICS_TORQUE_SCALE[type] } : {},
1206
1208
  tyre: { ...spec.tyre, friction: 0.8 + 0.03 * stats.handling },
1207
1209
  ...pedal ? { pedal } : {},
1208
1210
  ...tracks ? { tracks } : {}
@@ -1222,6 +1224,7 @@ var GameVehiclesProving = (() => {
1222
1224
  var CLUTCH_STRENGTH = 10;
1223
1225
  var CLUTCH_SLIP = 0.03;
1224
1226
  var BICYCLE_WHEEL_INERTIA = 0.1;
1227
+ var BICYCLE_IDLE_CADENCE_RPM = 40;
1225
1228
  var WHEEL_INERTIA_PER_MASS = 8e-4;
1226
1229
  var REFERENCE_RADIUS = 0.32;
1227
1230
  var MIN_WHEEL_INERTIA = 0.02;
@@ -1234,6 +1237,12 @@ var GameVehiclesProving = (() => {
1234
1237
  var MOTORCYCLE_TRANSMISSION = { switchTime: 0.05, clutchReleaseTime: 0.07, switchLatency: 0.05 };
1235
1238
  var clutchFor = (peakTorque, maxRpm) => Math.max(CLUTCH_STRENGTH, peakTorque / (CLUTCH_SLIP * (maxRpm * 2 * Math.PI / 60)));
1236
1239
  var clamp5 = (x, low, high) => Math.max(low, Math.min(high, x));
1240
+ var pedalCurve = (pedal) => {
1241
+ const redline = pedal.cadenceRpm * 1.5;
1242
+ const idle2 = BICYCLE_IDLE_CADENCE_RPM;
1243
+ const heldWatts = (cadence) => pedal.cadenceRpm / cadence;
1244
+ return [[0, heldWatts(idle2)], [idle2 / redline, heldWatts(idle2)], [pedal.cadenceRpm / redline, 1], [1, 0]];
1245
+ };
1237
1246
  var torqueCurve = (spec) => {
1238
1247
  const { idleRpm, peakRpm, redlineRpm, peakTorque } = spec.engine;
1239
1248
  const at = (rpm) => torqueAt(spec, rpm) / peakTorque;
@@ -1310,7 +1319,7 @@ var GameVehiclesProving = (() => {
1310
1319
  gears: pedal.gears.map((ratio) => 1 / ratio),
1311
1320
  reverseGears: [],
1312
1321
  differentialRatio: 1,
1313
- torqueCurve: [[0, 1], [0.67, 1], [1, 0]],
1322
+ torqueCurve: pedalCurve(pedal),
1314
1323
  transmission: { shiftUpRpm: pedal.cadenceRpm * 0.95, shiftDownRpm: pedal.cadenceRpm * 0.5, clutchStrength: clutchFor(pedal.watts / crankSpeed, pedal.cadenceRpm * 1.5) }
1315
1324
  };
1316
1325
  }
@@ -1318,7 +1327,7 @@ var GameVehiclesProving = (() => {
1318
1327
  return {
1319
1328
  engineDamping: ENGINE_DAMPING,
1320
1329
  engineInertia: ENGINE_INERTIA_PER_TORQUE * spec.engine.peakTorque,
1321
- maxTorque: spec.engine.peakTorque * spec.efficiency * (ENGINE_FLOOR + (1 - ENGINE_FLOOR) * health),
1330
+ maxTorque: spec.engine.peakTorque * (spec.physicsTorqueScale ?? 1) * spec.efficiency * (ENGINE_FLOOR + (1 - ENGINE_FLOOR) * health),
1322
1331
  minRpm: spec.engine.idleRpm,
1323
1332
  maxRpm: spec.engine.redlineRpm,
1324
1333
  gears: spec.gears,
@@ -1421,11 +1430,13 @@ var GameVehiclesProving = (() => {
1421
1430
  [9, 6],
1422
1431
  [10, 4.2]
1423
1432
  ],
1433
+ accelerationSpanByType: { bicycle: [36, 120] },
1424
1434
  accelerationSpread: 0.35,
1425
1435
  topSpeedSpread: 0.1,
1426
1436
  dryBrake: { default: [6.5, 11], heavy: [4.5, 8.5], agricultural: [3.5, 7.5], military: [4.5, 9] },
1427
1437
  wetBrake: { default: [3.5, 8.5], heavy: [2.5, 7], agricultural: [2, 6], military: [2.5, 7] },
1428
- turnCircle: { default: [7, 13.5], motorcycles: [3, 9], suvs: [9, 15], pickups: [9, 16], vans: [9, 15], heavy: [10, 26], military: [9, 24], agricultural: [6, 16] },
1438
+ // a tracked vehicle pivots on the spot (one track forward, the other back: "neutral steering", https://en.wikipedia.org/wiki/Tank_steering_systems), so its circle can be a point: the band starts at 0
1439
+ turnCircle: { default: [7, 13.5], motorcycles: [3, 9], suvs: [9, 15], pickups: [9, 16], vans: [9, 15], heavy: [10, 26], military: [9, 24], agricultural: [6, 16], tracked: [0, 24] },
1429
1440
  mudFourWheelDrive: 10
1430
1441
  };
1431
1442
  var byClass = (table, category) => table[category] ?? table.default;
@@ -1434,6 +1445,8 @@ var GameVehiclesProving = (() => {
1434
1445
  return base * (target / 100);
1435
1446
  };
1436
1447
  var accelerationRange = (table, subject, target) => {
1448
+ const span = subject.body.type ? table.accelerationSpanByType?.[subject.body.type] : void 0;
1449
+ if (span) return { min: round(span[0] * target / 100), max: round(span[1] * target / 100) };
1437
1450
  const t = expectedAcceleration(table, subject, target);
1438
1451
  return { min: round(t * (1 - table.accelerationSpread)), max: round(t * (1 + table.accelerationSpread)) };
1439
1452
  };
@@ -1448,7 +1461,7 @@ var GameVehiclesProving = (() => {
1448
1461
  var dryBrakeRange = (table, subject, kmh2) => brakeRange(byClass(table.dryBrake, subject.category), kmh2);
1449
1462
  var wetBrakeRange = (table, subject, kmh2) => brakeRange(byClass(table.wetBrake, subject.category), kmh2);
1450
1463
  var turnCircleRange = (table, subject) => {
1451
- const [min, max] = byClass(table.turnCircle, subject.category);
1464
+ const [min, max] = byClass(table.turnCircle, subject.body.type === "tracked" ? "tracked" : subject.category);
1452
1465
  return { min, max };
1453
1466
  };
1454
1467
  var inRange = (value, range) => (range.min == null || value >= range.min) && (range.max == null || value <= range.max);