Git Product home page Git Product logo

cedh's Introduction

Magic the Gathering cEDH Database Analysis

Requirements

  • python
  • pip

Setup

You may want to use a virtual environment.

  • pip install -r requirements.txt

Files

py

  • main.py: execute this file to generate the decklist visualization
  • savedecks.py: execute this file to crawl and save the current decklists of the cEDH decklist database
  • cardstats.py: execute this file after savedecks.py to generate and save the card stats
  • correlation.py: execute this file to generate the card visualization
  • crawler.py: slightly modified copy of the cEDH Decklist Database crawler from https://anonymous.4open.science/r/cEDH-DDB-Crawler-D2E6
  • cards.json: card attributes like type and mana cost from Scryfall, generate using mtgslides and copy here
  • tree.pdf: generated file containing the visualization

dist

dist/data

These files are generated by executing scripts in the py folder above.

  • links.json: Decklist links of the cEDH decklist database as a JSON array of decklist links, mostly from moxfield. Generated by py/savedecks.py.
  • decks.json and decks.js: Decklists of the cEDH decklist database, Generated by py/savedecks.py.
  • cards.json and cards.js: Card status of the cEDH decklist database. Generated by py/cardstats.py after py/savedecks.py

GitHub Actions

savedecks.py and cardstats.py are run daily in a GitHub workflow and deployed to data folder of the gh-pages branch.

Docker

If you want to generate the card visualization with correlation.py but don't want to install Python or the required libraries, you can use Docker as follows:

docker build . -t mtgcompare
docker run mtgcompare

Dependencies on External Web Services

Monthly cEDH staples post

This is how I generate the monthly cEDH staples posts at https://reddit.com/r/cedh, for example see July 2022.

python py/savedecks.py
python py/cardstats.py

Or download https://github.com/KonradHoeffner/cedh/raw/gh-pages/data/cards.json to dist/data. Download the comparison file at that point in time from GitHub and save it to dist/data/cards.old.json.

python py/diff.py > diff.txt

Per request, only use the top two sections, top increased and top decreased.

Visualization Algorithm

  1. if links.json does not exist:
  2. if decks.json does not exist then for each moxfield decklist link:
  3. remove very common lands and mana rocks from the decks
  4. transform the decks into binary vectors using a DictVectorizer
  5. perform agglomerative clustering
  6. create the linkage matrix
  7. visualize the linkage matrix as a tree of labelled nodes

Future Work

  • use different distance functions
  • use commander identity and card color relative scores in visualization
  • add graph not based on clustering but on distance cutoff

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.