Git Product home page Git Product logo

foolgo's Introduction

FoolGo is a Go A.I. based on MCTS (Monte Carlo Tree Search).

It shows the beginner level on the 9x9 board currently, for it does not use neural networks, but only the simple UCT (UCB for Tree) algorithm and Monte Carlo simulation.

The underlying data structure and algorithms are quite efficient. Specifically, it runs 40 thousand Monte Carlo games per second on my MacBook Air 2014.

The key ideas of the Go game's implementation are as follows:

  • We implement a string of connected pieces using the disjoint set to update piece strings during the game process efficiently.
  • We use bit operations to update the liberty point number of piece strings efficiently. For example, we use or when merging several piece strings into a single one.
  • We do not implement a tree structure for tree search, but use a hash table to keep game states. Especially, we use Zobrist Hashing to compute the hash value of a game state incrementally.

For MCTS, we use multi-thread search on CPU. In detail, we simply prohibit a thread from exploring nodes that are being explored by peer threads.

This project is highly readable and extensible due to its well-designed OOP design. Some important classes are listed as follows:

  • FullBoard A game board class providing efficient methods such as PlayMove to update the game state.
  • Player An interface providing inheritable methods such as NextMove. For example, RandomPlayer, a Player subclass, will return a random legal position of the next move when called its NextMove, while UCTPlayer performs the UCT algorithm to find the next move.
  • Game An interface containing two Player objects. For example, MonteCarloGame contains two RandomPlayer objects.

Make

  • boost is required
  • mkdir build && cd build
  • cmake ..
  • make

Contact

foolgo's People

Contributors

chncwang avatar qmarliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

foolgo's Issues

第三手棋程序会抛异常

启动项目foolgo,玩家白棋下第三手棋后程序会抛异常。日志:
Assertion failed: node_record.GetVisitedTime() > 0, file e:\project\foolgo\src\player/uct_player.h, line 62

查看源码:
float Ucb(const NodeRecord &node_record, int visited_count_sum) {
assert(node_record.GetVisitedTime() > 0);
return node_record.GetAverageProfit()
+ sqrt(2 * log(visited_count_sum) / node_record.GetVisitedTime());
}
发现白棋下第三手棋后模拟过程会出现Ucb节点访问次数为0,导致除0异常

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.