Skip to content

Add The Crimson King Deck - #292

Open
Malckyor wants to merge 3 commits into
IceYGO:masterfrom
Malckyor:master
Open

Malckyor wants to merge 3 commits into
IceYGO:masterfrom
Malckyor:master

Conversation

@Malckyor

@Malckyor Malckyor commented Oct 6, 2026

Copy link
Copy Markdown

The Crimson King deck, executor and dialogs added...

Note: This is a different executor which has some technical differences approaches from the other bots, I advise reading everything before deciding to use it.

This executor diverges from the traditional ones, instead of coding rules to follow scripted actions, I decided to make a decision engine to calculate plays and results based on guided routes, card value and endboard, which makes this bot adapt on each interaction and recalculate the routes to reach the best results trying as much as possible to outplay the player. There is the Mode=logic that makes the bot calculates even more plays and finding better endboards but usually takes +15s and that's not ideal, so by default it uses the Mode=fast where the ceiling is reduced and it will reach almost the same results as the logic one but it will take no more than +5s for that, which is pretty acceptable (Mode=turbo exists but barely changes the time and reduces a lot of the quality of the endboard, so ignore it).

It was thought to work with MDPro3 and due to the lack of information the bot can "see" from the card, like floodgates and other small things like "destroy" that it cannot tell when it's a thread or just not, I implemented an alternative to the default behavior for it to look reliably for the scripts from the game if the folder is closer to it, doing that the bot can "see" the effect more accurate to try to manage the thread, with that in mind and thinking on how to implement a better interaction I deliberated made it collect data over hundreds of duels and over a couple weeks of testing, then I made some logs which you will be able to see, it will find the card ID/name and log the effects, also it will search for card achetypes and cards that mentions it, then it will gather information and calculates risks of reaching threads (just like we do during a match), then I made it generates a log file to register games and try to learn from them, I noticed some behavior change but after all testing I was already tired and I'm not sure anymore if it will or not work, but I made sure to leave a switch in the code to turn it off since this is too ambicious and it would require more precise info that windbot can provide now and to work adding cards to lists of threads or whatever, I personally don't think it is practical due to how it will increase over time, anyway, to disable it just create a "thecrimsonking.pt-BR.json.off" inside the Dialogs folder.

This is the real log that my Windbot generates and you should see in cmd for the before mentioned systems:

[26-09-30 03:17:59] Duel started: The_Crimson_King versus Albaz
[26-09-30 03:17:59] Duel log: .\Yugioh\windbot-master\bin\Debug\Logs\20260930-031759_TheCrimsonKing_i1.jsonl
[26-09-30 03:17:59] [TheCrimsonKing] deck list matches: main 40, extra 15
[26-09-30 03:17:59] [TheCrimsonKing] decision mode: fast (width 400, ceiling 1500 ms, contenders 2)
[26-09-30 03:17:59] Albaz says: I've been walking for a long time, I'm hungry...
[26-09-30 03:17:59] Albaz says: My turn!
[26-09-30 03:17:59] The_Crimson_King says: Good luck, and have fun!
[26-09-30 03:17:59] The_Crimson_King says: Not so fast! I activate Maxx "C"!
[26-09-30 03:18:00] Albaz says: Come out, Aluber the Jester of Despia!
[26-09-30 03:18:00] [TheCrimsonKing] memory: collecting and deciding
[26-09-30 03:18:00] [TheCrimsonKing] Impermanence stops it: 1st opponent effect this turn (Aluber the Jester of Despia)
[26-09-30 03:18:00] [TheCrimsonKing] resolved: Aluber the Jester of Despia effect #0 from MonsterZone | to hand + search
[26-09-30 03:18:00] Albaz says: Activate the effect of Branded Fusion!
[26-09-30 03:18:00] [TheCrimsonKing] resolved: Branded Fusion (effect index unknown) from SpellZone | card does: special summon
[26-09-30 03:18:00] Albaz says: When will dinner be served?
[26-09-30 03:18:01] [TheCrimsonKing] reference index built: 14407 card names, 8152 quoted references
[26-09-30 03:18:01] [TheCrimsonKing] effect profile: Aluber the Jester of Despia
[26-09-30 03:18:01] [TheCrimsonKing]    e1: to hand + search | trigger | on EVENT_SUMMON_SUCCESS | once per turn
[26-09-30 03:18:01] [TheCrimsonKing]    e2: on EVENT_SPSUMMON_SUCCESS
[26-09-30 03:18:01] [TheCrimsonKing]    e3: special summon + disable | trigger | on EVENT_LEAVE_FIELD | once per turn
[26-09-30 03:18:01] [TheCrimsonKing] effect profile: Albion the Sanctifire Dragon
[26-09-30 03:18:01] [TheCrimsonKing]    e3: special summon | quick | on EVENT_FREE_CHAIN | once per turn
[26-09-30 03:18:01] [TheCrimsonKing]    e4: special summon | ignition | once per turn
[26-09-30 03:18:01] [TheCrimsonKing] effect profile: Fallen of Albaz
[26-09-30 03:18:01] [TheCrimsonKing]    e1: special summon | trigger | on EVENT_SUMMON_SUCCESS | once per turn
[26-09-30 03:18:01] [TheCrimsonKing]    e2: on EVENT_SPSUMMON_SUCCESS
[26-09-30 03:18:01] [TheCrimsonKing] effect profile: Guiding Quem, the Virtuous
[26-09-30 03:18:01] [TheCrimsonKing]    e1: to grave | trigger | on EVENT_SUMMON_SUCCESS | once per turn
[26-09-30 03:18:01] [TheCrimsonKing]    e2: on EVENT_SPSUMMON_SUCCESS
[26-09-30 03:18:01] [TheCrimsonKing]    e3: special summon | trigger | on EVENT_LEAVE_DECK | once per turn
[26-09-30 03:18:01] [TheCrimsonKing] effect profile: Branded Fusion
[26-09-30 03:18:01] [TheCrimsonKing]    e1: special summon | activate | on EVENT_FREE_CHAIN | once per turn
[26-09-30 03:18:01] [TheCrimsonKing] profile: 5 card(s) seen, archetypes: Branded, Dogmatika, Despia
[26-09-30 03:18:01] [TheCrimsonKing] memory: 3099 record(s) read, 1627 distinct key(s)
[26-09-30 03:18:01] [TheCrimsonKing] memory on Branded: 5 card(s) above lift 2,0 (baseline 24%) — Ash Blossom & Joyous Spring lift 2,0 of 35, Branded in White lift 3,0 of 26, Brightest, Blazing, Branded King lift 2,8 of 51, Called by the Grave lift 2,3 of 16, Mirrorjade the Iceblade Dragon lift 2,0 of 60
[26-09-30 03:18:01] [TheCrimsonKing] memory: 5 different route(s) lead to our trouble here, so cutting one does not stop it
[26-09-30 03:18:01] [TheCrimsonKing] 18 Extra Deck boss(es) reachable from what we have seen
[26-09-30 03:18:01] [TheCrimsonKing]   boss: Mirrorjade the Iceblade Dragon (ATK 3000, cost 110, support 1, by name) | materials: "Fallen of Albaz" + 1 Fusion, Synchro, Xyz, or Link Monster | already seen: Fallen of Albaz
[26-09-30 03:18:01] [TheCrimsonKing]   boss: Rindbrumm the Striking Dragon (ATK 2500, cost 90, support 1, by name) | materials: "Fallen of Albaz" + 1 Beast, Beast-Warrior, or Winged Beast monster | already seen: Fallen of Albaz
[26-09-30 03:18:01] [TheCrimsonKing]   boss: Ecclesia and the Dark Dragon (ATK 2500, cost 85, support 1, by name) | materials: 1 Tuner + 1+ non-Tuners
[26-09-30 03:18:01] [TheCrimsonKing]   boss: The Dragon that Devours the Dogma (ATK 3000, cost 80, support 1, by name) | materials: "Fallen of Albaz" + 1 LIGHT or DARK monster + 1 Effect Monster | already seen: Fallen of Albaz
[26-09-30 03:18:01] [TheCrimsonKing]   boss: Brigrand the Glory Dragon (ATK 2500, cost 80, support 1, by name) | materials: "Fallen of Albaz" + 1 Level 8 or higher monster | already seen: Fallen of Albaz
[26-09-30 03:18:01] [TheCrimsonKing]   boss: Despian Proskenion (ATK 3200, cost 75, support 2, by archetype) | materials: 1 "Despia" monster + 1 LIGHT monster + 1 DARK monster
[26-09-30 03:18:01] [TheCrimsonKing]   choke point: Fallen of Albaz -> Mirrorjade the Iceblade Dragon (cost 110)
[26-09-30 03:18:01] [TheCrimsonKing]   choke point: Aluber the Jester of Despia -> Despian Proskenion (cost 75)
[26-09-30 03:18:01] [TheCrimsonKing]   choke point: Guiding Quem, the Virtuous -> Despian Proskenion (cost 75)
[26-09-30 03:18:01] [TheCrimsonKing] first plan of the turn started calculating in the background (card drawn in the Draw Phase)
[26-09-30 03:18:01] The_Crimson_King says: I draw!
[26-09-30 03:18:01] [TheCrimsonKing] sets RDA's Chain to negate threats before the combo
[26-09-30 03:18:01] [TheCrimsonKing] RDA's Chain negates Albion the Sanctifire Dragon, Aluber the Jester of Despia (before the combo)
[26-09-30 03:18:01] The_Crimson_King says: I activate Red Dragon Archfiend's Chain!
[26-09-30 03:18:01] [TheCrimsonKing] background plan discarded: the state changed after the calculation started
[26-09-30 03:18:02] [TheCrimsonKing] new plan #1: 35 steps, tier 0, score 544, search route Soul (35 of 39 steps), 1509 ms | risks: exposure 10, cards given 0, nibiru 0 | hand=[Infinite Impermanence, King's Resonance, The Bystial Lubellion, Dominus Impulse, Soul Resonator] field=[] GY=[Maxx "C"]
[26-09-30 03:18:02] [TheCrimsonKing] profile: 5 searches, 30.998 states, 120.066 moves | successors 62% evaluate 21% nodes 12% sort 3% | cpu total 2810 ms, slowest search 1439 ms, wall 1509 ms, outside the search ~70 ms
[26-09-30 03:18:02] [TheCrimsonKing] phases: routes 2 ms, shortcut 0 ms, searches 1500 ms, seeds 0 ms, alternative 0 ms, resilience 0 ms, others 7 ms (wall 1509 ms)
[26-09-30 03:18:02] [TheCrimsonKing] resilience: starter "Soul searches Bone Archfiend": if negated, tier 3 score 104 (2 routes compared, the best-scoring one)
......

All the comments are in portuguese as these are my notes for better understanding since it's my native language, anyone trying to read it should translate on their own since I never planned to translate them.

There are lines of logging that does not exist in the current Windbot and where made for my local version for testing my engine and checking all decisions made, feel free to implement them on your own.

Also but not least, Claude helped me to make this faster and analyze thousands of data and running tests for a couple of weeks, I'm also not that good at coding and usually I leave broken or useless code behing since I either forget or don't know exactly what fixed what, so it could be my code or Claude code, so it might not be pretty (the reason for so many comments), but I can assure the quality of this work, anyway, use it or don't, it's your choice.

Dialogs for adding an extra personality care... GPT translated for everything that's not PT or EN, it's not made to sound like Jack Atlas, I know the deck is famous because of the anime, but I'm not him and this is my deck, if he wants theirs in the game, he can code his executor and add his list (jk).

The Crimson King deck, executor and dialogs added...

Note: This is a different executor which has some technical differences approaches from the other bots, I advise reading everything before deciding to use it.

This executor diverges from the traditional ones, instead of coding rules to follow scripted actions, I decided to make a decision engine to calculate plays and results based on guided routes, card value and endboard, which makes this bot adapt on each interaction and recalculate the routes to reach the best results trying as much as possible to outplay the player. There is the Mode=logic that makes the bot calculates even more plays and finding better endboards but usually takes +15s and that's not ideal, so by default it uses the Mode=fast where the ceiling is reduced and it will reach almost the same results as the logic one but it will take no more than +5s for that, which is pretty acceptable (Mode=turbo exists but barely changes the time and reduces a lot of the quality of the endboard, so ignore it).

It was thought to work with MDPro3 and due to the lack of information the bot can "see" from the card, like floodgates and other small things like "destroy" that it cannot tell when it's a thread or just not, I implemented an alternative to the default behavior for it to look reliably for the scripts from the game if the folder is closer to it, doing that the bot can "see" the effect more accurate to try to manage the thread, with that in mind and thinking on how to implement a better interaction I deliberated made it collect data over hundreds of duels and over a couple weeks of testing, then I made some logs which you will be able to see, it will find the card ID/name and log the effects, also it will search for card achetypes and cards that mentions it, then it will gather information and calculates risks of reaching threads (just like we do during a match), then I made it generates a log file to register games and try to learn from them, I noticed some behavior change but after all testing I was already tired and I'm not sure anymore if it will or not work, but I made sure to leave a switch in the code to turn it off since this is too ambicious and it would require more precise info that windbot can provide now and to work adding cards to lists of threads or whatever, I personally don't think it is practical due to how it will increase over time, anyway, to disable it just create a "thecrimsonking.pt-BR.json.off" inside the Dialogs folder.

All the comments are in portuguese as these are my notes for better understanding since it's my native language, anyone trying to read it should translate on their own since I never planned to translate them.
There are lines of logging that does not exist in the current Windbot and where made for my local version for testing my engine and checking all decisions made, feel free to implement them on your own.
Also but not least, Claude helped me to make this faster and analyze thousands of data and running tests for a couple of weeks, I'm also not that good at coding and usually I leave broken or useless code behing since I either forget or don't know exactly what fixed what, so it could be my code or Claude code, so it might not be pretty (the reason for so many comments), but I can assure the quality of this work, anyway, use it or don't, it's your choice.
@mercury233

Copy link
Copy Markdown
Collaborator

Thank you for the contribution. However, I'm not yet sure whether I can merge this PR. Automatically searching for and reading files outside the project directory seems risky. Storing a persistent memory file in the Dialogs directory under a dialogue-like filename is also concerning, although that should be straightforward to change. I also have some concerns about performance, particularly when running multiple duels concurrently.

Would it be possible to evaluate the deck's strength using WindBot Arena?

An automated AI review also identified the following issues. These findings are based on static analysis and have not been verified through runtime testing.

  1. [P2] No decompression size limit for automatically discovered ZIP files
    RdaScripts.Read() reads an entire archive entry using ReadToEnd(), without limiting its uncompressed size. The archive is discovered by searching up to six directory levels, including sibling directories. If another local user can write to one of those locations, a crafted script.zip containing a highly compressed card script could cause excessive memory allocation or prolonged blocking. Reading also holds a global lock, potentially affecting other duels. Please restrict discovery to explicitly configured, trusted locations and enforce limits on archive entries and actual bytes read. This requires local file placement; it is not a direct remote-upload vulnerability.

  2. [P2] Shared card models can lose updates and leak dynamic state across duels
    RdaCards.RegisterForeign() uses a ConcurrentDictionary, but adding a card, copying the dictionary, and publishing _lookup are not one atomic operation. Concurrent registrations can publish snapshots out of order, leaving a card present in All but missing from _lookup. Subsequent Get() calls can then return null, causing failures in the planner. The cache also permanently stores the card's current level, race, attribute, and tuner status, which may reflect temporary effects from another duel. Dynamic properties should belong to individual duel snapshots; shared models should contain only immutable card data.

  3. [P2] Concurrent memory-file writes can silently discard records
    KnowledgeFlush() appends to the same file from every duel without coordinating writes. If a write fails—for example, because another instance is writing—the exception is swallowed and _knowledgePending is cleared anyway, permanently losing the entire batch. Please coordinate appends and compaction, and clear pending records only after a successful write. Multiple processes sharing the same directory also need to be considered.

  4. [P2] Discarded background searches continue consuming resources
    When the game state changes, TakeBackgroundPlan() discards the task reference and starts a new search without cancelling the old one. The old task and its internal parallel searches continue running. Turn resets behave similarly, and there is no cancellation mechanism tied to duel termination. This adds unnecessary CPU and memory pressure, especially with concurrent duels. Please propagate cancellation through the searches and limit concurrent planning work. Time limits are currently checked only after an entire search depth has been processed, so they cannot promptly interrupt expensive expansion work.

Improved how it reads scripts, now it will ignore if the file is too big based on individual script file size and also added a key in the App.config so the user can set their script file path here instead of making another config file just for this bot (I still dislike the idea of changing something in windbot only for this bot).

Improved shared reading from the dictionary to decrease memory usage.

Improved how it checks on other cards that's not on the bot and added a reset so the attributes of the cards are not carried over after the duel.

Improved memory-file writes to avoid conflicts between multiple instances and fixing the issue it could have.

Improved the background searches since it was silently continuing in some cases.
@Malckyor

Malckyor commented Oct 8, 2026

Copy link
Copy Markdown
Author

Thank you for the concern and reporting all of them, I went up ahead and tried to improve them a bit more, I'm not sure if it would be enough to prevent all of them from happening, but it should work fine.

I deliberated choose to have the knowledge file inside the Dialog folder so users wouldn't just see a random log file and delete it, if I added it to my Log folder I would accidentally delete it, so instead I just moved it to a more suitable folder which will be created called "WindBot_knowledge" and inside it the knowledge file will be generated with the name of the bot + _knowledge suffix, the ".off" option to turn it off still existis and all that's necessary to do is add that after the .json extension.

As for testing with WindBot Arena... I must say that I'm not exactly very patient with setting a lot of apps just to never use them, even more when they require multiple settings and other tools outside of its own, so I tried and after failing a few times I gave up, so I'm not providing any feedback about that but feel free to test it on your own if you like.

If you have any more concerns, let me know and I'll see what I can do, I do not recommend merging the PR until you're satisfied with the results since this executor is different from the others.

Duel ends = closed connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants