Skip to content

feat: Maze - #340

Open
JustATin555 wants to merge 67 commits into
masterfrom
robot-minigame
Open

feat: Maze#340
JustATin555 wants to merge 67 commits into
masterfrom
robot-minigame

Conversation

@JustATin555

@JustATin555 JustATin555 commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

Description

Implement the robot-minigame module for use as a Source Academy Game minigame.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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.

  • Standard yarn tests
  • Can render assessment workspace tab correctly
  • Functions work correctly

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@JustATin555
JustATin555 marked this pull request as ready for review June 14, 2025 10:21
@JustATin555
JustATin555 requested review from RichDom2185 and lhw-1 June 14, 2025 10:22

@RichDom2185 RichDom2185 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick run through as I'm outside right now, so just some preliminary comments, thanks!

Comment thread src/tabs/RobotMaze/index.tsx Outdated
Comment thread src/tabs/RobotMaze/index.tsx Outdated
Comment thread src/tabs/RobotMaze/RobotSimulation.tsx Outdated
Comment thread src/bundles/robot_minigame/helpers/tests.ts Outdated
@JustATin555
JustATin555 requested a review from RichDom2185 June 15, 2025 08:14

@lhw-1 lhw-1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lhw-1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments as well:

Comment thread src/tabs/RobotMaze/RobotSimulation.tsx Outdated
Comment thread src/tabs/RobotMaze/RobotSimulation.tsx Outdated
# 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.
@JustATin555 JustATin555 changed the title Robot minigame Maze Module Sep 2, 2026
@JustATin555 JustATin555 changed the title Maze Module feat: Maze Sep 2, 2026
JustATin555 and others added 6 commits September 2, 2026 14:53
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants