# Wikiracer Game This GitHub project showcases my proficiency in Python data structures and algorithms by implementing a captivating Wikiracer game which is a challenge to find the most efficient path to traverse between a Wikipedia page to another. The game is built using various algorithms traversing the WikiPedia graph data structure, including Breadth-First Search (BFS), Depth-First Search (DFS), and Dijkstra's algorithm. Additionally, it includes an HTML parsing code that does not rely on external libraries like BeautifulSoup. **Please note that the code in this repository is intended for demonstration purposes only and should not be used for any other purpose.** ## Table of Contents - [Features](#features) - [Usage](#usage) - [Licensing and Contributing](#licensing-and-contributing) ## Features - BFS, DFS, and Dijkstra's algorithm: The game employs these algorithms to find the shortest path between two Wikipedia articles efficiently. Each algorithm is implemented using Python's data structures, ensuring optimal performance. - Custom HTML parsing: Instead of relying on external libraries like Beautiful Soup, the project includes a custom HTML parsing code. It leverages Python's built-in string manipulation and regular expression capabilities to extract relevant information from the Wikipedia article content. - Interactive gameplay: The game provides a user-friendly command-line interface (CLI) that allows players to input their starting and target articles. It then calculates and displays the shortest path, along with the number of clicks required to navigate from the start to the target article. - Wikipedia API integration: The project integrates the Wikipedia API to fetch article content and retrieve hyperlinks for a given article. This ensures that the game remains up-to-date with the latest information available on Wikipedia. - Extensible and modular design: The codebase is designed with modularity in mind, allowing for easy extension and customization. New algorithms or enhancements can be seamlessly added to improve gameplay or optimize the path-finding process. - Documentation and code comments: The project includes comprehensive documentation, guiding developers and potential employers through the codebase. Additionally, detailed comments within the source code explain the purpose and functionality of each component. ## Usage Once installed, you can use the following import statements to start instantiating BFS, DFS or Dijkstra's objects ```python import random import sys from typing import Callable, Iterator from itertools import chain from collections import defaultdict from types import ModuleType from importlib import reload from urllib.request import urlopen ``` A sample script to find the most efficient path between `/wiki/Reese_Witherspoon` and `/wiki/Academy_Awards` using BFS, DFS and Dijkstra's algorithms is shown below ```python bfs = BFSProblem() dfs = DFSProblem() dij = DijkstrasProblem() assert bfs.bfs(source = "/wiki/Reese_Witherspoon", goal = "/wiki/Academy_Awards") == ["/wiki/Reese_Witherspoon", "/wiki/Academy_Awards"] assert dfs.dfs(source = "/wiki/Reese_Witherspoon", goal = "/wiki/Academy_Awards") == ["/wiki/Reese_Witherspoon", "/wiki/Academy_Awards"] assert dij.dijkstras(source = "/wiki/Reese_Witherspoon", goal = "/wiki/Academy_Awards") == ["/wiki/Reese_Witherspoon", "/wiki/Academy_Awards"] ``` ## Licensing and Contributing Please note that the code in this repository is provided solely for demonstration purposes and should not be used for any other purpose. If you encounter any issues or bugs during your exploration of the repository, please open an issue, and I'll do my best to address it.