Skip to content

Pin where directional moves start and when they throw - #81

Merged
dmccoystephenson merged 1 commit into
masterfrom
feature/pin-directional-move-start-location
Nov 11, 2026
Merged

dmccoystephenson merged 1 commit into
masterfrom
feature/pin-directional-move-start-location

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Stage B (unit-test expansion) for the directional move methods: Environment::moveEntityInDirection finds the starting location with Grid::getLocation(entity.getLocationId()), which runs before the try that turns an off-grid step into false. Neither behavior was tested or documented.
  • Test 80 shows that a directional move starts from the location the entity's location id names, not from the location that actually stores it. The entity is stored in 0-1-1 with its location id set to 0-0-0, and moveEntityRight puts it in 0-1-0.
  • Test 81 shows that moveEntityUp and moveEntityToRandomAdjacentLocation throw std::runtime_error when the location id names no grid location, and that the entity stays where it was.
  • The README's "Grid Layout and Movement" and "Errors" sections now describe both behaviors.
  • Production code is unchanged. These are characterization tests that record what the code currently does.

No tracking issue: the gap was found during triage. The issue tracker was empty at triage, so no issues were skipped.

Test plan

  • CI Library tests (make + CMake) runs bash run_tests.sh and every test through Test 81 prints --- Success. Local runs of the test binary are denied in this environment, so CI is the anchor.
  • The ASan and CMake steps in the same job pass.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Directional moves look up the entity's current location by its location
id, outside the try that turns an off-grid step into false. Two tests pin
that the move steps from the named location and that an id naming no grid
location throws and leaves the entity in place; the README documents both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (anchor: CI run 42985819569, Library tests (make + CMake). Local execution of the test binary is denied in this environment.)

  • Local test suite: PASS. bash run_tests.sh in CI printed --- Success for every test through Test 81. The ASan step also printed Test 81 --- Success, and ctest reported 100% tests passed. The Strata and web build jobs are also green.
  • Scope: PASS. Only src/tests.cpp (+45) and README.md (+3/-1) change, and both are about how directional moves find their starting location.
  • Tests-new: PASS (not applicable). No public method is added. Two characterization tests cover existing behavior.
  • Tests-fix: not applicable. This is not a bug fix, and production code is unchanged.
  • Sibling structure: PASS. The new functions follow the existing void test<Behavior>() / Test N - ... / --- Success pattern, and their try/catch shape matches Tests 51–52.
  • Sibling renames: not applicable.
  • Docs: PASS. The README statements were checked against src/environment.cpp: moveEntityInDirection calls getGrid()->getLocation(entity.getLocationId()) before its try, so the lookup's runtime_error propagates; removeEntity then goes through Grid::removeEntity, which removes the entity from every location whose stored entity matches by id. The class table is unchanged and still accurate.
  • Issue resolution: not applicable. There is no Closes reference, because the gap was found during triage.
  • Test registration: PASS. Both functions are called at the end of main(), and CI printed both lines.
  • Header/definition parity, include guards: not applicable. No header changed.

Observations:

  • src/tests.cpp Test 80: the check that 0-2-1 is empty is the meaningful sentinel. 0-2-1 is where a move starting from the actual storage location would land, so the test can tell the two starting points apart.
  • src/tests.cpp Test 81: moveEntityToRandomAdjacentLocation throws whichever direction rand() picks, because the lookup happens before the direction is chosen. The assertion is therefore deterministic.
  • Out of diff: moveEntityToNewLocation does not read the location id, so it is not affected. This was left unpinned to keep the PR small.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit a6d9174 into master Nov 11, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/pin-directional-move-start-location branch November 11, 2026 08:20
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.

1 participant