{"id":16865579,"url":"https://github.com/erikras/war","last_synced_at":"2025-07-05T21:33:58.848Z","repository":{"id":70239987,"uuid":"171661760","full_name":"erikras/war","owner":"erikras","description":"Will this game of War ever end??","archived":false,"fork":false,"pushed_at":"2019-12-10T17:14:58.000Z","size":1166,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T17:53:26.289Z","etag":null,"topics":["card-game","cardgames","probability","statistics","war"],"latest_commit_sha":null,"homepage":"https://will-this-war-never-end.netlify.com","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erikras.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-02-20T11:36:01.000Z","updated_at":"2019-02-20T13:45:47.000Z","dependencies_parsed_at":"2023-04-15T01:26:22.404Z","dependency_job_id":null,"html_url":"https://github.com/erikras/war","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erikras/war","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fwar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fwar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fwar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fwar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erikras","download_url":"https://codeload.github.com/erikras/war/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikras%2Fwar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263809823,"owners_count":23515032,"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":["card-game","cardgames","probability","statistics","war"],"created_at":"2024-10-13T14:47:40.006Z","updated_at":"2025-07-05T21:33:58.834Z","avatar_url":"https://github.com/erikras.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Will This Game Of War Ever End?\n\nIf you've ever played the game of [War](\u003chttps://en.wikipedia.org/wiki/War_(card_game)\u003e), especially as a parent against a child, you may have wondered, \"_OMG, is this game ever going to end??_\" This project simulates the game to answer that very question. TL;DR: \"No, probably not.\"\n\nFor the purposes of this simulation, if you _ever_ run out of cards, either during normal play or during a \"war\" scenario, you lose the game.\n\nEach trial consisted of 1000 games, with randomly shuffled decks. What varied for each trial was how many maximum plays (card flips that could result in winning or losing cards) were allowed to be played before stopping. I was interested in how the probability of the game terminating goes up as you continue to play more and more rounds, and also how many \"blind cards\" (played face down to be won or lost in a \"war\") are played during a \"war\" scenario, as some people play with different rules about that.\n\n## Probability of Termination\n\nWith one blind card, the probability of the game ever ending goes up pretty linearly, but then levels out at about 60%, no matter how long you play. If you're playing with one blind card rules, you've got to play about 3,000 card flips to get to a 50-50 chance of the game ending. That's about two hours of playing _very_ quickly with a flip every 2.4 seconds.\n\nWith two blind cards, you can get to a 50-50 chance of the game ending with only 1,250 flips, that's just under an hour at the 2.4 seconds per flip rate, with the maximum probability of the game ending maxing out at around 73%, no matter how long you play. With three blind cards, the 50-50 point comes quickly at only 450 flips, and gets all the way up to a 90% chance of completion if you play forever.\n\n![Probability of Termination](https://raw.githubusercontent.com/erikras/war/master/charts/termination.jpg)\n\n## Average Total Plays\n\nHow many plays you will probably have for any given hard \"Okay, we're not gonna play more than X times\" limit?\n\nYou can be pretty certain that if you are playing with three blind cards, you probably won't end up playing more than 1,000 flips, no matter what your limit.\n\n![Average Total Plays](https://raw.githubusercontent.com/erikras/war/master/charts/plays.jpg)\n\n## Minimum Card Count\n\nWhat is the smallest hand you might get down to if you play forever (a game that does not terminate)?\n\nIf you're playing with one blind card, the answer is about 12, or just under a quarter of the entire deck. For two blind cards, the answer is 11, and for three blind cards, the answer is 10.\n\n![Minimum Card Count](https://raw.githubusercontent.com/erikras/war/master/charts/cards.jpg)\n\n## Conclusion\n\nIf you want your game of War to finish earlier, use more blind cards during each \"war\" scenario. But even so, you still might play until the heat death of the universe. ☠️\n\n---\n\nby Erik Rasmussen [@erikras](https://twitter.com/erikras)\n\n[Source code on Github](https://github.com/erikras/war)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikras%2Fwar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferikras%2Fwar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikras%2Fwar/lists"}