This project plays the Wikipedia Speedrun game automatically.
The goal: reach a target Wikipedia page from a starting page using only in-page links - no search, no URL edits, no going back, no cheating.
Two play modes:
- WikiSpeedRunner → SBERT Vector mode
- AI WikiSpeedRunner → Gemini LLM mode
Uses the SBERT model to compute word embeddings between:
every possible next-page title and the target page’s summary
It picks whichever title is semantically closest to the target.
Pros
- Very fast (no external API calls)
- Works offline after model download
Cons
- Sometimes takes more steps (longer path), even though computation is fast
Fast execution, longer routes
Uses Google Gemini to logically determine which link will lead closer to the goal using a one-line target description.
Pros
- Often picks shortest or smartest paths
- Understands concepts contextually
Cons
- Slower (each decision triggers an API call)
Short path, slower execution
You can enable or disable the visual browser from main.py:
USE_BROWSER = True # show the game visually in chromium
# or
USE_BROWSER = False # run silently (no UI)When enabled, the bot:
- scrolls to the chosen link
- highlights it in red
- clicks it like a real player
This transforms the script into a playable AI game.
git clone https://github.com/ankushhKapoor/WikiSpeedRunner.git
cd WikiSpeedRunneruv sync
playwright install chromiumpip install wikipedia-api sentence-transformers numpy python-dotenv google-genai playwright
playwright install chromiumCreate .env:
API_KEY=your_gemini_api_key_here- See
/.env.examplein the repository for reference - Not required for SBERT Vector mode
Edit settings in main.py:
START_PAGE = "Dog"
TARGET_PAGE = "Linux"
PLAYER_TYPE = "vector" # or "llm"
USE_BROWSER = True- If using LLM mode → set:
TARGET_DESC = "Linux is an open-source operating system..."- If using Vector/SBERT mode → leave
TARGET_DESCempty or ignore it
Then run:
python main.pyPLAYER_TYPE = "vector"→ WikiSpeedRunnerPLAYER_TYPE = "llm"→ AI WikiSpeedRunner
Each run is saved to history.json, including:
- path taken
- steps
- time taken
- player type used
Compare runs to see whether speed (SBERT) or efficiency (LLM) wins.
This project is inspired by a Green Code YouTube video I Forced AI to Speedrun Wikipedia demonstrating an AI solving Wikipedia speedruns.
