Small World is a Yu-Gi-Oh! card which is notorious for being difficult to understand. The idea is that you reveal a card from your hand, reveal a card from your deck with exactly one property in common with your original card, then reveal a third card also with exactly one property in common with the second card, and add that third card to your hand.
In theory, Small World can search any monster from your deck and add it to your hand. However, it may not be possible to bridge a card in your hand to the card that you want to search. The first card you reveal in your deck is referred to as the bridge which connects the card you reveal in your hand and the card you add to your hand.
If you use Small World, it is generally desirable to include one or more dedicated bridges that connects many cards in your deck so you have plenty of options for what to search starting from any card. However, such cards are difficult to find due to the many ways that cards can be considered connected. Because of the difficulty in optimizing a deck for Small World, there is a high barrier of entry to use the card.
The purpose of this repository is to assist in finding the best Small World bridges for any deck, as well as to visualize the connections between cards.
The card data cardinfo.json
is obtained from the Yu-Gi-Oh! API.
git clone https://github.com/KennethJAllen/ygo-small-world
cd ygo-small-world
- Install Poetry if not already installed.
- Run the following command in the project directory:
poetry install
poetry shell
You can now run the project's scripts within the poetry shell.
The command line interface for interacting with the Yu-Gi-Oh! Small World analysis tools and performing various analysesis is through main.py
. Hereβs how to use it:
-
Add .ydk File to Directory
- Add your .ydk file of the deck you wish to analyze to the ygo-small-world directory. A .ydk file may be downloaded from various online deck builder such as the Ygopro deckbuilder.
-
Using the Script:
- Find Bridges: To analyze bridges from a .ydk file:
py main.py deck_name.ydk bridges
- Generate Adjacency Matrix:
py main.py deck_name.ydk matrix
- Visualize Graph:
py main.py deck_name.ydk graph
- Visualize Matrix:
py main.py deck_name.ydk matrix_image
- Options:
--top TOP
: Limit the number of bridges shown forbridges
argument. e.g.--top 5
to only show top 5 bridges.--squared
: Square the adjacency matrix formatrix
ormatrix_image
arguments.--update_data
: Update the card data to the latest version if needed.
Ensure
deck_name.ydk
is replaced with your .ydk file name. - Find Bridges: To analyze bridges from a .ydk file:
For a more interactive approach or for example usage, you can utilize the Jupyter notebooks located in the examples
folder:
-
Initial Setup:
- Open
examples/bridge_generator_examples.ipynb
for top bridges or adjacency matrix outputs, orexamples/graph_adjacency_visualizer_examples.ipynb
for graph and adjaceny matrix image generation. - If using a .ydk file, place it in the
examples
folder. Note: Side deck monsters are included in the analysis. Replacesample_deck.ydk
with your file's name in all relevant cells. - Run the cell under Import Module to set up the environment.
- Open
-
Update Card Data:
- Run
fetch_card_data.py
to update the card data to the latest version if needed.
- Run
-
Finding Bridges to Required Targets:
- Open the
bridge_generator_examples.ipynb
notebook. - Edit
deck_monster_names
in the cell under Find Best Bridges From List of Names with your main deck monster names. To include a list of required targets that must connect to all bridges, editrequired_target_names
. Ensure that all card names match their official names, including capitalization and special characters. Card names can be verified on the Yu-Gi-Oh! card database.
- Open the
Consider a Mathmech deck consisting of the monsters
'Ash Blossom & Joyous Spring',
'D.D. Crow',
'Effect Veiler',
'Ghost Belle & Haunted Mansion',
'Mathmech Addition',
'Mathmech Circular',
'Mathmech Diameter',
'Mathmech Multiplication',
'Mathmech Nabla',
'Mathmech Sigma',
'Mathmech Subtraction',
'Nibiru, the Primal Being',
'PSY-Frame Driver',
'PSY-Framegear Gamma'.
Then the graph of connections via Small World can be visualized as follows.
The adjacency matrix corresponding to cards in a Mathmech deck is the following matrix. If an entry is black, that means the corresponding cards connect via Small World. If an entry is white, that means there is no connection.
Squaring the adjacency matrix, we get the following figure. If an entry is non-white, that means that one corresponding card can be searched from the other. The darker the color, the more connecting bridges the two cards have.
Every entry in the column corresponding to Mathmech Circular is non-zero except for the entry corresponding to Mathmech Multiplication, which means that Mathmech Circular can be searched with Small World starting from any monster in the deck except Mathmech Multiplication.
Moreover, the diagonal entries are the number of connections a card has to another card in the deck. The darker the entry, the more connections a card has to other cards in the deck.
The code to generate these figures may be found in the examples/graph_adacency_visualizer.ipynb
notebook.
We can use graph theory to calculate which cards can and cannot be searched via Small World starting from any card.
We can model the cards in a deck as the vertices of an undirected graph
Let
Starting with card
Entry
When using the bridge_generator_examples.ipynb
notebook, there is a bridge_score
output for each potential bridge
More specifically, the bridge score for any particular bridge
In more mathematical terms, consider a potential bridge
The bridge score is calculated as the number of non-zero elements in
Because of the block matrix structure of
Because
Therefore if there are