Guide to Creating New Bots for YGO Omega

Welcome to this comprehensive guide on creating new bots for YGO Omega! This tutorial will walk you through setting up your environment, cloning the project, and building a simple bot using C#. Whether you’re a beginner or an experienced developer, this guide will make the process engaging and straightforward. Let’s dive in!

Link: Files · first-version · Duelists Unite / DuelBotWrapper · GitLab


What is YGO Omega Bot Creation?

YGO Omega allows players to create custom AI bots for Yu-Gi-Oh! duels. These bots are coded in C#, leveraging the YGO Omega framework to simulate duel strategies. This guide focuses on creating a bot for the Master Duel format, including deck creation and basic AI actions.

Key Features:

  • Create custom decks with specific cards.
  • Define bot behaviors for summoning, setting, activating cards and others.
  • Test bots locally in YGO Omega.
  • Contribute to an open-source project with a vibrant community.

Step-by-Step Guide

Let’s build a simple bot from scratch, with visuals to guide you.

Step 1: Set Up Your Environment

  • Prerequisites:
    • Install C# via the .NET SDK.
    • Download your preferred code editor. We recommend Visual Studio Enterprise, but Visual Studio Code or Community editions work too.
  • Action: Install the .NET SDK and Visual Studio Enterprise. Ensure you include the Desktop development with C# workload during installation.

Step 2: Download or Clone the Project

  • Action: Visit the repository: Files · first-version · Duelists Unite / DuelBotWrapper · GitLab.
  • Switch Branch: Ensure you’re on the first-version branch for a stable starting point.
  • Download or Clone:
    • Download: Click the download button and extract the ZIP.
      OR
    • Clone: Use Git with the command:
      git clone -b first-version https://gitlab.com/duelists-unite/duelbotwrapper.git
      
  • Open Project: Load the solution file (.sln) in Visual Studio.

Step 3: Create a New Deck

  • Action: In YGO Omega, navigate to the Deck Editor and create a simple deck.

  • Example Deck:

  • Export Deck:

    • Go to Deck Manager in YGO Omega.
    • Select your deck and click Export.
    • Choose Clipboard code to copy the deck’s code.
  • DeckHash: Use the provided DeckHash for testing:

    02BYvDKcFYbXfTnDBMOTgh8zwPDL3d5MMPwwzAWOGRMF4DjqrSMzDC/eM5EVhhMyeBlBWG7VJ1YYzph6ngGEne39WWB4tvtxZhju992GggE=
    


Step 4: Add Deck to the Project

  • Action: In Visual Studio, expand the BotTest project, then navigate to Deck > DeckManager.cs.
  • Add Deck Name:
    • Add your deck to the MasterDuelDeck enum. For example:
      public enum MasterDuelDeck
      {
          TutorialTest,
          // Other decks...
      }
      
  • Add Deck Code:
    • In DeckManager.cs, add a new block for your deck using the clipboard code. Example:
        MasterDuelDeck.TutorialTest,
        (
            DeckName: "TutorialTest",
            DeckHash: "02BYvDKcFYbXfTnDBMOTgh8zwPDL3d5MMPwwzAWOGRMF4DjqrSMzDC/eM5EVhhMyeBlBWG7VJ1YYzph6ngGEne39WWB4tvtxZhju992GggE="
        )
      


Step 5: Create a New Bot

  • Action: In the project, navigate to Game > AI > Bots > MasterDuel.
  • Create Folder: Make a new folder named TutorialTest.
  • Add Classes:
    • Create TutorialTestActions.cs for bot actions.
    • Create TutorialTestCardId.cs for card IDs.
  • Card IDs:
    • In TutorialTestCardId.cs, define card IDs. Use the provided structure:
      public class TutorialTestCardId
      {
          public const int ManEaterBug = 54652250;
          public const int DarkMagician = 46986414;
          public const int SwordsOfRevealingLight = 72302403;
          public const int DarkMagicCurtain = 99789342;
      }
      
  • Bot Actions:
    • In TutorialTestActions.cs, add the following template:
      public class TutorialTestActions : RuleBasedBotActions
      {
          public TutorialTestActions(MasterDuelDeck deckId = MasterDuelDeck.TutorialTest)
          {
              DeckName = DeckManager.GetDeckName(deckId);
              DeckHash = DeckManager.GetDeckHash(deckId);
              InitializeCardInfo<TutorialTestCardId>();
          }
      }
      


Step 6: Register the Bot

  • Action: Open Program.cs in the BotTest project.
  • Add Bot:
    • Add your bot to the bot selection logic:
      MasterDuelDeck.TutorialTest => new TutorialTestActions((MasterDuelDeck)selectedDeck.Id)
      


Step 7: Test the Bot

  • Action:
    • Open YGO Omega and go to Local > Host.
    • Select AI_CUSTOM as the bot and click Add Bot.
    • Run the BotTest project in Visual Studio.
    • In YGO Omega, choose the Master Duel format and verify your bot (TutorialTest) appears in the list.
    • Select the bot, click Ready Up, and start the duel.



Advanced Section: Defining Card Actions

To make your bot smarter, define specific card actions in TutorialTestActions.cs. Use other bots as references for complex behaviors.

  • Basic Actions:

    • Add actions for summoning, setting, or activating cards:
      BotAction(
          action: MainAction.Activate,
          cardId: TutorialTestCardId.SwordsOfRevealingLight
      );
      BotAction(
          action: MainAction.Set,
          cardId: TutorialTestCardId.ManEaterBug
      );
      BotAction(
        action: MainAction.Summon,
        cardId: TutorialTestCardId.DarkMagician
      );
      
  • Conditional Actions:

    • Add conditions to control when cards are played:
      BotAction(
          action: MainAction.Activate,
          cardId: TutorialTestCardId.DarkMagicCurtain,
          condition: DarkMagicianCurtainCondition
      );
      
    • Define DarkMagicianCurtainCondition to check game state (e.g., if Dark Magician is available).
  • Pro Tip: Study other bots in the MasterDuel or SpeedDuel folder to learn advanced action patterns.


Tips for Success in Bot Development

  1. Test Frequently: Run your bot after every change to identify and fix errors early.
  2. Use References: Study existing bots to replicate complex behaviors and patterns.
  3. Check the Readme: Refer to the project’s README on GitLab for detailed setup instructions.
  4. Experiment: Test different decks and actions to craft unique and effective bots.
  5. Understand Game State: The game exposes elements like Phases, Turns, Chain, Bot, and Player. Explore these thoroughly to handle specific scenarios. For example, the Hammer Shot effect can destroy any card on the field if its condition is met, so you’d need to specify the Player’s card as the target.
  6. Explore WindBot: Check out the WindBot project by the team at https://github.com/IceYGO/windbot. You can study and adapt its logic into the Omega Wrapper. It may be challenging initially, but with dedication, you’ll see significant rewards!

Troubleshooting

  • Bot Not Appearing? Ensure the bot is registered in Program.cs and the deck is correctly added in DeckManager.cs.
  • YGO Omega Errors? Verify YGO Omega is running and the BotTest project is executed.
  • Need Help? Check the GitLab repository’s issues page or README for support.

Get Coding!

With this guide, you’re ready to create and test your own YGO Omega bot. Build your deck, code your bot, and duel in style! For more details, explore the repository: Files · first-version · Duelists Unite / DuelBotWrapper · GitLab.

Happy dueling!

1 Like