Introduction
Recently, I was skyping with a bunch of friends and we got bored and had nothing to do, so we "invented" a "game" (some people in the comments pointed out that this game is playable online and very popular, so we definetely didn't invent it, although I hadn't seen it before). The reason I put the word "game" in quotation marks is because it's not an actual computer game, but it's played on Wikipedia.
It's really easy to play: Someone chooses some Wikipedia article as the goal. Let's assume Code Golf for this example. All the players then have to start from a random article (by pressing Random Article in the sidebar or going to this URL) and have to get to the "goal" as quick as possible using only linked articles of the article you are currently at. Rules include:
- The search function is not allowed (obviously)
- You may only click links in the article's main text (specifically all text inside
<div id="bodyContent">
) - If your random page or any other page you encounter has no valid links (dead links, loops, etc) or no links at all you may roll again.
The challenge
Here's where you come in: unfortunately I'm pretty bad at this game, but I'm also a dirty cheater. So I want you to implement this bot for me. I'm also a programmer, so naturally my hard disk is full of stuff like code, libraries and such and I only have a few bytes of memory to spare. Therefore this challenge is Code Golf, the answer with the least bytes wins.
Implementation Details:
- Of course you don't have to implement an intelligent bot that knows connections between topics and automatically detects the optimal route. Brute forcing is more than enough for the purpose of this challenge
- In the actual game, time counts. Your program shouldn't take longer than 1 hour to find the article (this is to avoid loopholes like random searchers that will "eventually" find the goal)
- If no path to the goal can be found (e.g. dead links or a loop) you can choose what to do from the list below:
- Quit (score remains the same)
- Get another random article and try again and do nothing on loops (score -= 10)
- Get another random article on a dead link or a loop (detect loops automatically) (score -= 50)
- (By "score" I mean your byte count here)
- Another 20 bonus bytes will be subtracted if you "trace" the route, so you print the title of every individual page you visit.
- Standard network libraries may be used (to avoid loopholes like "I crafted my own network library which crawls wikipedia articles")
- The only thing network-related your program should do is send a HTTP request to download a wikipedia page
- If your program finds the page, it should quit, but somehow signalize that it finished (printing the character "f" or the title of the page is enough)
- Standard loopholes are to be avoided
Have fun golfing!
(This is my first question here, so please point out obvious loopholes and caveats in the comments before exploiting them - thanks :D)