Giter Club home page Giter Club logo

gomoku-first-move-always-win's Introduction

Gomoku, first move always win AI

Inspired by https://github.com/davda54/pn-search: C++ implementation of proof-number and dependency-based search for gomoku by Louis Victor Allis (1994)

Win rule: five or more stones in a line win

Try it

video demo: https://www.bilibili.com/video/BV1Sf4y1i7df

try it online: http://www.bytedance.ai/gomoku.html

run it from codebase:

bash ./compile_for_web.sh
cd gomoku/script
python3 ./tornado_server.py 80 debug

open url: http://127.0.0.1/web/gomoku.html

Requirement

System

  • Linux/macOS, Tested in ubuntu 18.04, macOS 10.15.4

Language

  • Python 3.x, Tested in 3.9.0
  • C++ 17

Package

macOS: brew install alexreg/dev/rocksdb@6 for python lib

""" rocksdb@6 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula.

If you need to have rocksdb@6 first in your PATH, run: echo 'export PATH="/usr/local/opt/rocksdb@6/bin:$PATH"' >> ~/.zshrc

For compilers to find rocksdb@6 you may need to set: export LDFLAGS="-L/usr/local/opt/rocksdb@6/lib" export CPPFLAGS="-I/usr/local/opt/rocksdb@6/include" For pkg-config to find rocksdb@6 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/rocksdb@6/lib/pkgconfig" """

Linux:

C++

  • RocksDB 6

    [email protected]:facebook/rocksdb.git da11a5903 v6.xx

    g++ rocksdb_test.cpp -o test -I/Users/chenqiang/Documents/gthub/rocksdb/include/ -std=c++17 -lsnappy -lgflags -lz -lbz2 -llz4 -lzstd /usr/local/Cellar/jemalloc/5.2.1_1/lib/libjemalloc_pic.a /Users/chenqiang/Documents/github/rocksdb/librocksdb.a

AI limitation

The AI might not work if white move far away 3 steps from any existing move

Development Guide to solve an board

  1. encode your board by string, for example: for , you need to encode it to h8_i9, this is the board to solve, , and last black move is i10, this is guided move
  • board to solve: h8_i9
  • guided move: i10
  1. solve your board with guided move
./problem_comb.sh h8_i9 i10

during the time, in order to see more debug info, run

tail -f gomoku/script/run.py.log
  1. validate if the board get solved
./problem_manager.sh h8_i9

if nothing print, the board get solved, if not then you need to solve listed board in "AND" node

  1. for the listed board, go step 1 to solve it, you need find guided move yourself

  2. tested in UI by launching it locally

bash ./compile_for_web.sh
cd gomoku/script
python3 ./prepare_board2action_from_dir.py
python3 ./write_board2action_into_db.py
python3 ./tornado_server.py 80 debug

open url: http://127.0.0.1/web/gomoku.html

gomoku-first-move-always-win's People

Contributors

fucusy 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.