Giter VIP home page Giter VIP logo

gomoku's Introduction

GOMOKU

By @ayguillo and @HkhanH

This project is a drawing school project

Constraints

AI that can win over a human at gomoku under 0.5 second per move with minimax algorithm

Installation

You need the golang version 1.16.6 or less and to install go-sdl2 depending your OS : install go-sdl2.

After this install you can execute

go mod init gomoku
go mod tidy
go build

Rules

Win

You must align 5 stones to win.

Captures - As in the Ninuki-renju or Pente variants - (option)

You can remove a pair of your opponent’s stones from the board by flanking them with your own stones.

This rule adds a win condition : If you manage to capture ten of your opponent’s stones, you win the game.

drawing

Note : One can only capture PAIRS, not single stones, and not more than 2 stones in a row.

Game-ending capture

A player that manages to align five stones only wins if the opponent can not break this alignment by capturing a pair, or if he has already lost four pairs and the opponent can capture one more, therefore winning by capture.

drawing

No double-three (option)

It is forbidden to play a move that introduces two free-three alignments, which would guarantee a win beny alignment.

drawing

Algorithm explanation

We used minimax algorithm with alphabeta prunning. To achieve a move under 0.5 second, we limited the exploration at 5 depth in default settings.

Alpha beta prunning

Alpha-beta pruning reduces the number of nodes that are evaluated by the minimax algorithm in its search tree.

We keep track of two values: Alpha and Beta.

  • Alpha = the minimum score that the player is assured of.
  • Beta = the maximum score that the opponent is assured of. Initially, alpha is negative infinity and beta is positive infinity.

It stops evaluating a move when at least one possibility has been found that proves the move to be worse than a previously examined move.

FindNeighbors()

During the search, we don't evaluate all the Goban but only the neighbors to limited the tree search.

drawing

Interface

The interface is very simply, and developed with sdl2.

In the menu, you can set all the rules, and disable/enable the captures, and no double-three rule.

You can also play against a bot, or an another player. We have developed an helper who can suggest a move, but warning, it's not the best move ! This option can be disable.

Feel free to use the "thinking time" option. The algorithm will have more time to process and search the best move in the tree search.

drawing

Now can you win against the AI ?

party

gomoku's People

Contributors

ayguillo avatar hkhanh avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.