Sharing a Pure-Python Reimplementation of the CaptchaSolve Environments

#2
by huzpsb - opened

Thank you for open-sourcing the dataset at https://huggingface.co/datasets/Capycap-AI/CaptchaSolve30k! I tried using it for some RL-related research, and I ran into a small issue that I thought might be worth sharing.

I noticed that the README at https://huggingface.co/spaces/Capycap-AI/CaptchaSolve-Demo/blob/main/README.md has license: mit in its front matter. However, the actual game logic is packaged in game.wasm (https://huggingface.co/spaces/Capycap-AI/CaptchaSolve-Demo/blob/main/game.wasm), which is a nearly 2 MB WASM binary. From a Python-based research workflow, getting that running can be a bit of a nightmare.

After spending a few weeks on it, and with some help from DayBreak, I managed to rewrite the simulation environments for all three games in Python:

https://github.com/huzpsb/capy_cap_py

For example:

from capycap import GameSession

env = GameSession('thread-the-needle', puzzle_seed=3157) 
for x, y, is_down in trajectory:      # 240 Hz pointer ticks
    env.step(x, y, is_down)
    if env.is_solved():
        break

I tried to keep the reimplementation clean and self-contained rather than highly optimized. The good news is that it does not require a WASM runtime or pygame. The bad news is that, performance-wise, it is... not exactly impressive.

Anyway, I hope this can be useful to others in the community who have similar use cases, especially for RL and other Python-based research.

Thanks again for open-sourcing the code and dataset!

CAPYCAP INC. org

Hello! Thank you for your contribution! Yes, now that I think about it, it might have been a little shortsighted of me to package the games in WASM, haha. These were originally meant to be captchas, and I wanted at least some level of security without bothering with obfuscation. But now that they're not in use anymore, I'm glad someone was able to recreate them in python. :)

I'd love to credit you in the card and link your code, if you're ok with it!

Sign up or log in to comment