tchataway / poke-dojo

"Offline" BDSP Battle Tower simulator
1 stars 0 forks source link
pokemon

The "offline" Pokemon Dojo

In conjunction with an offline Pokemon Showdown server, battle the teams from Brilliant Diamond and Shining Pearl's Singles format Battle Tower.

AI has been coded by hand based on observations of in-game behaviour and online research and is still a work-in-progress. If you see erroneous logic, pull requests are most welcome!

How to Use

Environment Setup

Install poke-env

poke-dojo makes heavy use of the poke-env library. poke-env requires python >= 3.6 and a local Pokemon Showdown server.

pip install poke-env

Showdown Installation

There's one thing you need to update for your local server when running it, otherwise the normal installation instructions in the README suffice: Trainers in the Battle Tower aren't restricted by the Item Clause. Some teams have multiple Pokemon holding a Focus Sash, for example. With that in mind, your BDSP 3v3 singles format needs to remove that clause. You can do so by:

  1. Find and open pokemon-showdown/config/formats.ts.
  2. Find the config for [Gen 8 BDSP] 3v3 Singles (last I checked it was lines 1015 - 1022)
  3. In the list for ruleset, add '! Item Clause'. The ruleset line should now look like:
    ruleset: ['Flat Rules', '! Item Clause', 'Min Source Gen = 8'],

    Without this change, Showdown will reject Battle Tower trainers' attempts to challenge you if their team violates the item clause.

    Running the Simulator

  4. Once your Showdown server is up and running, connect to it and log in.
  5. Ensure you have a 3v3 singles format team ready to go.
  6. Note your username (top right corner, if you're unfamiliar with Showdown).
  7. Create a new folder, config, in poke-dojo's root directory.
  8. Inside config, create a challenger.txt file and inside it add the username noted in step 3, and nothing else. E.g., if your username is SaltyBoi420, the file would simply contain
    SaltyBoi420
  9. In poke-dojo's root directory, run the simulator.
    python .\battle_tower_simulator.py
  10. Back in Pokemon Showdown, you should have a challenge waiting for you. Accept it and get down to battling!

    AI notes regarding damage calculation

    Part of the AI's decision-making process involves simulating damage rolls against the opposing Pokemon. At the moment, this is done using POST requests to an API created by Smogon users Nineage and TheFenderStory. With this in mind, the simulator is not truly offline, because these requests obviously require an internet connection. It also slows down the AI's decision-making slightly. Having a proper, offline damage calculation solution is a high priority, but I don't have a clear plan for that yet, as the Pokemon Showdown calculator repository is in TypeScript, and short of hosting an offline calculator server to receive POST requests instead, I'm not sure how to utilise it. I'm open to ideas!

Special Thanks to