Problems in using the local simulator

:psysad:Sorry for such a stupid question but I just get started with nodejs. I successfully installed showdown to nodejs and started a random battle following the instruction in the md file in github, then I got trouble sending decision of the 1st turn. According to the md file, I should type something like p1 default or p1 move 1 or p1 switch 2, but the simulator keeps responding Unexpected token. So what should I do to properly send the decision? Thanks.
QQ图片20230315190120.png

QQ图片20230315191030.png
 

Mathy

F░U░R░R░E░T░ I░N░ B░I░O░
is a Programmeris a Forum Moderatoris a Battle Simulator Moderator
Hi! I won't have my PC until tomorrow but I'll see if I can help you troubleshoot.

It seems the Node eval console is running. What command(s) did you enter to run PS?
 
Hi! I won't have my PC until tomorrow but I'll see if I can help you troubleshoot.

It seems the Node eval console is running. What command(s) did you enter to run PS?
:psytear:Thanks for troubleshooting! I used these lines from the md files to start a battle:

const Sim = require('pokemon-showdown');
stream = new Sim.BattleStream();

(async () => {
for await (const output of stream) {
console.log(output);
}
})();

stream.write(`>start {"formatid":"gen7randombattle"}`);
stream.write(`>player p1 {"name":"Alice"}`);
stream.write(`>player p2 {"name":"Bob"}`);

thanks!
 

Mathy

F░U░R░R░E░T░ I░N░ B░I░O░
is a Programmeris a Forum Moderatoris a Battle Simulator Moderator
In that case, you will write to the sim using lines such as:

Code:
stream.write(`>p1 move 1`);
stream.write(`>p2 switch 2`);
However, I've provided a tutorial on how to get an interactive sim console below, which is probably closer to what you want:

1. Clone Pokemon Showdown. You can use git from your command prompt if you have it installed, GitHub Desktop, etc

2. Go inside the pokemon-showdown directory with the cd command

3. Use the command node pokemon-showdown simulate-battle. You might not see any output but the sim has started and is accepting input.

4. Start the battle. Write some lines such as
Code:
>start {"formatid":"gen9randombattle"}
>player p1 {"name":"Alice"}
>player p2 {"name":"Bob"}
to start a random battle

5. Control the battle with lines such as >p1 move 1 and >p2 switch 2
 
In that case, you will write to the sim using lines such as:

Code:
stream.write(`>p1 move 1`);
stream.write(`>p2 switch 2`);
However, I've provided a tutorial on how to get an interactive sim console below, which is probably closer to what you want:

1. Clone Pokemon Showdown. You can use git from your command prompt if you have it installed, GitHub Desktop, etc

2. Go inside the pokemon-showdown directory with the cd command

3. Use the command node pokemon-showdown simulate-battle. You might not see any output but the sim has started and is accepting input.

4. Start the battle. Write some lines such as
Code:
>start {"formatid":"gen9randombattle"}
>player p1 {"name":"Alice"}
>player p2 {"name":"Bob"}
to start a random battle

5. Control the battle with lines such as >p1 move 1 and >p2 switch 2
:psytear:Thanks a lot! :psytear:
 
In that case, you will write to the sim using lines such as:

Code:
stream.write(`>p1 move 1`);
stream.write(`>p2 switch 2`);
However, I've provided a tutorial on how to get an interactive sim console below, which is probably closer to what you want:

1. Clone Pokemon Showdown. You can use git from your command prompt if you have it installed, GitHub Desktop, etc

2. Go inside the pokemon-showdown directory with the cd command

3. Use the command node pokemon-showdown simulate-battle. You might not see any output but the sim has started and is accepting input.

4. Start the battle. Write some lines such as
Code:
>start {"formatid":"gen9randombattle"}
>player p1 {"name":"Alice"}
>player p2 {"name":"Bob"}
to start a random battle

5. Control the battle with lines such as >p1 move 1 and >p2 switch 2

:psysad:Oops, I cloned the repository to the wrong directory by mistake. Although I did successfully started and finished a game, but I have some problems trying to use python to run the game, then I removed the repository in the wrong place. But when I tried to clone it again, I was denied to clone it again.
QQ图片20230317210857.png
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top