{"id":31721212,"url":"https://github.com/axionbuster/gemssearch002","last_synced_at":"2025-10-09T03:44:25.020Z","repository":{"id":314007250,"uuid":"1052358085","full_name":"axionbuster/gemssearch002","owner":"axionbuster","description":"Solver for Gem Seeker (Tomb of the Mask+)","archived":false,"fork":false,"pushed_at":"2025-09-22T05:26:33.000Z","size":305,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-22T07:20:24.854Z","etag":null,"topics":["algorithm","gem-seeker","haskell","tomb-of-the-mask"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axionbuster.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-07T23:33:31.000Z","updated_at":"2025-09-22T05:26:36.000Z","dependencies_parsed_at":"2025-09-10T02:54:46.218Z","dependency_job_id":"2eaf98db-3f99-4b02-b933-a842d295ec74","html_url":"https://github.com/axionbuster/gemssearch002","commit_stats":null,"previous_names":["axionbuster/gemssearch002"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/axionbuster/gemssearch002","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axionbuster%2Fgemssearch002","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axionbuster%2Fgemssearch002/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axionbuster%2Fgemssearch002/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axionbuster%2Fgemssearch002/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axionbuster","download_url":"https://codeload.github.com/axionbuster/gemssearch002/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axionbuster%2Fgemssearch002/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000713,"owners_count":26082911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","gem-seeker","haskell","tomb-of-the-mask"],"created_at":"2025-10-09T03:44:24.093Z","updated_at":"2025-10-09T03:44:25.015Z","avatar_url":"https://github.com/axionbuster.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gem Seeker Solver\n\nA Haskell solver for the Gem Seeker minigame from Tomb of the Mask+.\n\n## Problem Description\n\nYou are given a 2D grid containing gems that need to be collected. The goal is to collect all gems by manipulating gravity to slide objects around the grid.\n\n### Game Mechanics\n\n- **Grid Elements:**\n  - `.` - Air (empty space)\n  - `@` - Gem (movable, must be collected)\n  - `%` - Bat (movable, dangerous)\n  - `#` - Obstacle/Wall (immovable)\n  - `*` - Target (collection point, always appears as air)\n\n- **Physics:**\n  - Each move changes gravity to one of four directions: Up, Down, Left, Right\n  - All movable objects (gems and bats) slide in the gravity direction until they hit an obstacle, boundary, or another object\n  - When a gem slides into the target position, it disappears immediately (gets collected)\n  - Objects cannot overlap or teleport through each other\n\n- **Win/Lose Conditions:**\n  - **Win:** All gems have been collected (reached the target)\n  - **Lose:** A bat reaches the target position\n  - **Continue:** Gems remain and no bat is at the target\n\n### Important Invariants\n\n- The target position (`*`) must always contain air in any valid game state\n- No gem, bat, or obstacle should ever occupy the target position\n- Gems disappear immediately upon sliding into the target\n\n## Input Format\n\n**Note:** Input and output formats are fluid and may change anytime.\n\n```\n\u003cnumber_of_test_cases\u003e\n\u003cwidth\u003e \u003cheight\u003e\n\u003cgrid_row_1\u003e\n\u003cgrid_row_2\u003e\n...\n\u003cgrid_row_height\u003e\n```\n\n### Example Input\n\n```\n1\n6 8\n@...#@\n.#....\n......\n...#..\n#..@.#\n......\n#*....\n..#...\n```\n\nThis represents:\n- 1 test case\n- Grid dimensions: 6 columns × 8 rows  \n- 3 gems at positions: (0,0), (0,5), and (4,3)\n- Target at position (6,1)\n- Various obstacles (`#`) throughout the grid\n\n## Output Format\n\nFor each test case:\n- `yes` if a solution exists, `no` if impossible\n- If solvable, show the initial state and each step with gravity direction\n- Display the final \"Won!\" or \"Lost!\" message\n\nNote: the output format is fluid and may change anytime as long as it remains human-readable.\n\n### Example Output\n\n```\nTest case 1:\nyes\nInitial state:\n@...#@\n.#....\n......\n...#..\n#..@.#\n......\n#*....\n..#...\n\nStep 1: Apply gravity Down\n....#.\n.#....\n......\n@..#.@\n#....#\n......\n#*....\n..#@..\n\nStep 2: Apply gravity Right\n(...)\nWon!\n```\n\n## Algorithm\n\nThe solver uses uniform-cost search (UCS) via Dijkstra's algorithm to find the optimal sequence of gravity changes:\n\n1. **State Representation:** Each game state consists of the board configuration and target position\n2. **Search Space:** Each move transitions to a new state by applying gravity in one direction  \n3. **Pathfinding:** Explores all possible sequences of moves to find the shortest solution\n4. **Optimality:** Guarantees the minimum number of moves required\n\n## Building and Running\n\n```bash\n# Build the project\nstack build\n\n# Run on input file\nstack exec gemssearch002-exe \u003c input.txt\n\n# Run tests\nstack test\n```\n\n## Implementation Details\n\n- **Language:** Haskell, but with efficient mutable arrays\n- **Core Module:** `TotM.hs` contains the game logic and solver\n- **Performance:** Handles complex puzzles with multiple gems efficiently\n\n## Example Usage\n\n```bash\necho \"1\n6 8\n@...#@\n.#....\n......\n...#..\n#..@.#\n......\n#*....\n..#...\" | stack exec gemssearch002-exe\n```\n\n## License\n\nBSD-3-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxionbuster%2Fgemssearch002","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxionbuster%2Fgemssearch002","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxionbuster%2Fgemssearch002/lists"}