Another fun little python project.
#Stephen Duncanson #Monte Carlo Pokemon Crystal from pyautogui import press, typewrite, hotkey, screenshot import time import random possible_keys = ['a','s','return','space','up','right','down','left'] move_counter = 0 write_file = open('mc-poke.txt','a') while True: move_counter +=1 choice = random.choice(possible_keys) press(choice) write_file.write(str(choice)+"\t"+str(time.time())+"\n") if move_counter % 1000 == 0: myScreenshot = screenshot() myScreenshot.save(str(move_counter)+'.png') #time.sleep(.5)
This code consists of an infinite loop which repeatedly chooses one of the eight possible moves possible on the gameboy hardware:
Every 1000 inputs the script will save a screenshot in order to track the progress.
There is a very good chance that this is just not possible on a human time scale. But let's try it anyway!
As in all pokemon games, we begin in our bedroom. The script begins spamming the emulator with random inputs.
After 1,000 random inputs, we have moved a net total of a couple squares...
After 10,000 random inputs, we have moved another couple squres, and are facing the other direction. One major obstacle here is that the character must recieve two consecutive directional commands, due to the fact that the first command will change our orientation, and the second will move us one square.
After 17,000 iterations (here I define an iteration as 1 randomized input) we have moved ourselves into the opposite corner. Sadly, not the one we want...
After 38,000 iterations we repeatedly examine the region map. So close. So close.
On the 40,000th iteration we have made it downstairs! Yay! It has been more than an hour of real life time however, since the CPU clockspeed is being properly emulated.
Welp. After grabbing the pokegear from mom we stumbled back upstairs... Great.
To be continued...