coldmayo / 40kAI

Warhammer 40k AI
1 stars 0 forks source link
reenforcementlearning tabletop-gaming ttrpg wargame warhammer warhammer-40k



40kAI

Contents

  1. Description
  2. Gameplay
  3. Installation
  4. Contact

Description

I 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.

Gameplay

Phases

Just like the tabletop game, it is played in turns, with each turn divided into several phases:

  1. Command Phase
    • Both players gain 1 Command Point and resolve BattleShock tests
  2. Movement Phase
    • Players move their units across the battlefield according to their movement characteristic
    • Units can move, advance, and fall back
  3. Shooting Phase
    • Units equipped with ranged weapons can target and attack enemy units within their weapon's range
  4. Charge Phase
    • Units within 12 inches of each other can attempt to charge and engage in close combat.
    • 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
  5. Fight Phase
    • Close combat between engaged units is resolved

Deployment

Before 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:

Victory Conditions

The only mission available is Only War and the Victory Conditions are described below:

These 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)

Stratagems

Also, 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:

Current factions available are:

Installation

Application

Before proceeding make sure your device meets the below requirements:

# clone repo
$ git clone https://github.com/coldmayo/40kAI.git

# go into /40kAI/installation/ directory
$ cd installation

# (optional) build install script
$ make

# run install script
$ make run

# or
$ ./install

# while running the script, type "install" into the prompt
> install

# Once finished, exit the script with the "exit" command
> exit

Once the above is completed, one should be able to find the .desktop file in the /home/your_username/.local/share/applications directory.

Go here to learn more about how to use the app.

Bash Scripts

If 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:

# create virtual environment
$ python -m venv .venv

# cd into gym_mod folder
$ cd gym_mod

# install packages
$ pip install .

# train model (chmod +x train.sh if permission error)
./train.sh

# play against model (chmod +x play.sh if permission error)
./play.sh

Contact Me

This project is still being worked on, if you have any suggestions or found bugs you can either open an issue or email me here.