Fix reversed anode/cathode polarity on battery/generator - #90
Open
pangwangshu wants to merge 1 commit into
Open
Conversation
Generator.tick() put voltage on the anode and ground on the cathode, but every polarized load (LightBulb, ElectricMotor, ElectricBuzzer) only activates when its anode connects to ground and its cathode connects to voltage. This mismatch meant wiring a battery "naturally" (anode-to-anode, cathode-to-cathode) never completed a circuit; only the crossed wiring worked, which is why the gold-agent action sequences had been wiring devices crossed as a workaround. Swap the Generator's terminal assignment so natural, same-name wiring works as expected, and update the gold action sequences in TaskElectricCircuit, TaskElectricalConductivity, and TaskElectricalConductivity2 to match. Rebuild scienceworld.jar. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Aug 5, 2026
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.
Summary
Fixes #50.
Generator.tick()assigned voltage to the anode and ground to the cathode, butPolarizedElectricalComponent.tick()(inherited byLightBulb,ElectricMotor,ElectricBuzzer) only activates a load when its anode connects to ground and its cathode connects to voltage. BecauseTerminal.connectsToGround()stops traversal as soon as it reaches a generator terminal, this mismatch meant wiring a battery "naturally" (anode-to-anode, cathode-to-cathode, as the issue describes) never completed a circuit — only the crossed wiring (anode-to-cathode) worked. This is exactly why the gold-agent action sequences had been wiring devices crossed as a workaround.Generator.tick()(simulator/.../Generator.scala) so activation now requires natural, same-name wiring. This fixesBatteryand every other source that extendsGenerator(GasGenerator,NuclearGenerator,SolarPanel,WindGenerator) without touching the load side.TaskElectricCircuit,TaskElectricalConductivity, andTaskElectricalConductivity2to wire devices naturally instead of crossed, matching the fixed polarity.scienceworld/scienceworld.jar.The issue also asks to "regenerate training data" — that refers to the separately-built
goldpaths-all.ziparchive produced by an external/offline process outside this repo, out of scope for this change.Test plan
./simulator/package.sh— builds cleanly; rebuilt jar is byte-identical to the committed onetask-2-power-component,task-2-power-component-(renewable-vs-nonrenewable-energy),task-2a-test-conductivity,task-2a-test-conductivity-of-unknown-substancespytest tests/test_scienceworld.py— 7 passedtox -e flake8— cleantox -e precommit— clean on all hooks that apply to the changed files (theshellcheckhook itself can't run in this sandbox due to a CPU-architecture mismatch in the downloaded binary, unrelated to this change — no shell scripts were touched)🤖 Generated with Claude Code