Giter Club home page Giter Club logo

mcts's Introduction

Monte Carlo Tree Search

Java implementation of UCT based MCTS.

Main Algorithm

Everything in the main package is related to the algorithm itself. The other packages (connectFour, twothousandfortyeight) are implementations of games which the algorithm can play. Use them for reference. As of now 2048 is broken, but Connect Four works fine.

MCTS specifies the method runMCTS which implements the full algorithm with UCT default policy. After thinking for the specified number of iterations it will do a final selection where it decides, ultimately, which move to make.

This move is what the algorithm concluded was the best move to make at this point in time. The more iterations you let it think, the better a movie will be returned.

Board is an interface that must be implemented if you want to make the algorithm play your game. Move is another interface that also must be implemented. Your implementation of Board must be able to return a list of all moves possible at the current state of the game.

Score Bounds

You can enable score bounds by passing a 'true' to the runMCTS function as the third parameter. When score bounds is enabled, the algorithm will, when backtracking, also propagate an upper and lower score bound which is used to cut down the size of the tree near end states.

Clarifying some terms here: The active player for a given node is the player who is to make a decision at that point. The opponent for a given node is a player who is not making a decision.

These represent the potentially highest and potentially lowest possible scores for the given active player from this point on. For example: A node with a lower score bound of 1.0 for player 1 means that from that state and onwards down the tree no possible move by any opponent can lead to a worse state for player 1. Player 1 is guaranteed to win.

Conversely an upper bound of 0.0 implies there is no way for that player to win.

Bounds are propagated back up the tree such that the upper bound for the active player in any node is always the maximum upper bound for that player in any child node. The lower bound for the active player in any node is always the maximum lower bound for that player in any child node.

The rules also propagate the bounds for the opponents. The upper and lower bound for an opponent is always the lowest upper and lower bounds for any node respectively.

Stochastic Games

Support for randomness is pending. It will likely be part of the next major update.

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.