scaljeri / chess.com

A chess bot for chess.com
64 stars 39 forks source link

Chrome closing instantly #24

Closed cristiansori2 closed 2 years ago

cristiansori2 commented 3 years ago

The bot starts fine, open Chrome and start a match, but 10 seconds later it closes automatically.Im using macOS Big Sur.

scaljeri commented 3 years ago

Do you see any errors in the terminal?

cristiansori2 commented 3 years ago

Do you see any errors in the terminal?

No,0 errors in terminal.

cristiansori2 commented 3 years ago

Do you see any errors in the terminal?

Do you see any errors in the terminal?

Btw im using the code that is 5 months old,maybe its a problem with html tags?

scaljeri commented 3 years ago

I just noticed the project had build issues, which I fixed. On my mac the bot is playing fine now. Are you running the bot with lerna start:bot,that command doesn't output much, so if you go to packages/bot and run yarn build and yarn start you might get more feedback from the terminal

What exactly do you mean with "html tags"?

juntangnj commented 2 years ago

I had the same issue as christionsori2 had and I got the following exceptions: [1] Setting up controller FileController [1] Setting up controller StockfishController [1] up and running [1] [2021-11-20T23:42:29.574Z]: Example server started on port: 3000 [1] Ready [1] [1] [1] [1] /Users/juntang/chess.com/node_modules/puppeteer/lib/helper.js:270 [1] throw new Error(message); [1] ^ [1] Error: No node found for selector: .icon-font-chess.modal-seo-close-icon [1] at assert (/Users/juntang/chess.com/node_modules/puppeteer/lib/helper.js:270:11) [1] at DOMWorld.click (/Users/juntang/chess.com/node_modules/puppeteer/lib/DOMWorld.js:366:5) [1] at processTicksAndRejections (node:internal/process/task_queues:96:5) [1] -- ASYNC -- [1] at Frame. (/Users/juntang/chess.com/node_modules/puppeteer/lib/helper.js:111:15) [1] at Page.click (/Users/juntang/chess.com/node_modules/puppeteer/lib/Page.js:1031:29) [1] at Client. (/Users/juntang/chess.com/packages/bot/src/backend/client.ts:79:21) [1] at Generator.next () [1] at /Users/juntang/chess.com/node_modules/tslib/tslib.js:110:75 [1] at new Promise () [1] at Object.__awaiter (/Users/juntang/chess.com/node_modules/tslib/tslib.js:106:16) [1] at Client.click (/Users/juntang/chess.com/packages/bot/src/backend/client.ts:65:24) [1] at ComputerNavigation. (/Users/juntang/chess.com/packages/bot/src/backend/context/computer/navigation.ts:13:21) [1] at Generator.next () [1]

juntangnj commented 2 years ago

I am using macOS Monterey

scaljeri commented 2 years ago

Did it work before?

juntangnj commented 2 years ago

It's the first time I am trying it out. If I don't choose the player and wait till it get to show the "Play" button, it will get into a game without quitting. However, it will never make a move.-:)

scaljeri commented 2 years ago

Ok, I have to look. Its been a while since I used this project :) I guess they changed one or more classes. Give me some time and I'll come back here!

scaljeri commented 2 years ago

I just tested this issue but couldn't reproduce. In my case the pure browser version didn't work anymore, but when I switch to the docker stockfish it played a whole game. Do you use the pure browser / webassembly stockfish?. If so, try to switch to docker stockfish

juntangnj commented 2 years ago

Yes, I use the pure browser/webassembly stockfish. When I try to build with docker stockfish, I got the following errors: ../../node_modules/webdriverio/webdriverio.d.ts(18,34): error TS2304: Cannot find name 'WrapWithPromise'.

../../node_modules/webdriverio/webdriverio.d.ts(29,34): error TS2304: Cannot find name 'WrapWithPromise'

and got the following errors when try to start it:

juntang@Juns-Mac chess.com % lerna run start info cli using local version of lerna lerna notice cli v3.13.4 lerna info versioning independent lerna info Executing command in 3 packages: "yarn run start" lerna ERR! yarn run start exited 1 in 'statistics' lerna ERR! yarn run start stdout: yarn run v1.22.15 $ rm -r ./dist && tsc && cp ./src/index.html ./dist && browserify ./dist/www/main.js -o ./dist/www/main.js && ts-node ./src/server.ts info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

lerna ERR! yarn run start stderr: rm: ./dist: No such file or directory error Command failed with exit code 1.

lerna ERR! yarn run start exited 1 in 'statistics' lerna WARN complete Waiting for 2 child processes to exit. CTRL-C to exit immediately.

scaljeri commented 2 years ago

Maybe you can try it without lerna. If you cd into packages/engines and run the following command:

$> yarn build
$> yarn run:sf

does it start a docker container?

juntangnj commented 2 years ago

I tried to run the command as you suggested and the following is the output. I felt something is missing in my packages such as the file webdriverio.d.ts:

juntang@Juns-Mac engines % yarn build yarn run v1.22.15 $ rm -rf ./dist && tsc -p tsconfig.build.json ✨ Done in 3.93s. juntang@Juns-Mac engines % yarn run:sf yarn run v1.22.15 $ CHESS_ENGINE=fs node ./dist/src/websockets/main.js [Nest] 1279 - 12/06/2021, 6:45 AM [NestFactory] Starting Nest application... Chess engine is: Stockfish [Nest] 1279 - 12/06/2021, 6:45 AM [InstanceLoader] ApplicationModule dependencies initialized +34ms [Nest] 1279 - 12/06/2021, 6:45 AM [InstanceLoader] EventsModule dependencies initialized +1ms [Nest] 1279 - 12/06/2021, 6:45 AM [NestApplication] Nest application successfully started +146ms node:events:368 throw er; // Unhandled 'error' event ^

Error: spawn docker ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -2, code: 'ENOENT', syscall: 'spawn docker', path: 'docker', spawnargs: [ 'run', '--rm', '--interactive', '--cpus=1', 'jeanluca/stockfish:latest' ] } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

juntangnj commented 2 years ago

After I install webdriverio package and rerun the bootstrap, lerna run build is giving some errors:

juntang@Juns-Mac chess.com % lerna run build info cli using local version of lerna lerna notice cli v4.0.0 lerna info versioning independent lerna info Executing command in 3 packages: "yarn run build" lerna ERR! yarn run build exited 2 in '@scaljeri/chess-shared' lerna ERR! yarn run build stdout: yarn run v1.22.15 $ rm -rf ./dist && tsc src/backend/context.ts(5,13): error TS2559: Type '"shared-context"' has no properties in common with type 'Partial'. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. lerna ERR! yarn run build stderr: error Command failed with exit code 2. lerna ERR! yarn run build exited 2 in '@scaljeri/chess-shared'

scaljeri commented 2 years ago

Is docker running? It seems it cannot start the docker image

juntangnj commented 2 years ago

How do I start the Docker? I re-download the code and run the webassebly stockfish is working now except I have to make the move. I thought it could play automatically.

scaljeri commented 2 years ago

For docker you need to install docker desktop. Then, if it is up and running you can simply do yarn run:sf inside that engines directory and start the bot. Also, the web-assembly version wasn't working anymore for me too. I guess the packages is updated or something, so right now, you have to use that docker engine. Of course I'll fix the web-assembly some day :)

juntangnj commented 2 years ago

Installed docker desktop and run yarn run:sf inside the engine directory: juntang@Juns-Mac engines % yarn run:sf yarn run v1.22.15 $ CHESS_ENGINE=fs node ./dist/src/websockets/main.js [Nest] 1754 - 12/07/2021, 6:16 PM [NestFactory] Starting Nest application... Chess engine is: Stockfish [Nest] 1754 - 12/07/2021, 6:16 PM [InstanceLoader] ApplicationModule dependencies initialized +33ms [Nest] 1754 - 12/07/2021, 6:16 PM [InstanceLoader] EventsModule dependencies initialized +2ms [Nest] 1754 - 12/07/2021, 6:16 PM [NestApplication] Nest application successfully started +115ms sf cmd: setoption name Threads value 128 sf cmd: setoption name Ponder value true ENABLE PONDERING!!!!! true sf cmd: setoption name Move Overhead value 120 sf cmd: setoption name Contempt value 0 sf cmd: setoption name Hash value 1024 sf cmd: setoption name Slow Mover value 15

but when I start the bot with the "lerna run start" commend in the docker instruction, I still got the same error as I got earlier: juntang@Juns-Mac chess.com-master % lerna run start info cli using local version of lerna lerna notice cli v3.13.4 lerna info versioning independent lerna info Executing command in 3 packages: "yarn run start" lerna ERR! yarn run start exited 1 in 'statistics' lerna ERR! yarn run start stdout: yarn run v1.22.15 $ rm -r ./dist && tsc && cp ./src/index.html ./dist && browserify ./dist/www/main.js -o ./dist/www/main.js && ts-node ./src/server.ts info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

lerna ERR! yarn run start stderr: rm: ./dist: No such file or directory error Command failed with exit code 1.

lerna ERR! yarn run start exited 1 in 'statistics' lerna WARN complete Waiting for 2 child processes to exit. CTRL-C to exit immediately.

scaljeri commented 2 years ago

I see that the engine is up and running now, thats good. For the bot, try to start it without lerna, goto packages/bot and run yarn start . Make sure you configured the bot correctly, like this

image

juntangnj commented 2 years ago

Thanks. it works now but stops after playing 7 moves. The webassembly config stops after 1 move.

scaljeri commented 2 years ago

Is it always 7 or random. I've seen this issue too I must confess but in 9 out of 10 games it played till the end. I get the feeling there is some kind of timing issue in the chess bot. I will investigate this and fix the webassembly engine too. But at the moment I don't have anytime, so it can take some time (hopefully before the end of this year)

juntangnj commented 2 years ago

It runs 6 to 7 moves the first time after I start the program. After that, it stops at 1 move. I saw the small windows on the left-bottom corner of the browser says book:6, book:7 or book1.

scaljeri commented 2 years ago

I've made some updates (master), can you check if your errors are still there?