-
Notifications
You must be signed in to change notification settings - Fork 0
Merge add_findOpeningByMoves_util branch - Add chess opening detection utility #39
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
Co-authored-by: mterczynski <27309340+mterczynski@users.noreply.github.com>
| expect(findOpeningByMoves(moves)).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns the shortest matching opening if multiple match", () => { |
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.
this test doesnt match its title
| expect(findOpeningByMoves(moves)).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns the shortest matching opening if multiple match", () => { |
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.
Should return the longest matching, not the shortest one
| * Finds the opening that matches the given move history. | ||
| * Returns the matched opening object, or null if none found. | ||
| */ | ||
| export function findOpeningByMoves( |
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.
Can be renamed to findLongestMatchingOpeningByMoves
This PR successfully merges the
add_findOpeningByMoves_utilbranch, adding a utility function to detect chess openings based on move history and integrating it into the InfoBar component.Changes Made
New Utility Function
findOpeningByMoves.ts: A utility function that matches move sequences against the openings databasefindOpeningByMoves.test.tswith 4 test cases covering edge cases and normal usageutils/index.tsto prevent dependency cyclesInfoBar Integration
Implementation Details
The utility function:
Testing Results
Manual Testing
The application was tested by playing a chess game sequence (e4, e5, Nf3). The opening detection correctly shows no opening name since this 3-move sequence doesn't match any complete opening in the database - demonstrating proper functionality where openings are only detected when there's a complete match.
This resolves issue #18 by:
The utility is now available for use throughout the codebase and the InfoBar correctly displays opening names when recognized opening sequences are played.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.