{"id":15673974,"url":"https://github.com/sshine/rock-spock","last_synced_at":"2025-03-30T05:44:29.732Z","repository":{"id":66658585,"uuid":"264486376","full_name":"sshine/rock-spock","owner":"sshine","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-19T00:52:56.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T08:09:31.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/sshine.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-05-16T17:10:11.000Z","updated_at":"2020-05-19T00:52:58.000Z","dependencies_parsed_at":"2023-07-06T18:33:05.424Z","dependency_job_id":null,"html_url":"https://github.com/sshine/rock-spock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshine%2Frock-spock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshine%2Frock-spock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshine%2Frock-spock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshine%2Frock-spock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshine","download_url":"https://codeload.github.com/sshine/rock-spock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246281217,"owners_count":20752208,"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":[],"created_at":"2024-10-03T15:43:18.240Z","updated_at":"2025-03-30T05:44:29.716Z","avatar_url":"https://github.com/sshine.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rock-Spock\n\nA collection of small programs related to Rock-Paper-Scissors.\n\n## \"nig-nag-nug\"\n\n - Each player chooses value 1-4.\n - Choosing value just below opponent wins.\n - Otherwise, choosing highest value wins.\n - Choosing \"1\" gives you two points.\n\n### What's the better strategy in this game?\n\nIt depends on the opponent, but assuming everyone plays uniformly random?\n\nAnalysing this,\n\n - 4 \u003e 2 \u003e 1\n - 3 \u003e 4 \u003e 1\n - 2 \u003e 3\n - 1 \u003e 2 (and scores two points)\n\nBoth hands 4 and 3 beat two other hands and lose to one hand.\n\nBoth hands 2 and 1 beat one other hand and lose to two hands.\n\n### What hand scores the most points?\n\n```haskell\n$ stack ghci\nλ\u003e QC.generate (uniformGameGen 100000)\nfromList [(Hand 1,49744),(Hand 2,25064),(Hand 3,12544),(Hand 4,12513)]\n```\n\nPicking hand 1 gives the most points when playing against a uniformly random\nplayer in spite of losing more games. Maybe a player that picks hand 1 more\noften will win, on average, against a uniformly random player.\n\n### Pitting different strategies against one another\n\nThe following logic lets multiple players play each other, but we only use it\nfor two players for the initial hypothesis. At the core `roundM` plays a single\nround and `tournament` gathers the score for multiple rounds:\n\n```haskell\ntournament :: Int -\u003e Map Player (Gen Hand) -\u003e Gen (Map Player Int)\ntournament n = fmap (Map.unionsWith (+)) . replicateM n . roundM\n\nroundM :: Map Player (Gen Hand) -\u003e Gen (Map Player Int)\nroundM = fmap decideWinners . traverse go . Map.assocs\n  where\n    go :: (Player, Gen Hand) -\u003e Gen (Player, Hand)\n    go (player, handGen) = fmap (player,) handGen\n\nsimple :: Map Player (Gen Hand)\nsimple = Map.fromList\n  [ (Player 1, uniformHandGen)\n  , (Player 2, uniformGameGen 10000 \u003e\u003e= frequencyMapGen)\n  ]\n```\n\nTrying this out (this is very inefficient right now):\n\n```haskell\nλ\u003e QC.generate (tournament 1000 simple)\nfromList [(Player 1,500),(Player 2,454)]\n```\n\nApparently the uniform player is better, so my initial gut feeling was wrong.\nWhat if the next generation of strategies assumes some other discrete\ndistribution based on how many points the first uniform strategy scores? How\nwell would this perform against the uniform strategy and itself?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshine%2Frock-spock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshine%2Frock-spock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshine%2Frock-spock/lists"}