Otter-stop update to scale sequence length with difficulty level#84
Otter-stop update to scale sequence length with difficulty level#84
Conversation
- Early game: at most 5 otters before fish (level 0) - Each level adds 1 to the maximum sequence length - Sequence length is randomized each round up to the level max - maxSequenceLength is saved to progress via saveScore extraFields - Export getMaxSequenceLength() and getCurrentSequenceLength() from game.js - Update and expand tests for new sequence behaviour Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/b5175073-9102-4186-a890-77d366114374 Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
…ula and test cleanup Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/b5175073-9102-4186-a890-77d366114374 Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
acrosman
left a comment
There was a problem hiding this comment.
Mas Sequence length does not step down when a player fails three times in a row and the player goes back to a lower level. It should also be the same for any given level of difficulty.
| [0.5, 'go-3.png', false], | ||
| [0.75, 'no-go', true], | ||
| ])('Math.random()=%f → imageKey="%s", isNoGo=%s', (rand, expectedKey, expectedIsNoGo) => { | ||
| [0.34, 'go-2.png', false], |
There was a problem hiding this comment.
Nothing about this change should have required an update to the timing in this test.
There was a problem hiding this comment.
Restored in 12671d7. The it.each random values are back to [0, 0.25, 0.5, 0.75]; only the expected image keys were updated to reflect the 3-key GO_KEYS pool (Math.floor(r * 3) gives indices 0, 0, 1, 2 for those values).
| expect(getMaxSequenceLength()).toBe(7); | ||
| }); | ||
|
|
||
| it('increases by 1 for each additional level', () => { |
There was a problem hiding this comment.
This test is the same as the three before it. If we're doing to run a generic one here it should be further into the level count than levels 0-2. Have it test a much later level or remove this extra test.
There was a problem hiding this comment.
Updated in 12671d7. The test now advances to level 10 (30 consecutive correct no-go inhibitions) and asserts getMaxSequenceLength() === 15.
…s review comments - Remove randomized sequence length generation; sequence is now always exactly BASE_MAX_SEQUENCE_LENGTH + level (5 at level 0, +1 per level) - pickNextImage() compares sequencePosition against the live level-based value, so the sequence length adjusts immediately when the level drops - Remove MIN_SEQUENCE_LENGTH constant and generateSequenceLength() helper - getCurrentSequenceLength() now returns the same deterministic value as getMaxSequenceLength() - Restore original it.each random values [0, 0.25, 0.5, 0.75] in pickNextImage test, updating expected keys for the 3-key GO_KEYS pool - Update redundant getMaxSequenceLength 'increases by 1' test to assert at level 10 (value 15) instead of rechecking levels 0-2 - Expand getCurrentSequenceLength tests to cover level-drop behaviour Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/e48782cc-c2de-4d6b-b7b9-fe1d558da4d7 Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
Fixed in 12671d7. The sequence length is now deterministic: |
acrosman
left a comment
There was a problem hiding this comment.
The goal was not to make it deterministic. The length of any given sequence of otters should be random, between zero (just show the fish) and the max length for the current level.
Go back to the previous version. Update the process so that when a player goes back two levels because they failed three sequences in a row it reduces the max sequence length to the correct length for the new level.
…lamping - Restore MIN_SEQUENCE_LENGTH=0 (sequences range [0, BASE+level]) allowing fish to appear immediately (length 0) per design intent - Restore currentSequenceLength state variable and generateSequenceLength() - Restore pickNextImage() to compare against currentSequenceLength and regenerate it when the fish is returned - In recordResponse(), clamp currentSequenceLength to the new maximum whenever the level drops (fixes the core bug: sequences no longer stay too long after a 3-wrong-streak drops the player two levels) - Update it.each rand=0 → rand=0.2 to guarantee a non-zero sequence in those tests; add initGame() call inside it.each after spy setup - Fix 'starts a new go sequence after the fish' test to use a spy so the post-fish sequence is guaranteed non-zero - Update getCurrentSequenceLength() tests: range assertions, level-drop clamping assertion, and regeneration-on-fish assertion Agent-Logs-Url: https://github.com/acrosman/BrainSpeedExercises/sessions/f7bcb8f0-b2bb-4d2a-aa60-2efbbcf9b27a Co-authored-by: acrosman <2972053+acrosman@users.noreply.github.com>
Fixed in 0a0c94e. Reverted to randomized sequence lengths. |
Otter Stop sequences were fully random per trial. This PR introduces structured sequences: N otters followed by one fish, where N is sampled randomly from
[0, BASE_MAX_SEQUENCE_LENGTH + level]— giving sequences that grow with difficulty and shrink immediately when the level drops.Core logic (
game.js)Replaced the random
IMAGE_KEYSselection inpickNextImage()with sequence-based selection:MIN_SEQUENCE_LENGTH = 0— a sequence of length 0 means the fish appears immediately with no preceding ottersgenerateSequenceLength()samples uniformly from[0, BASE_MAX_SEQUENCE_LENGTH + level]— at level 0 that is [0, 5]; each level gained widens the upper bound by 1recordResponse()triggers a level drop,currentSequenceLengthis immediately clamped to the new maximum (BASE_MAX_SEQUENCE_LENGTH + newLevel) so in-flight sequences cannot exceed the reduced difficultyforceGoNextstill takes priority, advancingsequencePositionnormallystopGame()now returnsmaxSequenceLength(=BASE_MAX_SEQUENCE_LENGTH + level)getMaxSequenceLength(),getCurrentSequenceLength()Progress persistence (
index.js)stop()passesmaxSequenceLengthtosaveScoreviaextraFields, tracking the session high-water mark:Sequence length is not surfaced in the UI.
Tests (
game.test.js)it.eachvalues to guarantee non-zero sequence lengths when the spy is active (re-runsinitGame()inside the test after setting the spy);rand=0.2replacesrand=0for thego-1.pngcaseMath.random()=0.75→no-gotest with sequence-exhaustion tests'starts a new go sequence after the fish'test to use a spy ensuring the post-fish sequence is also non-zerogetMaxSequenceLength()(including a level-10 assertion) andgetCurrentSequenceLength()covering range assertions, level-drop clamping, and regeneration-on-fish