pmariglia / showdown

A Pokemon Showdown Battle Bot written in Python
GNU General Public License v3.0
257 stars 175 forks source link

Actually playing a move in state class #90

Closed Andyloris closed 2 years ago

Andyloris commented 2 years ago

Hi, i'm trying to implement tuning in showdown and, how can i play a move in the state class ?

pmariglia commented 2 years ago

Going to need more information. Do you have some sample code you're working with?

This is an example of a decision making function.. You want to return format_decision(self, <move_choice>). Something like : format_decision(self, "flamethrower"), or format_decision(self, "switch landorustherian")

Andyloris commented 2 years ago

I need to locally run a match beetween the bot and itself. How could i do this ?

pmariglia commented 2 years ago

I need to locally run a match beetween the bot and itself. How could i do this ?

Two ways you can do this:

  1. You can set up two bots and a local Pokemon-Showdown server. Set the configurations accordingly and let them play against each other. This will be slow because of needing to communicate with the PokemonShowdown server.
  2. Use the engine directly to simulate battles. This ~will~ might be faster, but note that the engine in this project is not a perfect Pokemon battle engine. There are things missing. For information about this look at this section of ENGINE.md

For option number 2 you want to generate instructions with:

instructions = get_all_state_instructions(mutator, my_move, your_move)

Pick a random instruction set based on the chances of each happening

chosen_instructions = random.choices(instructions, weights=[i.percentage for i in instructions])

and then apply one of the instructions with:

mutator.apply(chosen_instructions)
hsahovic commented 2 years ago

I think that option 1 is faster than option 2 if you disable throttling, which can be achieved with the --no-security flag - I got up to 20 games per second with it.

pmariglia commented 2 years ago

I think that option 1 is faster than option 2 if you disable throttling, which can be achieved with the --no-security flag - I got up to 20 games per second with it.

The bottleneck running this project's bot against itself will surely be running minimax + doing evaluations, not the PS server. Especially if something like depth=2 is used. Even at depth=1 games will still take ~40 seconds each. Running multiple sessions of the bot vs itself will speed it up, but you'll need the compute resources to keep up.