Skip to content

Conversation

@Infinitay
Copy link
Owner

@Infinitay Infinitay commented Dec 11, 2025

fix(surpriseexam): Fixed next missing item solver from early return

  • Removed the code that calculates how many matches are in a relation and returns early if it's 4
    • This fixed the issue(s) with broader relationships early returning despite a more specific one was the answer
  • Added test case which was broken prior to this commit changes thanks to @rmobis

Example: Initial items were ranged and answer set [longsword, bow] -> they are both in COMBAT_ECOSYSTEM so it would early return matching the first item (longsword) instead of checking the other items too which would be the shortbow belonging to the answer relationship - RANGED_WEAPONS (See #33 (comment) for the particular problem)

- Removed the code that calculates how many matches are in a relation and returns early if it's 4
	- This fixed the issue(s) with broader relationships early returning despite another specific item was the answer
- Added test case which was broken prior to this commit changes thanks to @rmobis
@Infinitay Infinitay added surprise-exam Surprise Exam module testing Testing and verifying the changes implementing Actively working on this issue/PR labels Dec 11, 2025
- Modified similarity thresholds
- Refactored scoring constants/multipliers into statically defined variables instead
- Add support for negation words for puzzles hints containing negations
	- Added NEGATION_WORDS for negation keywords and NEGATION_OPPOSITE_MAP to map the reverse of various relationships
	- Fixes various matching puzzles that have hints like "who hate ranging or magic" where hate signals the negation
- Added #detectNegatedTokens to parse the hint for negation keywords and apply negation handling in analyzeRiddleAndFindItems():
- Modify #analyzeRiddleAndFindItems to handle negations
	- Penalize the relationship (hint words vs relationship) score for the relationship(s) being negated
	- Multiply negation's opposite relationship scores
- Added support for inverse context keyword matching within #expandWithContextAndSynonyms
- Correctly use JaroWinklerDistance#apply
	- Invert similarity distance logic
- Use similarity (instead of inverted) and its threshhold within #getRelationshipSimilarity
- Added extra test cases for matching puzzles with negation hints like "who hate ranging or magic" and more
@Infinitay
Copy link
Owner Author

Infinitay commented Dec 12, 2025

fix(surpriseexam): Improve relationship scoring and handle negation keywords

  • Modified similarity thresholds
  • Refactored scoring constants/multipliers into statically defined variables instead
  • Add support for negation words for puzzles hints containing negations
    • Added NEGATION_WORDS for negation keywords and NEGATION_OPPOSITE_MAP to map the reverse of various relationships
    • Fixes various matching puzzles that have hints like "who hate ranging or magic" where hate signals the negation
  • Added #detectNegatedTokens to parse the hint for negation keywords and apply negation handling in analyzeRiddleAndFindItems():
  • Modify #analyzeRiddleAndFindItems to handle negations
    • Penalize the relationship (hint words vs relationship) score for the relationship(s) being negated
    • Multiply negation's opposite relationship scores
  • Added support for inverse context keyword matching within #expandWithContextAndSynonyms
  • Correctly use JaroWinklerDistance#apply
    • Invert similarity distance logic
  • Use similarity (instead of inverted) and its threshhold within #getRelationshipSimilarity
  • Added extra test cases for matching puzzles with negation hints like "who hate ranging or magic" and more

Fixes the two incorrect matching puzzles found in #33 (comment)

@Infinitay
Copy link
Owner Author

test(surpriseexam): Add more tests for missing item puzzles

Added more test cases as found in #33 (comment)

- Fixed next missing item solver from returning early and giving incorrect solutions
	- Caused by multiple relations having full matches
	- Fixed next missing item puzzle that were weapons, and the answer set two different weapons melee/range
- Improved the OSRSItemRelationshipSystem and fixed wrong matching puzzle solutions
	- Reworked similarity distance and inverted the existing logic
	- Modified existing thresholds and multipliers
	- Added support for negations and matching puzzles with negated hints such as "hate ranging"
	- Fixed wrong matching puzzle solutions that contained hints like "who hate ranging or magic"
@Infinitay
Copy link
Owner Author

chore: Update plugin to v2.6.1

  • Fixed next missing item solver from returning early and giving incorrect solutions
    • Caused by multiple relations having full matches
    • Fixed next missing item puzzle that were weapons, and the answer set two different weapons melee/range
  • Improved the OSRSItemRelationshipSystem and fixed wrong matching puzzle solutions
    • Reworked similarity distance and inverted the existing logic
    • Modified existing thresholds and multipliers
    • Added support for negations and matching puzzles with negated hints such as "hate ranging"
    • Fixed wrong matching puzzle solutions that contained hints like "who hate ranging or magic"

@Infinitay Infinitay merged commit ecccf4b into master Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

implementing Actively working on this issue/PR surprise-exam Surprise Exam module testing Testing and verifying the changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants