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) ⚠️

You might also like...
 Pendulum Simulation using Pygame
Pendulum Simulation using Pygame

Pendulum project, built using pygame and math modules.

OpenGL experiments with Pygame & ModernGL
OpenGL experiments with Pygame & ModernGL

pygame-opengl OpenGL experiments with Pygame & ModernGL TODO Skybox & Reflections Post-process effects (motion blur, color correction, etc..) Normal m

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

A Street Fighter game in Pygame
A Street Fighter game in Pygame

What is Street Fighter? Street Fighter, commonly abbreviated as SF or スト, is a Japanese competitive fighting video game franchise developed and publis

Simple car game written in PyGame

Welcome to CarGame 👋 Car Game written in PyGame! NOTE: This is still new and there may be stuff broken... 🏠 Homepage Install install pygame by typin

A Pygame application which generates mazes using randomized DFS (Depth-First-Search)
A Pygame application which generates mazes using randomized DFS (Depth-First-Search)

Maze-Generator-with-Randomized-DFS A Pygame application which generates mazes using randomized DFS (Depth-First-Search)-(Iterative implementation). Ra

FlappyBird game with python and pygame

FlappyBird game with python and pygame

An interactive pygame implementation of Conway's Game of Life
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.

A Gomoku game GUI using pygame where the user can choose to play against another player or an AI using minimax with alpha-beta pruning

Gomoku A GUI based Gomoku game using pygame where the user can choose to play against another player or an AI using minimax with alpha-beta pruning. R

Comments
  • Add table of contents to readme

    Add table of contents to readme

    :unicorn: Problem

    README.md is a hundred lines long with many pictures. Such a game is better explained this way, but browsing such a file is cumbersome: you have to scrool all the way down fo find installation notes.

    :robot: Solution

    Add a table of contents, eg with an oneline tool. You may also give a try to GH native feature in the repository setting.

    image

    opened by GradedJestRisk 0
  • Lint code

    Lint code

    :unicorn: Problem

    Some bugs can be easily found with code linting

    :robot: Solution

    Trigger lint in GH's CI

    :rainbow: Remarks

    You may have to activate actions and add a security rule to block merge if the action failed, as in the working example here

    image

    opened by GradedJestRisk 0
Owner
Main: Python3 Also: HTML/CSS/JS and C#
null
Un semplice Snake game , come negli anni 90!

Project-SnakeGame Un semplice Snake game , come negli anni 90! ITA VI porto un semplice giochino per i nostalgini degli anni 90 , ispirato al vecchio

Matt K Lawrence 1 Oct 17, 2021
Made to help you create UI using pygame in python, gonna add way more to this project

Pygame visualizer Made to help you create UI using pygame in python, gonna add way more to this project. As of now, this is only hours worth of work.

Ayza 2 Feb 8, 2022
A module for use with Pygame. Includes fully customisable buttons, textboxes, sliders and many more, as well as the ability to create and run animations on these widgets.

Pygame Widgets A helper module for common widgets that may be required in developing applications with Pygame. It supports fully customisable buttons,

null 37 Jan 2, 2023
Playing memory game is fun and the more harder it is the more challenging it is.

Playing memory game is fun and the more harder it is the more challenging it is. Playing thi sgame make us stress free and also happy. So, I have decided to make a memory Game which people can play while doing work. To pass your time and to be little happy, play this wonderful memory game - **JACKPOT** while doing your work and sitting in front of your computer.

Shreejan Dolai 3 Nov 11, 2022
A Pygame game made in 48 hours

Flappuccino Flappuccino is a game created in 48 hours for the PyGame Community New Years Jam using Python with Pygame. Screenshots Background Informat

PolyMars 242 Jan 2, 2023
Quiz game made entirely with python and pygame for school work

Tabela de conteúdo Descrição Como instalar Linguagens usadas Contribuidores Créditos Problemas com o jogo? Contate-nos Descrição Quiz feito inteiramen

null 3 Apr 12, 2022
This is a simple game made using pygame.

Ball breaker This is a simple game made using pygame game view The game view have been updated wait for the new view to be uploaded Game_show.mp4 Lear

Rishikesh Kumar 3 Nov 5, 2021
A simple matrix code rain created using Python with Pygame.

Matrix4_code_rain A simple matrix code rain created using Python with Pygame. To run the code you will need Pygame and MS Mincho font. Create a projec

null 7 Nov 6, 2022
null 3 Oct 22, 2021
This is an amazing game make using pygame.

This is an awesome balloon game. It is made in python using Pygame library. It is a project game while learning game development.

Rishikesh Kumar 2 Oct 10, 2021