Skip to content

AsperaDesu/LoL-AI-Draft-Picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoL AI Draft Picker

A machine learning-based draft pick assistant for League of Legends, trained to suggest optimal champion picks and roles based on professional play data.


Features

  • Predicts optimal champions and roles using AI
  • Trained on historical LCK draft data under a Transformer Model
  • Modular architecture: scraping, preprocessing, training
  • Easily extendable for new patches or metas

Requirements

Install dependencies with:

pip install -r requirements.txt

☁How to Use on Google Colab (Cloud)

You can run this project fully in the cloud using Google Colab — no local installation needed.

Open Colab to get started immediately.


How to Use (Locally)

  1. Clone the Repository

    git clone https://github.com/AsperaDesu/LoL-AI-Draft-Picker.git
    cd LoL-AI-Draft-Picker
  2. Run data_scraper.py You may modify the URL variable to have a dataset of a different tournament.

    import json
    from tqdm import tqdm
    
    URL = "https://lol.fandom.com/wiki/Special:RunQuery/PickBanHistory?PBH%5Bpage%5D=LCK+2024+Summer&PBH%5Btextonly%5D=Yes&_run="
    HEADERS = {"User-Agent": "Mozilla/5.0"}
  3. Output

    A new .json file will be created in the data/ folder. It contains scraped pick and ban data.

  4. Train the Model

    Run every cell in training.ipynb to start training the model.


Optional: Skip Training

If you don't want to retrain the model from scratch, you can use the pre-trained weights provided:

  1. In training.ipynb, skip the training cell and run the very bottom cell:

    model.load_state_dict(torch.load('model_weights.pth'))
    model.eval()

This skips the training process and lets you instantly run inference.


Overview

This is a project created to test my knowledge from Andrej Karpathy's NN Playlist. Noticably, the implementation of Self Attention and Transformer in this project is majorly inspired from what he had covered.

Core Components & Techniques
  • Input Masking Inspired from how Transformers are masked where inputs are only known until the N-th element.

  • Winner Emb The usage of winner_emb is to encourage the model to optimize towards the winning draft and less to the losing one.

  • Class Emb To make the model understand the composition of the team.

    • Contains special token START
  • Position Emb To distinguish first pick, last pick and anything in between

  • Type Emb Differentiates Pick and Ban

    • Contains special token START
  • Score Linear Projection To estimate a score to measure how "optimal" a champion is on that current patch and pass it down to a projection layer.

  • Team Emb Blue versus Red Team's turn is different so we factor that in to the input

    • Contains special token START
  • Champ Emb Every champ has different skillset, counter, and countered by.

    • Contains special token <start>
  • Joint Logits Stores logits with the last two shape of (champ_vocab, ROLES) so the model's output contains how synergeous a champion is to all possible roles.

  • Champ and Role Loss While not used/returned during forward function, it is used to help guide the model effectively.

  • Top K Sampling during Simulation Due to concerns that the set of champions that are appropriate to pick/ban combined don't have a high enough probability to make it consistent, we only sample the 20 highest logits.

Loss Graph

    import matplotlib.pyplot as plt
    lossi = torch.tensor(lossi)
    loss_50 = lossi.view(-1, 50)
    loss_50_mean = loss_50.mean(dim=1)
	
    plt.figure(figsize=(10, 6))
    plt.plot(loss_50_mean)

Plot

What to Improve

  • Add full flex-pick role probability modeling
  • Model can reevaluate roles after a flex pick
  • Deploy as a public web app or Discord bot
  • Closer attention to Trio ([Top, Mid, Jungle], [Bot, Support, Jungle]) and Duo (Bot and Support) synergies

📝 License

This project is licensed under the MIT License.


👤 Author

Made by @AsperaDesu — mind behind the project

About

A machine learning-based draft pick assistant for League of Legends, trained to suggest optimal champion picks and roles based on professional play data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors