tchataway / poke-dojo

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

Cannot import name 'MOVES' from 'poke_env.data' #1

Open rjzhao07 opened 4 months ago

rjzhao07 commented 4 months ago

After I run battle_tower_simulator.py, it shows Traceback (most recent call last): File ".\battle_tower_simulator.py", line 7, in from battle_tower_player import BattleTowerPlayer File "C:\Users\xxx\Downloads\poke-dojo-master\poke-dojo-master\battle_tower_player.py", line 11, in from poke_env.data import MOVES ImportError: cannot import name 'MOVES' from 'poke_env.data' (C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\poke_env\data__init__.py) what shall I do to fix it?

btw, where can I find 'pokemon-showdown/config/formats.ts' when I need to change the Item Clause.

Thanks a lot!

tchataway commented 4 months ago

Hi there, thanks for reaching out! I'll do my best to get you up and running with poke-dojo.

It's been a while since I've worked on this codebase, and its dependencies (Pokemon Showdown and poke-env) have likely changed, so please bear with me!

The stack trace indicates that poke-dojo is having difficulty getting the MOVES collection from poke-env. I'll try to reproduce this issue myself when I next get the chance (it's currently 9pm local time for me). In the meantime, can you verify that the poke-env installation was successful? (pip install poke-env).

The formats.ts file is included with the pokemon-showdown repository, as it defines the different formats it can offer when the server is running, so if you're able to run a local instance of Showdown and connect to it in your browser, you should have the file already, located wherever you cloned the Pokemon Showdown repository to. I believe the file itself has changed considerably since I wrote the poke-dojo instructions, however.

I'll look into the poke-env issue when I can and get back to you as soon as possible!

rjzhao07 commented 4 months ago

Thank you so much for your efforts!

Yes, the poke-env installation was successful on my laptop. But I didn't know the local instance of Showdown is needed.

tchataway commented 4 months ago

I've looked into this and in doing so I discovered a much larger issue: the damage calculator API which the AI logic uses to evaluate moves is no longer available.

This means that even if everything else is configured correctly, the opposing trainer won't be able to make any decisions, which obviously renders poke-dojo completely useless.

In order to remedy this, I'll have to implement local damage calculation using Smogon's damage calculation repo. That will take some time, though. It's written in TypeScript and JavaScript, which means I'll need to write an interface through which poke-dojo can use it, because poke-dojo is written in Python, and therefore can't import the library directly.

But I didn't know the local instance of Showdown is needed.

The poke-dojo README isn't particularly clear on this point, my apologies. The Showdown server README does a good job of explaining how to get it up and running (it's very straightforward).

poke-dojo is hard-coded to connect to a local server with a BDSP format defined. It could technically be made to battle online, but that would require some code changes -- and most of the trainer teams (if not all) are not legal in any of the available formats at the moment. Also, a freshly-cloned Showdown repo no longer contains the BDSP format the Battle Tower uses, so a new one needs to be added to formats.ts, one that looks like:

{
    name: "[Gen 8 BDSP] 3v3 Singles",
    mod: 'gen8bdsp',
    searchShow: false,
    ruleset: ['Flat Rules','! Item Clause', '! Obtainable Moves', '+ Mythical', 'Min Source Gen = 8'],
},

Thanks for your patience. I'm sorry that you're not able to get straight in and battling!

rjzhao07 commented 4 months ago

BDSP battle tower is a great tool for testing team builds. Your efforts are greatly appreciated!