Open Angrones opened 2 years ago
I managed to somewhat fix the looping by defining some things (after a hard research because I barely get python), and here's what I currently have:
NUM_LOOPS = 19 # The maximum number of games we'll play. After this number, the script will quit.
n = 0
print("beginning to play the game. We'll play " + str(NUM_LOOPS) + " games.")
while n < NUM_LOOPS:
print("beginning game " + str(n) + str(1) + "...")
time.sleep(GAME_DELAY)
solve_board()
time.sleep(GAME_DELAY)
pyautogui.click(
pyautogui.center(
pyautogui.locateOnScreen(
PLAY_FILE_LOC,
confidence=CONFIDENCE_VALUE
)
)
)
print("ending game " + str(n) + str(1) + "...")
n += 1
print("Script exiting.")
For some reason, I had to add "str" to the n and 1, otherwise it wouldn't register it. That works for the looping unless someone with 10x more knowledge than me can make it more efficient. The loop counting is still a mist, it just... counts it as "Ending 01, Beginning game 11" no matter what I do to the print.
I also got this error! I'm not sure how or where @HjOtal-1 changed the code to fix it, so any help would be great!
C:\Users\Owner\Desktop\Glimmer-and-Gloom-master>python autorun.py
Traceback (most recent call last):
File "C:\Users\Owner\Desktop\Glimmer-and-Gloom-master\autorun.py", line 13, in
@opheliasrose You open the Autorun.py on Notepad or something that can open the file, then select everything after the Confidence Value line, and replace it with the new code (reference).
@HjOtal-1 The reference link you sent doesnt work? Could you send that again so people can get the bot working?
@Killua-coder EDIT: I've created a fork that not only fixes both bugs in the autorun.py, it also contains an in-depth explanation of the script's basis, the installation process, and the Confidence & PNGs.
Hey, sorry for the late response, here it is:
This is where I ask for anyone with better Python knowledge because the only reason why I managed to fix this was purely from a blindfold search about the TypeError in the title. That is supposed to tell the current game round (e.g: beginning game 01) but it instead keeps adding +10 instead of +1 (e.g: beginning game 11).
The new code allows you to control the waiting before the script clicks the play button (GAME_DELAY_2) and after it clicks play (GAME_DELAY_1). The latter is to allow the game to load first then start the script. I found it to be a major problem in the OG Autorun.py script because it used the same delay, and as result, it'd sometimes ceased to work before the play button other times it didn't let the game to load first.
I see a lot of people are having problems with the CONFIDENCE_VALUE and the errors it gives, here's my best at explaning how it works. CONFIDENCE_VALUE is how well can the script detect the Glimmer Gloom pngs that correspond to the board tiles, they systematically work together.
The higher the Confidence, the better the script can detect the pngs as the tiles.
↕
The more evenly matched the pngs are to the board tiles, the better the script can confidently detect the pngs as tiles.
If the game say... doesn't display the tiles properly and has a lot of visual bugs due to system scaling or simply because it just cannot display them correctly, and you made the pngs to highlight a chunk of the tile that's highly subjected to visual bugs, then the script will go down a domino spiral. Tiles don't match the pngs so Script can't confidently detect them as tiles and throws out an "Out of Range" if the tiles don't match, or a "NoneType object is not subscriptable" if the script thinks the Confidence is too high for the amount of uneven matches between the pngs and the tiles.
Down below is an example how I have it set up.
The same applies to the Play.png, I'm able to keep the Autorun.py's Confidence at .9 because fortunately for me, the Play button is able to keep itself consistent in spite of the system scaling. But if I increased the tile to fill the entire button, it'll throw me errors because it was capturing areas subjected to visual bugs.
If you modify the DELAY_FUZZING and balance out the GAME_DELAYs, you can get a very quick but humanely possible autorun - in my case, I have DELAY_FUZZING of .4, HOVER_FUZZING of (2, 9), CONFIDENCE_VALUE (board_solver's) of .8, GAME_DELAY_1 of 2.9 and GAME_DELAY_2 of .54. This is enough to keep a constant flow and if I go anywhere below those numbers, it will give off errors because the script isn't registering the quick changes (e.g: miss a tile, not register a tile, ect) or it will begin to go too fast.
These all highly depend on your PC's performance (my old laptop was able to run it faster than what I have now for example) so it's highly subject to change.
Here's the full coding and how it should look like. The # of Loops is already set to gather all 75k from G&G (4000*18 is 72k, +3000 is 75k, hence 19 loops).
PLAY_FILE_LOC = "play.png" # The local file location of the play button image
GAME_DELAY_1 = 2.9 # How much we wait after the game loads.
GAME_DELAY_2 = .54 # How much we wait before starting a new game.
CONFIDENCE_VALUE = .9 # The confidence value we're searching the screen with. A lower number will lead to more false positives.
NUM_LOOPS = 19 # The maximum number of games we'll play. After this number, the script will quit.
n = 0
print("beginning to play the game. We'll play " + str(NUM_LOOPS) + " games.")
while n < NUM_LOOPS:
print("beginning game " + str(n) + str(1) + "...")
solve_board()
time.sleep(GAME_DELAY_1)
pyautogui.click(
pyautogui.center(
pyautogui.locateOnScreen(
PLAY_FILE_LOC,
confidence=CONFIDENCE_VALUE
)
)
)
time.sleep(GAME_DELAY_2)
print("ending game " + str(n) + str(1) + "...")
n += 1
print("Script exiting.")
I'm glad the code now has a limit loop, though there's a slight problem with it, it gives that error instead. F