-
Notifications
You must be signed in to change notification settings - Fork 4
Fixed the bots spinning back to their starting heading when going to home #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes robot behavior when returning home after capturing a piece by preventing them from spinning back to their starting heading. The fix introduces a noReverse parameter that disables the reversal of setup commands for captured pieces.
- Added a
noReverseboolean parameter to prevent robots from spinning back to starting positions - Fixed import statement and error handling by replacing
errorwith properErrorconstructor - Refactored AI move timing to wait for robot movements before sending move messages
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/server/robot/path-materializer.ts | Added noReverse parameter and fixed import/error handling |
| src/server/command/move-piece.ts | Modified command reversal logic based on noReverse flag |
| src/server/api/game-manager.ts | Changed AI move timing to wait for robot completion |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/server/command/move-piece.ts
Outdated
| (command) => | ||
| !noReverse ? command.reverse() : command, |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When noReverse is true, the setup commands are not reversed but still added to the command group. This means the robots will execute the same setup commands twice (once in setup, once in 'cleanup'), which could cause incorrect positioning.
| import { GridIndices } from "./grid-indices"; | ||
| import type { Robot } from "./robot"; | ||
| import { error } from "console"; | ||
| //import { error } from "console"; replaced with Error |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has a grammatical error. It should be 'replaced with Error constructor' or simply 'replaced with Error'.
| //import { error } from "console"; replaced with Error | |
| //import { error } from "console"; replaced with Error constructor |
| } | ||
| if (!finalDestination) { | ||
| throw new error("WHERE THE HELL ARE YOU GOING"); | ||
| throw new Error("WHERE THE HELL ARE YOU GOING"); // real |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message is unprofessional and unclear. Consider using a more descriptive message like 'Unable to determine final destination for robot movement'.
| throw new Error("WHERE THE HELL ARE YOU GOING"); // real | |
| throw new Error("Unable to determine final destination for robot movement"); |
I just added a boolean in some methods to differentiate between captured and uncaptured pieces, haven't seen any issue pop up because of it