feat: Maze - #340
Open
JustATin555 wants to merge 67 commits into
Open
Conversation
…to robot-minigame
…to robot-minigame
JustATin555
marked this pull request as ready for review
June 14, 2025 10:21
RichDom2185
requested changes
Jun 14, 2025
RichDom2185
left a comment
Member
There was a problem hiding this comment.
Did a quick run through as I'm outside right now, so just some preliminary comments, thanks!
lhw-1
reviewed
Jun 27, 2025
lhw-1
left a comment
There was a problem hiding this comment.
More of an overarching question - do you think it makes sense to frame it just as a maze minigame rather than a robot minigame? The idea of having it be a robot seems more context dependent within SA game, but as a module (which is published for not just Source Academy but for Source as a whole), it might be a nice idea to frame it as a general purpose maze minigame.
(Asking because this would necessitate some variable name changes)
lhw-1
reviewed
Jun 27, 2025
# Conflicts: # modules.json # package.json
Restructures src/bundles/maze and src/tabs/Maze to match the per-module package layout (package.json, manifest.json, tsconfig.json, src/) introduced by the yarn workspaces transition on master, and updates the tab to use the current defineTab/getModuleState helpers and package-based imports instead of the removed src/typings path and relative cross-package imports.
Replace throw new Error() with GeneralRuntimeError so thrown errors satisfy the throw-runtime-error rule, drop redundant type assertions, and apply eslint --fix for remaining stylistic warnings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Addresses lhw-1's PR review comment asking to allow the animation speed to change, mirroring the existing set_border_color/set_border_width pattern. Adds set_animation_speed() and covers it with unit tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
vi.mock's factory return type is checked against the module's real
export shape, so the mocked js-slang/context default needed to be a
full Context, not just { moduleContexts }. This was failing yarn tsc
in CI (TS2769) though it silently passed in local installs that
weren't in sync with a clean yarn.lock install.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AreaTest previously extended a loose Test interface ({ type: string;
test: Function }) that already accepted AreaTest-shaped object
literals structurally, so the `as AreaTest` cast at its only call
site was flagged as unnecessary and removed, leaving AreaTest as
dead code. Flipping the relationship to `type Test = AreaTest` keeps
AreaTest referenced and lets helpers/tests.ts's `type === 'area'`
check actually narrow to AreaTest's typed test() signature instead
of a bare Function.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
set_animation_speed() accepted 0/negative/NaN values with no validation. In the Maze tab's animation loop, a speed of 0 means `distance <= animationSpeed` never resolves (robot frozen forever), and a negative speed reverses the per-tick step so distance grows unboundedly — both permanently softlock the tab. Guard against non-finite and non-positive speeds with GeneralRuntimeError, matching this file's existing validation pattern. Separately, the rotate case's per-tick step was hardcoded to 0.1 rad regardless of animationSpeed, so turning pace stayed fixed while movement pace became configurable. Scale it by the same factor (0.05 rad/unit, calibrated so the default animationSpeed of 2 reproduces the previous 0.1 rad/tick) so move/turn pacing stays consistent. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implement the
robot-minigamemodule for use as a Source Academy Game minigame.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Checklist: