Recreation of HexGame in Pygame. More features will come soon !

Overview

Hex with Pygame

Whats is Hex ?

Historical point of view


Hex as been created in 1942 by a Danish mathematician named Piet Hein. The first commercialization of this game is in 1952. With time, some strategies to win have been seeking. Thus, techniques have been found to consistently win on a 7x7 and 9x9 Board. More recently, in 2019, Facebook succeeds in beating the best player of Hex on a 19x19 board.

What Are the rules of this game ?


First, Hex is a two player game. It's a strategic and abstract board game. Each players have a color, black and white. The cells of the board are made up of hexagons. Hence the name "Hex".The goal for each player is to form a connected path of their stones linking the opposing sides of the board marked by their colors before their opponent similarly connects his or her sides.

Illustration from the Game

In this example, white won because they form a line that is linking the opposite white side. Traditionally, board measure 9x9, 11x11, 13x13 or 17x17.

Some Strategies and tips


Easy and Faster connections

Usually, beginners place their pawns directly next to them to create a connection. But there is a faster way to proceed. If you have 2 pawns that have 2 hexagons in common (1), they can be connected, even if black put a Hexagon in one of them (2) > (3). Example:

Stopping a pawn

Imagine playing black and being in this situation:


How can you stop white ? First play a pawn in front of white's pawn.


Now white is obligate to play at the left if they want to win.


Now that you are in this position you must put white in a situation where they must play near your pion, by playing like that:


Now white as no option:


Last be not the least, play a pawn like the first time


And that's it ! You blocked them.

The program

The algorithm for the Win


How can the algorithm detect if a player has won ?

Step 1:

If there is a pawn on the first line, it would be marked as "solution pawn". If there is no pawn on this line, then, the player can't win

Step 2:

All pawns connected to a solution Pawn becomes Solution pawn. But when a Solution Pawn makes a non-solution pawn to become a solution, then this pawn becomes "past". A past pawn can't be a solution pawn anymore.

Step 3:

If a solution pawn is on the last line, the player won.



This algorithm can be similar to Mathematical induction ("Raisonnement par Récurrence" in French) in Maths

Other fonctionnalities


Color

You can customize the main color of this game. Just by pressing a button

Languages

Many languages are available. (French 🇫🇷 , English 🇺🇸 , Japan 🇯🇵 , Korean 🇰🇷 , Greek 🇬🇷 and Sweden 🇸🇪 )

Sound/Music

There is an default music made by the author. The volume of the music can be modified from 0.0% to 100.0%

Lenght of the Board

The Lenght of the board can go from 5x5 to 50x50


How to install Python and Pygame ?

Install Python

If Python is not installed on your computer (to verify that, you can do: "python --version" on a Terminal. If you don't know how to access a Terminal you can click here : How to access a Terminal) you can click on this link Installing Python, than click on "Download Python 3.X.X". After that, you can execute this File. A window should appear. At the bottom of the screen, there is a small box where it's written: "Add Python3.X to path". Check this box. After that, click on "Customize Installation". Check all the boxes if they aren't checked and click on "Next". Then, click on "Install". After that, you can close the window

Install Pygame

If you want to check if Python is installed you can open a Terminal and write python --version. Installing Pygame is not difficult. Now you need to open a Terminal if there is none open. And just type py -m pip install pygame. It will take some time for being installed.

Install Hex Game

To install Hex Game you need to download this project as a .zip, then you have to decompress it. After the installation and the decompression, you have to execute it by doing py main.py
⚠️ Make sure that you are in the good Folder when you do that. For example, if the file is on your Desktop you should do cd Desktop. You don't understand what I just said? Path of a file in Windows / Mac. How to use CD: Here (It's the same with Mac) ⚠️

Owner
Main: Python3 Also: HTML/CSS/JS and C#
Code d'un jeu en python par Graveen (avec mes modifications)

ATTENTION Vous ne devez pas copier coller le code sans le comprendre, apprennez déjà, le python et pygame, et seulement ensuite, vous pourrrez l'utili

TheBigWolfy 7 Nov 02, 2022
🐍 Conway's Game of Life cellular automaton implemented in PyGame

Conway's Game of Life My PyGame implementation of Conway's Game of Life. This implementation involves treating all edges of the grid as stitched toget

Mateusz Żebrak 1 May 29, 2022
source codes for my(small indie game developer) games

My repository for most of my finished && unfinished games Table of Contents Getting Started Prerequisites Installation Usage License Contact Prerequis

Gustavs Jākobsons 1 Jan 30, 2022
ReplitTD - Replit Tower Defense Game

IMPORTANT: I mean no offense at all in this game, this is only based off of cycl

kokomi simp :3 3 Jun 25, 2022
Datamining of 15 Days of (free) Games at the Epic Games Store (EGS).

EGS: 15 Days of Games This repository contains Python code to data-mine the 15 Days of (free) Games at the Epic Games Store (EGS). Requirements Instal

Wok 9 Dec 27, 2022
Automatically prepare your Minecraft maps for release

map-prepare Automatically prepare Mineraft map for release. Current state: kinda works Make sure you have backups for your world before running this p

11 Oct 11, 2022
A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3

A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3. Requires the installation of PIL/Pillow and Requests

1 Dec 24, 2021
An interactive pygame implementation of Conway's Game of Life

Game of Life An interactive pygame implementation of Conway's Game of Life Installation Clone the repo and navigate into it. git clone https://github.

Ethan 1 Dec 05, 2021
A popular children's game developed in Python.

Pedra Papel e Tesoura Um dos jogos mais populares da infância... 🪨 📜 ✂️ 💻 Situação do projeto: Projeto finalizado ✔️ 🛠 Tecnologias: Python Tkinter

Arthur V.B.S. 2 Dec 05, 2022
A Pygame Hangman Game coded in Python 3. Run Hangman.py in a terminal if you have Python 3

Hangman A Pygame Hangman Game coded in Python 3. Run python3 Hangman.py in a terminal if you have Python 3.

1 Dec 24, 2022
Python game engine for 2D multiplayer online games.

LAN-Caster The goal of LAN-Caster is to provide an easy-to-use code base (game engine) for developing 2D multiplayer online games. LAN-Caster original

Douglas Bakewell 1 Feb 11, 2022
A pygame implementation of John Conway's Game of Life

Game of Life A Pygame Simulation This is a Pygame implementation of the famous Conway's Game of Life. The game features a set of very simple rules: An

1 Jan 06, 2022
Tic Tac Toe Game build with Python

Tic Tac Toe Game Description two players who take turns marking the spaces in a three-by-three grid with X or O. The player who succeeds in placing th

Kemal Kochekov 2 Jan 21, 2022
A short non 100% Accurate Solar System in pygame

solar-system-pygame Controls UP/DOWN for Emulation Speed Control ESC for Pause/Unpause q to Quit c or ESC again to Continue LEFT CLICK to Add an orbit

LightCrimson 2 May 28, 2022
Minecraft - Online Players Overlay Generator

Minecraft - Online Players Overlay Generator Contents About Quick Start Download Pre-Built Binary Run from Source Configuration Command-Line Options F

4 Sep 12, 2022
A puzzle game coded entirely in Python.

Pyzzle A puzzle game coded entirely in Python. This is a school project created by me, Mohit Singh. The .exe file, created from the main.py script, is

Mohit Singh 1 Mar 19, 2022
A script to install a Windows game through GOG on Linux

proton-gog-install A script to install a Windows game through GOG on Linux. Based on this gist. Tested on Arch, might work elsewhere. Requirements: Im

5 Dec 28, 2022
A quantum version of Ladders and Snakes

QPath-and-Snakes A quantum version of Ladders and Snakes Desarrollo Para continuar el desarrollo sin pensar en instalación de dependencias: Descargue

2 Oct 22, 2021
Minecraft Script to Tellraw Datapack Generator

Minecraft Script to Tellraw Datapack Geneator (STDG) can generate a chain of tellraw command in datapack from script.

1 Jan 28, 2022
2d war game single player

WarGame-third-version-0.0.4- 2d war game single player Hi ! Today, I publish on GitHub the version 0.0.4 of "WarGame". In this version, you can find a

Edouard Vincent 2 Apr 08, 2022