Skip to content

Python utilities to play the Wikipedia Random Article Game

License

Notifications You must be signed in to change notification settings

oxcompsoc/wikigame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wikipedia game

The aim of the Wikipedia game is to click the random article button and then click on as few links as possible try to get to another designated Wikipedia article. In this game our goal is to write bots to get to the page for frogs.

This repository contains some Python code to get started with the challenge, along with an example that uses the 'Philosophy' strategy: if you keep clicking the first link of an article you eventually get to Philosophy, and from there we can get to the frog using a known path.

Python 3 is required, so you may need to run python3 instead of python if you have both installed.

To get started, download a local copy of this repository (either via cloning, forking, or downloading the zip file) and checking it works with python3 philosophy.py. Alternatively you can use the Python IDE IDLE by opening philosophy.py and running it.

Initial ideas

  • Find a shorter route from Philosophy to Frogs
  • Come up with a better strategy for handling the "Dead End" case

Functions

import wikigame
# Gets the title of a random article
rnd = wikigame.random_article()
# Gets a list of all the links on that page
links = wikigame.links_in_order(rnd)

print(rnd)
for link in links:
    print(" - " + link)

When I run this using python3:

Bhujabalapatnam
 - Village
 - India
 - States and territories of India
...

Caching

To reduce the number of requests to Wikipedia, a set of links for each page are also cached in a sub-folder called 'cache', so you will find that after running a strategy a few times it will run reasonably quickly.

About

Python utilities to play the Wikipedia Random Article Game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages