{"id":22657068,"url":"https://github.com/sunsided/box-search-strategy","last_synced_at":"2025-03-29T08:12:02.318Z","repository":{"id":263137020,"uuid":"889457014","full_name":"sunsided/box-search-strategy","owner":"sunsided","description":"A simulation of a seemingly paradoxical outcome of different search orders on a grid.","archived":false,"fork":false,"pushed_at":"2024-11-16T13:15:58.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T21:52:40.737Z","etag":null,"topics":["competitive-search","game-theory","grid-search","optimal-stopping","probability","rust","simulation"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunsided.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-11-16T12:41:18.000Z","updated_at":"2024-11-16T13:16:03.000Z","dependencies_parsed_at":"2024-11-16T13:31:22.827Z","dependency_job_id":null,"html_url":"https://github.com/sunsided/box-search-strategy","commit_stats":null,"previous_names":["sunsided/box-search-strategy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbox-search-strategy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbox-search-strategy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbox-search-strategy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbox-search-strategy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunsided","download_url":"https://codeload.github.com/sunsided/box-search-strategy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156416,"owners_count":20732397,"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","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":["competitive-search","game-theory","grid-search","optimal-stopping","probability","rust","simulation"],"created_at":"2024-12-09T10:17:26.006Z","updated_at":"2025-03-29T08:12:02.296Z","avatar_url":"https://github.com/sunsided.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📦🔍 Box Searching simulation\n\n\u003e Eight boxes are filled with two coins, where all boxes have equal\nprobability to have a coin. Alice searches the boxes left to right,\nthen row by row, whereas Bob searches the boxes top to bottom,\ncolumn by column. The first person to find a coin wins.\nAre Alice and Bob equally likely to win?\n\u003e \n\u003e ```text\n\u003e _________________\n\u003e |   |   | 🪙 |   |\n\u003e -----------------\n\u003e |   | 🪙 |   |   |\n\u003e -----------------\n\u003e ```\n\nOne could argue that if at least one coin is located in the top row, Alice\nhas an edge over Bob. If all coins are in the second row, Bob has an edge over\nalice. Since the distribution of coins is uniform, they might have equal chance.\n\nThis is incorrect, which might feel paradoxical at first glance due to our\nintuitive assumptions about symmetry and fairness. Here's a breakdown:\n\n1. **Symmetry Intuition:**\n  At first glance, Alice and Bob seem to have symmetric roles. Both are searching for coins in the same grid, with the same probabilities assigned to each box containing a coin.\n  Symmetry often leads us to expect equal chances of success, but the search order introduces an asymmetry in their strategies.\n2. **Traversal Bias:**\n  Alice searches left-to-right, row-by-row, while Bob searches top-to-bottom, column-by-column. The grid layout means their traversal paths overlap in non-intuitive ways. This can result in uneven probabilities of finding the coin first.\n3. **Dependence of Outcomes:**\n  If the coins are distributed probabilistically, the interaction between Alice's and Bob's traversal paths can create non-uniform probabilities for who finds a coin first, leading to unexpected results.\n\nThe outcome is not actually paradoxical as it is fully determined by\n* The distribution of coins in the grid.\n* The deterministic traversal strategies of Alice and Bob.\n\n## Simulation output\n\nHere's the example output of the simulation for Alice (row-wise search order),\nBob (column-wise search order) and Charlie (random order with uniform distribution):\n\n```text\nOutcome after for 2 rows, 8 columns, 2 coins (100000 trials)\n  row-wise wins:     46886 (37.76%)\n  column-wise wins:  33631 (27.09%)\n  random-order wins: 43641 (35.15%)\nOutcome after for 8 rows, 2 columns, 2 coins (100000 trials)\n  row-wise wins:     33508 (26.97%)\n  column-wise wins:  46577 (37.49%)\n  random-order wins: 44157 (35.54%)\nOutcome after for 8 rows, 8 columns, 2 coins (100000 trials)\n  row-wise wins:     36488 (33.29%)\n  column-wise wins:  36507 (33.31%)\n  random-order wins: 36599 (33.40%)\nOutcome after for 8 rows, 8 columns, 4 coins (100000 trials)\n  row-wise wins:     38292 (33.50%)\n  column-wise wins:  37917 (33.17%)\n  random-order wins: 38088 (33.32%)\n```\n\nFrom this we find that searching along the longest dimension has an edge\nover searching along the shortest dimension. We also find that a randomized search\nappears to be on par with the optimal directional strategy for the according\ngrid layout. This is because the coin distribution is randomized as well.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fbox-search-strategy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsided%2Fbox-search-strategy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fbox-search-strategy/lists"}