Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential RandomPlayerAI bug in simulator #10542

Open
cyi1341 opened this issue Sep 11, 2024 · 0 comments
Open

Potential RandomPlayerAI bug in simulator #10542

cyi1341 opened this issue Sep 11, 2024 · 0 comments

Comments

@cyi1341
Copy link

cyi1341 commented Sep 11, 2024

There is a bug in the battle-stream-example.ts located in ./sim/examples/, when running node build && node .sim-dist/examples/battle-stream-example inside the root directory after running git clone https://github.com/smogon/pokemon-showdown. It returned the following error:

node:internal/modules/cjs/loader:1137            
  throw err;                                     
  ^                                              
                                                 
Error: Cannot find module '/home/cyi/pokemon-show
down/.sim-dist/examples/battle-stream-example'   
    at Module._resolveFilename (node:internal/mod
ules/cjs/loader:1134:15)                         
    at Module._load (node:internal/modules/cjs/loader:975:27)                                     
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)        
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',                      
  requireStack: []                               
}                                                
                                                 
Node.js v18.19.0  

It appears the .sim-dist directory does not exist, so I went and nuked the repo locally, and git clone again, then based on the latest commit that modifies battle-stream-example, it has the SHA256 checksum of 13189fd, so I did git checkout 13189fdb02778f4c99cfe81da9ee82978485f48a inside the repo and did the same node build && .sim-dist/examples/battle-stream-example and this time, it works, and produces the expected output of the battle stream of a random battle using RandomPlayerAI from ./sim/tools/random-player-ai

Looks good and all, but this is for printing the omniscient stream, originally it looks like this:

void (async () => {
        for await (const chunk of streams.omniscient) {
                console.log(chunk);
        }
})();

There's a p1 and p2 stream, we can modify the program by changing omniscient to p1 or p2, then run node build again.

Results of p1:

p1 is RandomPlayerAI
p2 is RandomPlayerAI

For some reason the stream of p1 is non-existent, maybe this is how the class handles the streams?

Results of p2:

p1 is RandomPlayerAI                                                                       
p2 is RandomPlayerAI                                                                       
|t:|1726063393                                                                             
|gametype|singles                                                                          
|player|p1|Bot 1||                                                                         
|player|p2|Bot 2||                                                                         
|teamsize|p1|6                                                                             
|teamsize|p2|6                                                                             
|gen|7                                                                                     
|tier|[Gen 7] Custom Game                                                                  
|clearpoke                                                                                 
…

This looks normal, but if you try node .sim-dist/examples/battle-stream-example | grep "|request", it returns nothing, and if you try node .sim-dist/examples/battle-stream-example | grep "|faint", it would return something like below:

|faint|p2a: Volcanion
|faint|p1a: Araquanid
|faint|p2a: Ambipom
|faint|p1a: Palossand
|faint|p1a: Altaria
|faint|p2a: Pelipper
|faint|p2a: Raichu
|faint|p1a: Raichu
|faint|p1a: Zekrom

So tldr:

  1. The command to run the only example in sim does not work as it does not produce .sim-dist
  2. Even when going back to the state where it works, it does not work consistently, specifically with the handling of p1 and p2

In latest commit, after node build, running tsc sim/example/battle-stream-example.ts it returns the error:

error TS6053: File 'sim/example/battle-stream-example.ts' not found.
  The file is in the program because:
    Root file specified for compilation


Found 1 error.

And running node sim/example/battle-stream-example.js after tsc returns the following error:

node:internal/modules/cjs/loader:1137
  throw err;
  ^

Error: Cannot find module '/home/cyi/pokemon-showdown/sim/../config/formats'
Require stack:
- /home/cyi/pokemon-showdown/sim/dex-formats.js
- /home/cyi/pokemon-showdown/sim/dex.js
- /home/cyi/pokemon-showdown/sim/battle.js
- /home/cyi/pokemon-showdown/sim/index.js
- /home/cyi/pokemon-showdown/sim/examples/battle-stream-example.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at DexFormats.load (/home/cyi/pokemon-showdown/sim/dex-formats.js:437:23)
    at ModdedDex.includeFormats (/home/cyi/pokemon-showdown/sim/dex.js:524:22)
    at ModdedDex.loadData (/home/cyi/pokemon-showdown/sim/dex.js:463:18)
    at ModdedDex.get (/home/cyi/pokemon-showdown/sim/dex.js:121:25)
    at DexFormats.get (/home/cyi/pokemon-showdown/sim/dex-formats.js:523:22)
    at exports.Teams.Teams.getGenerator (/home/cyi/pokemon-showdown/sim/teams.js:549:36) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/cyi/pokemon-showdown/sim/dex-formats.js',
    '/home/cyi/pokemon-showdown/sim/dex.js',
    '/home/cyi/pokemon-showdown/sim/battle.js',
    '/home/cyi/pokemon-showdown/sim/index.js',
    '/home/cyi/pokemon-showdown/sim/examples/battle-stream-example.js'
  ]
}

Node.js v18.19.0

So question: is this a bug in RandomPlayerAI that should be fixed, or is such result somehow working as expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant