{"id":20898863,"url":"https://github.com/coldmayo/40kai","last_synced_at":"2026-04-14T01:31:48.545Z","repository":{"id":232111991,"uuid":"783496125","full_name":"coldmayo/40kAI","owner":"coldmayo","description":"Warhammer 40k AI","archived":false,"fork":false,"pushed_at":"2024-07-20T03:57:18.000Z","size":57086,"stargazers_count":12,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T17:46:21.369Z","etag":null,"topics":["reenforcementlearning","tabletop-gaming","ttrpg","wargame","warhammer","warhammer-40k"],"latest_commit_sha":null,"homepage":"","language":"Python","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/coldmayo.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}},"created_at":"2024-04-08T02:21:47.000Z","updated_at":"2025-12-27T11:13:16.000Z","dependencies_parsed_at":"2024-04-15T06:04:40.526Z","dependency_job_id":null,"html_url":"https://github.com/coldmayo/40kAI","commit_stats":null,"previous_names":["coldmayo/40kai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coldmayo/40kAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldmayo%2F40kAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldmayo%2F40kAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldmayo%2F40kAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldmayo%2F40kAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coldmayo","download_url":"https://codeload.github.com/coldmayo/40kAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldmayo%2F40kAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31778580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T00:11:49.126Z","status":"ssl_error","status_checked_at":"2026-04-14T00:10:29.837Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["reenforcementlearning","tabletop-gaming","ttrpg","wargame","warhammer","warhammer-40k"],"created_at":"2024-11-18T11:12:27.590Z","updated_at":"2026-04-14T01:31:48.523Z","avatar_url":"https://github.com/coldmayo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n  40kAI\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n## Contents\n\n\n1. \u003ca href=\"#description\"\u003eDescription\u003c/a\u003e\n2. \u003ca href=\"#gameplay\"\u003eGameplay\u003c/a\u003e\n\t- \u003ca href=\"#phases\"\u003ePhases\u003c/a\u003e\n\t- \u003ca href=\"#victory-conditions\"\u003eVictory Conditions\u003c/a\u003e\n\t- \u003ca href=\"#stratagems\"\u003eStratagems\u003c/a\u003e\n\t- \u003ca href=\"#factions\"\u003eFactions\u003c/a\u003e\n3. \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\n4. \u003ca href=\"#contact-me\"\u003eContact\u003c/a\u003e\n\n## Description\n\nI was new to the Warhammer 40k tabletop game and I unfortunitly had no one to play with. So, I took matters into my own hands. I decided to make an RL model to play against, to sharpen my skills. To accomplish this, I am making a custom 40k Gymnasium environment and a DQN using PyTorch.\n\n## Gameplay\n\n### Phases\n\nJust like the tabletop game, it is played in turns, with each turn divided into several phases:\u003cbr\u003e\n\n1. Command Phase\n   - Both players gain 1 Command Point and resolve BattleShock tests\n2. Movement Phase\n   - Players move their units across the battlefield according to their movement characteristic\n   - Units can move, advance, and fall back\n3. Shooting Phase\n   - Units equipped with ranged weapons can target and attack enemy units within their weapon's range\n4. Charge Phase\n   - Units within 12 inches of each other can attempt to charge and engage in close combat.\n   - The player rolls 2D6 and if the result brings the unit within 5 inches of the enemy unit (in Engagement Range) successfully charge, Otherwise the unit fails and does not move\n5. Fight Phase\n    - Close combat between engaged units is resolved\n\n### Deployment\n\nBefore the game is played, a deployment card is drawn at random. These cards determine where the players can place their units on the board. The ones currently available are:\n- Search and Destroy\n- Hammer and Anvil\n- Dawn of War\n\n### Victory Conditions\n\nThe only mission available is Only War and the Victory Conditions are described below:\n- Major Victory:\n   - All foes are eliminated\n- Slay and Secure:\n   - At the end of the game each Objective Marker are worth 2 Victory Points to the player that controls it. Players also earn D3 Victory Points if the opposing Warlord is defeated\n- Ancient Relic:\n   - At the start of the first battle round, but before the first turn begins, select an objective marker. At the end of the battle, whoever controls that objective marker receives 6 Victory Points\n- Domination:\n   - At the end of each turn each objective marker is worth 1 Victory Point to the player who controls it. Keep a running score from turn to turn\n\nThese victory conditions are decided by a roll of a D3 before the first turn and there will be 5 total turns in a game. (or less if one army gets a Major Victory before then)\n\n### Stratagems\n\nAlso, players can use Command Points on Stratagems, which are special abilities that can be activated during certian points of the game. The ones that are supported so far are:\n- Fire Overwatch\n\t- This strategem allows the selected unit to act as if it's their Shooting Phase before the opponent's charge roll\n- Insane Bravery\n\t- If a unit fails a Battle shock test, the player can use this strategem so the unit is not effected by it\n- Smokescreen\n\t- Gives all models in unit the Benefit of Cover and the Stealth ability until the end of their opponent's next turn\n- Heroic Intervention\n\t- The player can select one of their units and use 2 CP to charge an enemy unit while they are in combat with another unit. So essentailly the player can switch units in combat. This only works if the unit is within 6 inches of the enemy.\n### Factions\n\nCurrent factions available are:\n- Space Marines\n- Adeptus Custodes\n- Adepta Sororitas\n- Orks\n- Tyranids\n- Adeptus Mechanicus\n- Astra Militarum\n- Tau\n\n## Installation\n\n### Application \n\nBefore proceeding make sure your device meets the below requirements:\n- Runs a Linux Distribution (Windows and Mac not supported)\n   - Confirmed to work on Arch Linux (working on more)\n- Has the following installed:\n   - Python and pip\n   - gtkmm\n   - make\n   - cmake\n   - gcc\n   - nlohmann-json\n\n```bash\n# clone repo\n$ git clone https://github.com/coldmayo/40kAI.git\n\n# go into /40kAI/installation/ directory\n$ cd installation\n\n# (optional) build install script\n$ make\n\n# run install script\n$ make run\n\n# or\n$ ./install\n\n# while running the script, type \"install\" into the prompt\n\u003e install\n\n# Once finished, exit the script with the \"exit\" command\n\u003e exit\n```\n\nOnce the above is completed, one should be able to find the .desktop file in the /home/your_username/.local/share/applications directory.\n\nGo \u003ca href=\"https://github.com/coldmayo/40kAI/blob/main/gui/README.md\"\u003ehere\u003c/a\u003e to learn more about how to use the app.\n\n### Bash Scripts\n\nIf you don't use the install script you have to install all of the python packages manually. Luckily the list of requirements are a lot smaller (all you need is Python and pip). Instructions are as follows below:\n\n```bash\n# create virtual environment\n$ python -m venv .venv\n\n# cd into gym_mod folder\n$ cd gym_mod\n\n# install packages\n$ pip install .\n\n# train model (chmod +x train.sh if permission error)\n./train.sh\n\n# play against model (chmod +x play.sh if permission error)\n./play.sh\n```\n## Contact Me\n\nThis project is still being worked on, if you have any suggestions or found bugs you can either open an issue or email me \u003ca href=\"mailto:coldmayo@proton.me\"\u003ehere\u003c/a\u003e. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldmayo%2F40kai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoldmayo%2F40kai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldmayo%2F40kai/lists"}