{"id":20576478,"url":"https://github.com/hazarddede/risk-sim","last_synced_at":"2025-07-04T13:06:33.658Z","repository":{"id":106666864,"uuid":"116693211","full_name":"HazardDede/risk-sim","owner":"HazardDede","description":"Risk Combat Simulator","archived":false,"fork":false,"pushed_at":"2018-01-15T08:21:20.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T11:19:06.605Z","etag":null,"topics":["risk-game","simulator"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HazardDede.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":"2018-01-08T15:22:19.000Z","updated_at":"2018-10-20T12:00:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e22fa4a-1d75-4509-99c2-22b9ce5b4f93","html_url":"https://github.com/HazardDede/risk-sim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HazardDede/risk-sim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazardDede%2Frisk-sim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazardDede%2Frisk-sim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazardDede%2Frisk-sim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazardDede%2Frisk-sim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HazardDede","download_url":"https://codeload.github.com/HazardDede/risk-sim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazardDede%2Frisk-sim/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263548654,"owners_count":23478808,"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":["risk-game","simulator"],"created_at":"2024-11-16T05:45:55.696Z","updated_at":"2025-07-04T13:06:33.638Z","avatar_url":"https://github.com/HazardDede.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# risk-sim - Risk Combat Simulator\n\nThis python program is a combat simulator for the famous `Risk` strategy board game.\n\nThe idea was born during an exciting game of `Risk: Halo Legendary Edition` with my family and friends.\nBack then I was curious about the odds when attacking an enemy army, which inspired my to write this little program to perform some hacker statistics in the `Risk` campaign setting.\n\nI will not take a deeper look at the rules - so if you are interested do it yourself:\n[https://www.wikihow.com/Play-Risk](https://www.wikihow.com/Play-Risk)\n\nThe `Risk: Halo Legendary Edition` introduced so called leaders (generals), which grants units in the same territory a +1 to the value of their rolled dices.\n\nBesides implementing some hacker statistics about `Risk` I also pursued the following goals:\n\n* Use `attrs` to model my container classes\n* Use `docopt` for parsing console arguments\n* Use `schema` for adapting additional validation\n\n## Installation\n\nCause I will not publish this repo via pypi you have to install it manually without pip support\n\n    # Clone this repo\n    https://github.com/HazardDede/risk-sim.git \u0026\u0026 cd risk-sim\n\n    # Make a python3 virtualenv\n    python3 -m venv venv \u0026\u0026 source venv/bin/activate\n\n    # Install the dependencies\n    pip install -r requirements.txt \u0026\u0026 pip install -r requirements-dev.txt\n\n    # Run the test to see if everything worked fine\n    pytest\n\n## Running the simulator\n\n    $ python risk_sim.py -h\n    Risk Simulator.\n\n    Usage:\n      risksim \u003cattacker\u003e \u003cdefender\u003e [-i \u003citer\u003e] [--attacking-general] [--defending-general]\n      risksim (-h | --help)\n      risksim --version\n\n    Arguments:\n      attacker      Number of attacking units (\u003e 1)\n      defender      Number of defending units (\u003e 0)\n\n    Options:\n      -h --help                      Show this screen.\n      --version                      Show version.\n      -i \u003citer\u003e --iterations=\u003citer\u003e  Number of iterations to simulate [default: 1000].\n      --attacking-general            Enables the general when attacking (+1 to all pips) [default: False]\n      --defending-general            Enables the general when defending (+1 to all pips) [default: False]\n\nFollowing these help page you have to\n\n    python -m risksim 100 50 --defending-general --iterations=1000\n\nto simulate a battle between 100 attacking and 50 defending units, while the defending army is lead by a general (+1 to all rolled dice values).\nThe same battle between those units will be repeated and recorded for a 1.000 times, leading to a summary statistic like below:\n\n    ╔Success Rate: 63.8 %════╦═════════╦════════╦═════════╗\n    ║ Metric       ║ avg     ║ median  ║ min    ║ max     ║\n    ╠══════════════╬═════════╬═════════╬════════╬═════════╣\n    ║ Attacks      ║ 68.174  ║ 69.0    ║ 49     ║ 77      ║\n    ║ Attacker     ║ --      ║ --      ║ --     ║ --      ║\n    ║ Casualties   ║ 87.872  ║ 92.0    ║ 45     ║ 99      ║\n    ║ Casualties % ║ 87.87 % ║ 92.0 %  ║ 45.0 % ║ 99.0 %  ║\n    ║ Survivor     ║ 12.128  ║ 8.0     ║ 1      ║ 55      ║\n    ║ Defender     ║ --      ║ --      ║ --     ║ --      ║\n    ║ Casualties   ║ 47.308  ║ 50.0    ║ 25     ║ 50      ║\n    ║ Casualties % ║ 94.62 % ║ 100.0 % ║ 50.0 % ║ 100.0 % ║\n    ║ Survivor     ║ 2.692   ║ 0.0     ║ 0      ║ 25      ║\n    ╚══════════════╩═════════╩═════════╩════════╩═════════╝\n\nCause the odds are highest when rolling three (attacker) or two (defender) dices the algorithm will always (if possible) maximize the number of rolled dices.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazarddede%2Frisk-sim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazarddede%2Frisk-sim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazarddede%2Frisk-sim/lists"}