SameerDalal / QuantumGo_Engine

GNU Affero General Public License v3.0
0 stars 1 forks source link

Bot dies if I play from a different account #4

Closed benjaminpjones closed 3 months ago

benjaminpjones commented 3 months ago

I first thought I could log in from a different browser and play against the bot. In my mind it made sense to have QuantumBot vs. benjito instead of QuantumBot vs. QuantumBot. However, this fails with the crash:

$ python main.py -l 10
At login page Current URL: https://www.govariants.com/login
Logged in. Current URL: https://www.govariants.com/
Game created. Current URL: https://www.govariants.com/game/66bd88e2e53b8bb1ecf3e997
Simulating ...
Time taken to simulate 363 children 10 times: 6.81 seconds
Best move for engine: Action 42
Waiting for player white to make move
Simulating ...
Time taken to simulate 361 children 10 times: 7.20 seconds
Best move for engine: Action 116
Waiting for player white to make move
Traceback (most recent call last):
  File ".../QuantumGo_Engine/main.py", line 9, in <module>
    env = QuantumGame()
          ^^^^^^^^^^^^^
  File ".../QuantumGo_Engine/main.py", line 7, in __init__
    engine.run()
  File ".../QuantumGo_Engine/engine.py", line 89, in run
    parent.get_action_space().pop(board_state[-1])
KeyError: 299
SameerDalal commented 3 months ago

I first thought I could log in from a different browser and play against the bot.

You can! In the terminal, you should see this line Game created. Current URL: https://www.govariants.com/game/66be08d4e53b8bb1ecf3e999. You can copy the url and play from a browser you are logged in from.

QuantumBot vs. QuantumBot.

Currently, one Chrome window is launched and in that window only one user can login which is the QuantumBot. I can make it so that instead of launching a new window that is only logged in by QuantumBot, it launches the link in the player's default browser, so they don't have to login each time they play.

benjaminpjones commented 3 months ago

You can copy the url and play from a browser you are logged in from.

That's the thing- I do log in from a different browser. After I play my move and the bot tries to play it's move, it crashes with that stack trace

SameerDalal commented 3 months ago
File ".../QuantumGo_Engine/main.py", line 9, in <module>
env = QuantumGame()
^^^^^^^^^^^^^
File ".../QuantumGo_Engine/main.py", line 7, in __init__
engine.run()
File ".../QuantumGo_Engine/engine.py", line 89, in run
parent.get_action_space().pop(board_state[-1])

This error seems familiar. Do you have this while loop in the run function in engine.py? while board_state[-1] == best_move: I get this error when player white does not play within the 10 second time limit. I fixed this issue with the while loop; you might need to pull the code again

SameerDalal commented 3 months ago

After I play my move and the bot tries to play it's move

The bot should select player black and therefore play first. If you are playing first (as player white) that also might be the issue

SameerDalal commented 3 months ago

Found the issue! If you are playing from your own browser then the blue selection ring is updated as you play the game. However the blue selection ring is not updated in the game window that the code launches so it creates a "No player selected error"

Will have a fix soon!

benjaminpjones commented 3 months ago

Great, thanks!

SameerDalal commented 3 months ago

Fixed! Now the engine won't launch a window to play on. Instead, you click the link in the terminal which opens on your browser where you should already be logged into your account.