BlueGit

projects-timfalken-com meteors

feat: reward spawn rate 15 + 10t blocks/s (RATE0 = 15, ACCEL = 10, t1178)

timfa Grok Bot · pushed by timfa

Authored 2026-11-14 · 3 days ago

Hash
f229b227933bc369a17a5b550c181b3fc3922f55
Parent
97e5fffc
2 files changed +20 −20
src/reward.js +5 −5
@@ -10,7 +10,7 @@
10 10 * Spawn rate accelerates: rate(t) = RATE0 + ACCEL·t blocks/s, so the
11 11 * number spawned after t seconds is N(t) = RATE0·t + ACCEL·t²/2, and
12 12 * block i (0-based) leaves at T(i) = the t where N(t) = i.
13 * t1177: RATE0 = 10, ACCEL = 5 → 253 points ≈ 8.3 s, 800 = 16 s, 2000 ≈ 26.4 s.
13 * t1178: RATE0 = 15, ACCEL = 10 → 253 points ≈ 5.8 s, 800 ≈ 11.2 s, 2000 ≈ 18.6 s.
14 14 *
15 15 * The pure timing / sequencing part (Reward.spawnTime, Reward.createSequence)
16 16 * has no DOM and is unit-tested. Reward.play wires it to an overlay.
@@ -19,10 +19,10 @@
19 19 {
20 20 'use strict';
21 21
22 /** Blocks per second at t = 0 (t1177: was 5, now 10). */
23 var RATE0 = 10;
24 /** Rate increase in blocks/s per second (t1175: 3, t1177: 5). */
25 var ACCEL = 5;
22 /** Blocks per second at t = 0 (t1177: 10, t1178: 15). */
23 var RATE0 = 15;
24 /** Rate increase in blocks/s per second (t1175: 3, t1177: 5, t1178: 10). */
25 var ACCEL = 10;
26 26 var INTRO = 1.0; // centred title before it rises
27 27 var RISE = 0.6; // title tween to the top
28 28 var FLIGHT = 0.7; // one block's arc duration
@@ -10,7 +10,7 @@
10 * Spawn rate accelerates: rate(t) = RATE0 + ACCEL·t blocks/s, so the
10 * Spawn rate accelerates: rate(t) = RATE0 + ACCEL·t blocks/s, so the
11 * number spawned after t seconds is N(t) = RATE0·t + ACCEL·t²/2, and
11 * number spawned after t seconds is N(t) = RATE0·t + ACCEL·t²/2, and
12 * block i (0-based) leaves at T(i) = the t where N(t) = i.
12 * block i (0-based) leaves at T(i) = the t where N(t) = i.
13 * t1177: RATE0 = 10, ACCEL = 5 → 253 points ≈ 8.3 s, 800 = 16 s, 2000 ≈ 26.4 s.
13 * t1178: RATE0 = 15, ACCEL = 10 → 253 points ≈ 5.8 s, 800 ≈ 11.2 s, 2000 ≈ 18.6 s.
14 *
14 *
15 * The pure timing / sequencing part (Reward.spawnTime, Reward.createSequence)
15 * The pure timing / sequencing part (Reward.spawnTime, Reward.createSequence)
16 * has no DOM and is unit-tested. Reward.play wires it to an overlay.
16 * has no DOM and is unit-tested. Reward.play wires it to an overlay.
@@ -19,10 +19,10 @@
19{
19{
20'use strict';
20'use strict';
21
21
22/** Blocks per second at t = 0 (t1177: was 5, now 10). */
22/** Blocks per second at t = 0 (t1177: 10, t1178: 15). */
23var RATE0 = 10;
23var RATE0 = 15;
24/** Rate increase in blocks/s per second (t1175: 3, t1177: 5). */
24/** Rate increase in blocks/s per second (t1175: 3, t1177: 5, t1178: 10). */
25var ACCEL = 5;
25var ACCEL = 10;
26var INTRO = 1.0; // centred title before it rises
26var INTRO = 1.0; // centred title before it rises
27var RISE = 0.6; // title tween to the top
27var RISE = 0.6; // title tween to the top
28var FLIGHT = 0.7; // one block's arc duration
28var FLIGHT = 0.7; // one block's arc duration
test/reward.test.js +15 −15
@@ -28,17 +28,17 @@ function runToEnd (seq, dt, maxT)
28 28 return { events, t, spawned, arrived, monotonic, last: events[events.length - 1] };
29 29 }
30 30
31 describe('Reward spawn schedule (t1177: 10 + 5t blocks/s)', () =>
31 describe('Reward spawn schedule (t1178: 15 + 10t blocks/s)', () =>
32 32 {
33 it('block i leaves when 10t + 5t²/2 = i', () =>
33 it('block i leaves when 15t + 10t²/2 = i', () =>
34 34 {
35 assert.equal(Reward.RATE0, 10);
36 assert.equal(Reward.ACCEL, 5);
35 assert.equal(Reward.RATE0, 15);
36 assert.equal(Reward.ACCEL, 10);
37 37 assert.equal(Reward.spawnTime(0), 0);
38 38 for (const i of [1, 5, 10, 50, 100, 252, 1000])
39 39 {
40 40 const t = Reward.spawnTime(i);
41 assert.ok(Math.abs(10 * t + 5 * t * t / 2 - i) < 1e-9, 'i=' + i + ' t=' + t);
41 assert.ok(Math.abs(15 * t + 10 * t * t / 2 - i) < 1e-9, 'i=' + i + ' t=' + t);
42 42 }
43 43 // spawn times strictly increase, gaps shrink (accelerating)
44 44 let prevGap = Infinity;
@@ -51,26 +51,26 @@ describe('Reward spawn schedule (t1177: 10 + 5t blocks/s)', () =>
51 51 }
52 52 });
53 53
54 it('starts at 10/s; 253 ≈ 8.3 s, 800 = 16 s, 2000 ≈ 26.4 s (Tim\'s examples)', () =>
54 it('starts at 15/s; 253 ≈ 5.8 s, 800 ≈ 11.2 s, 2000 ≈ 18.6 s (Tim\'s examples)', () =>
55 55 {
56 56 // 1/5 s between the first two blocks.
57 assert.ok(Math.abs(Reward.spawnTime(1) - (-10 + Math.sqrt(110)) / 5) < 1e-12);
58 assert.ok(Reward.spawnTime(1) > 0.09 && Reward.spawnTime(1) < 0.1);
59 const last = (-10 + Math.sqrt(100 + 10 * 252)) / 5;
57 assert.ok(Math.abs(Reward.spawnTime(1) - (-15 + Math.sqrt(245)) / 10) < 1e-12);
58 assert.ok(Reward.spawnTime(1) > 0.06 && Reward.spawnTime(1) < 0.067);
59 const last = (-15 + Math.sqrt(225 + 20 * 252)) / 10;
60 60 assert.ok(Math.abs(Reward.spawnTime(252) - last) < 1e-9);
61 assert.ok(last > 8.2 && last < 8.35, 'last=' + last);
62 assert.ok(Math.abs(Reward.spawnTime(799) - 16) < 0.02, '800: ' + Reward.spawnTime(799));
63 assert.ok(Math.abs(Reward.spawnTime(1999) - 26.4) < 0.1, '2000: ' + Reward.spawnTime(1999));
61 assert.ok(last > 5.7 && last < 5.85, 'last=' + last);
62 assert.ok(Math.abs(Reward.spawnTime(799) - 11.2) < 0.05, '800: ' + Reward.spawnTime(799));
63 assert.ok(Math.abs(Reward.spawnTime(1999) - 18.6) < 0.1, '2000: ' + Reward.spawnTime(1999));
64 64 assert.equal(Reward.spawnedBy(last + 1e-6, 253), 253);
65 65 assert.equal(Reward.spawnedBy(last - 0.01, 253), 252);
66 66 assert.ok(Math.abs(Reward.countDuration(253) - (last + Reward.FLIGHT)) < 1e-9);
67 67 });
68 68
69 it('spawnedBy matches floor(10t + 5t²/2) + 1, capped by n', () =>
69 it('spawnedBy matches floor(15t + 10t²/2) + 1, capped by n', () =>
70 70 {
71 71 for (let t = 0; t <= 20; t += 0.37)
72 72 {
73 const expect = Math.min(253, Math.floor(10 * t + 5 * t * t / 2 + 1e-9) + 1);
73 const expect = Math.min(253, Math.floor(15 * t + 10 * t * t / 2 + 1e-9) + 1);
74 74 assert.equal(Reward.spawnedBy(t, 253), expect, 't=' + t);
75 75 }
76 76 assert.equal(Reward.spawnedBy(-1, 10), 0);
@@ -83,7 +83,7 @@ describe('Reward spawn schedule (t1177: 10 + 5t blocks/s)', () =>
83 83
84 84 describe('Reward sequence (t1173)', () =>
85 85 {
86 it('500 + 253 → counts every point from 500 up to 753 in ~9 s of counting', () =>
86 it('500 + 253 → counts every point from 500 up to 753 in ~6.5 s of counting', () =>
87 87 {
88 88 const seq = Reward.createSequence({ won: true });
89 89 seq.setResult({ before: 500, after: 753 });
@@ -28,17 +28,17 @@ function runToEnd (seq, dt, maxT)
28 return { events, t, spawned, arrived, monotonic, last: events[events.length - 1] };
28 return { events, t, spawned, arrived, monotonic, last: events[events.length - 1] };
29}
29}
30
30
31describe('Reward spawn schedule (t1177: 10 + 5t blocks/s)', () =>
31describe('Reward spawn schedule (t1178: 15 + 10t blocks/s)', () =>
32{
32{
33 it('block i leaves when 10t + 5t²/2 = i', () =>
33 it('block i leaves when 15t + 10t²/2 = i', () =>
34 {
34 {
35 assert.equal(Reward.RATE0, 10);
35 assert.equal(Reward.RATE0, 15);
36 assert.equal(Reward.ACCEL, 5);
36 assert.equal(Reward.ACCEL, 10);
37 assert.equal(Reward.spawnTime(0), 0);
37 assert.equal(Reward.spawnTime(0), 0);
38 for (const i of [1, 5, 10, 50, 100, 252, 1000])
38 for (const i of [1, 5, 10, 50, 100, 252, 1000])
39 {
39 {
40 const t = Reward.spawnTime(i);
40 const t = Reward.spawnTime(i);
41 assert.ok(Math.abs(10 * t + 5 * t * t / 2 - i) < 1e-9, 'i=' + i + ' t=' + t);
41 assert.ok(Math.abs(15 * t + 10 * t * t / 2 - i) < 1e-9, 'i=' + i + ' t=' + t);
42 }
42 }
43 // spawn times strictly increase, gaps shrink (accelerating)
43 // spawn times strictly increase, gaps shrink (accelerating)
44 let prevGap = Infinity;
44 let prevGap = Infinity;
@@ -51,26 +51,26 @@ describe('Reward spawn schedule (t1177: 10 + 5t blocks/s)', () =>
51 }
51 }
52 });
52 });
53
53
54 it('starts at 10/s; 253 ≈ 8.3 s, 800 = 16 s, 2000 ≈ 26.4 s (Tim\'s examples)', () =>
54 it('starts at 15/s; 253 ≈ 5.8 s, 800 ≈ 11.2 s, 2000 ≈ 18.6 s (Tim\'s examples)', () =>
55 {
55 {
56 // 1/5 s between the first two blocks.
56 // 1/5 s between the first two blocks.
57 assert.ok(Math.abs(Reward.spawnTime(1) - (-10 + Math.sqrt(110)) / 5) < 1e-12);
57 assert.ok(Math.abs(Reward.spawnTime(1) - (-15 + Math.sqrt(245)) / 10) < 1e-12);
58 assert.ok(Reward.spawnTime(1) > 0.09 && Reward.spawnTime(1) < 0.1);
58 assert.ok(Reward.spawnTime(1) > 0.06 && Reward.spawnTime(1) < 0.067);
59 const last = (-10 + Math.sqrt(100 + 10 * 252)) / 5;
59 const last = (-15 + Math.sqrt(225 + 20 * 252)) / 10;
60 assert.ok(Math.abs(Reward.spawnTime(252) - last) < 1e-9);
60 assert.ok(Math.abs(Reward.spawnTime(252) - last) < 1e-9);
61 assert.ok(last > 8.2 && last < 8.35, 'last=' + last);
61 assert.ok(last > 5.7 && last < 5.85, 'last=' + last);
62 assert.ok(Math.abs(Reward.spawnTime(799) - 16) < 0.02, '800: ' + Reward.spawnTime(799));
62 assert.ok(Math.abs(Reward.spawnTime(799) - 11.2) < 0.05, '800: ' + Reward.spawnTime(799));
63 assert.ok(Math.abs(Reward.spawnTime(1999) - 26.4) < 0.1, '2000: ' + Reward.spawnTime(1999));
63 assert.ok(Math.abs(Reward.spawnTime(1999) - 18.6) < 0.1, '2000: ' + Reward.spawnTime(1999));
64 assert.equal(Reward.spawnedBy(last + 1e-6, 253), 253);
64 assert.equal(Reward.spawnedBy(last + 1e-6, 253), 253);
65 assert.equal(Reward.spawnedBy(last - 0.01, 253), 252);
65 assert.equal(Reward.spawnedBy(last - 0.01, 253), 252);
66 assert.ok(Math.abs(Reward.countDuration(253) - (last + Reward.FLIGHT)) < 1e-9);
66 assert.ok(Math.abs(Reward.countDuration(253) - (last + Reward.FLIGHT)) < 1e-9);
67 });
67 });
68
68
69 it('spawnedBy matches floor(10t + 5t²/2) + 1, capped by n', () =>
69 it('spawnedBy matches floor(15t + 10t²/2) + 1, capped by n', () =>
70 {
70 {
71 for (let t = 0; t <= 20; t += 0.37)
71 for (let t = 0; t <= 20; t += 0.37)
72 {
72 {
73 const expect = Math.min(253, Math.floor(10 * t + 5 * t * t / 2 + 1e-9) + 1);
73 const expect = Math.min(253, Math.floor(15 * t + 10 * t * t / 2 + 1e-9) + 1);
74 assert.equal(Reward.spawnedBy(t, 253), expect, 't=' + t);
74 assert.equal(Reward.spawnedBy(t, 253), expect, 't=' + t);
75 }
75 }
76 assert.equal(Reward.spawnedBy(-1, 10), 0);
76 assert.equal(Reward.spawnedBy(-1, 10), 0);
@@ -83,7 +83,7 @@ describe('Reward spawn schedule (t1177: 10 + 5t blocks/s)', () =>
83
83
84describe('Reward sequence (t1173)', () =>
84describe('Reward sequence (t1173)', () =>
85{
85{
86 it('500 + 253 → counts every point from 500 up to 753 in ~9 s of counting', () =>
86 it('500 + 253 → counts every point from 500 up to 753 in ~6.5 s of counting', () =>
87 {
87 {
88 const seq = Reward.createSequence({ won: true });
88 const seq = Reward.createSequence({ won: true });
89 seq.setResult({ before: 500, after: 753 });
89 seq.setResult({ before: 500, after: 753 });