/Hex-Fusekipedia

Python app about the hex board game

Primary LanguagePythonApache License 2.0Apache-2.0

Hex Fusekipedia

Overview

Hex is a strategy board game for two players invented independently by a Danish mathematician Piet Hein and a Nobel laureate John Nash. In spite of having very simple rules, the game has deep strategy, sharp tactics and a profound mathematical underpinning related to the Brouwer fixed point theorem.

Rules of the game are straightforward - players alternate placing pieces on unoccupied spaces in an attempt to link opposite sides of the board in an unbroken chain. One player must win; there are no draws.

Surprisingly, apart from a few rules of thumb, there is very little information about how the game should be played. The project Hex Fusekipedia aims to at least partially fill the gap of human unawareness in this matter. This simple application written in Python collects games from all championship tournaments played on Little Golem server which gathers top hex players. Based on these pieces of data, the application shows a variety of opening moves with their follow-ups played by the best players. Additional information (e.g., concerning the win ratio for a particular move) is also provided. Everything is wrapped in an user-friendly GUI (made with tkinter package).

Features

  • Browse opening moves for every board size (11x11, 13x13, and 19x19), choosing from championship or individual players' games
  • See frequency of a particular move, its win ratio and follow-up moves
  • Review games based on the chosen opening sequence
  • Download your own (or any player's) games and get surprised by always(or never)-win-moves
  • The non-static database - at any time with just a few clicks update the game collection

Usage

Simply download the two listed files (Python script and SQLite database), place them in the same directory and run the script with Python 3.x. In order to be able to download new games, one has to install the bs4 package - for details refer to https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup. Note that wihtout this library one can still use the app with all its functionalities except for the one above-mentioned. The application itself should be intuitive but additionally there is a help section in the "Info" --> "About Hex Fusekipedia" menu.

Details

  • The application has been made in Python 3.5 with the use of standard libraries and one additional package for pulling data (games) out of the HTML files (LG website) - bs4 (Beautiful Soup). This module should be installed by the user in order to fully enjoy all the functionalities of the application. Generally, check whether following packages are installed and can be imported in your Python 3.x (the application should run with any Python 3, however, not all the versions has been tested): time, urllib, re, sqlite3, webbrowser, bs4, tkinter.

  • The application has not (but probably should) been written in the model–view–controller pattern what resulted in a bit messy code because of which the author feels sorry for a potential code explorer.

Contributing

This is my first project so contributions are even more than welcome!

Additional information

About the game:

About the tkinter package:

Screenshots

sc1

sc2

sc3

sc4

sc5

Further work

The project is considered to be (successfully) completed and is not about to be further developed - at least by the author. However, naturally, there are areas in which the application could be enhanced:

  • "free play mode", i.e., a mode which would allow a user to make own moves (for example, in case he or she was curious about a possible alternate sequence and would like to check it on their own) with a possibility to get back to the actual position;

  • easier (previous) move browsing - e.g., with a slider;

  • rewriting the application in the model–view–controller pattern - probably would be nicer to read, control and modify;

  • rewriting the application in a web technology so that it could be uploaded on a web page and thus made available to a wider audience.

Anyone willing to take up any of abovementioned tasks is warmly encouraged to do so! (And of course to contact me for any advice).

License

See the LICENSE file for license rights and limitations.