Giter Site home page Giter Site logo

mancalaai's Introduction

MancalaAI

Yet another mancala AI (Minimax, MCTS) implementation.
Even though mancala is solved game, it is still fun to play with those algorithms!
You can play it here.

Interesting things

Minimax

I used simple (myScore - opponentScore) as heuristic.
At first, I set high weight for winning state (like 1000 points when already scored more than half), but this leads to suicide moves (giving up all the stones) if already winning / boring moves just to delay losing. This looks fool at first glance (while reasonable though), so I stick to simple score.

In mancala, if player finishes a move at his/her scoring pot, that player get an extra turn.
Considering the depth of this extra turn just like a regular move might be unfair, because if so, some leaf nodes (that is estimated by heuristic) are in opponent's turn while some are mine.
Of course, such moves will be favored.

So I considered extra move as same depth as previous move. You might think it's still unfair because leaf nodes has different progression.
But my heuristic is pure relative, so the game progression doesn't matter.

MCTS

On 1vs1 game, MCTS is very similar to minimax. Both consider opponent as smart as itself, simulates worst actions for itself.
But minimax is more strict. It is right for its depth. MCTS is more rough but deeper. (And yes, they have different and more important properties, like aheuristic, anytime)
So it is make sense that there is some Minimax-MCTS hybrid approach, MCTS for big picture and minimax for details.

Best action selection at root node (after enough iteration of selection-expand-simuate-back propagation) is selecting robust child (child with most visit). This isn't intuitive for me, and still I'm not sure about it. (link about it)

Implementation

Not much interesting things here :p I used fixed array for stack-live board state, and removed threading for WebGL build.

Experiments

Matchup (first=start) Win Lose Draw
Random vs Random 47.4% 46.8% 5.8%
Random vs Minimax 0.1% 99.7% 0.2%
Random vs MCTS - 99.9% 0.1%
Minimax vs Random 100% - -
Minimax vs Minimax 100%* - -
Minimax vs MCTS 100% - -
MCTS vs Random 100% - -
MCTS vs Minimax 27.9% 57.2% 14.9%
MCTS vs MCTS 70.4% 21.9% 7.7%

* My implementation of minimax doesn't contain any randomness.

I tested with depth 7 for minimax, 8000 iteration for MCTS. Each matchup is played 1000 times.

mancalaai's People

Contributors

yellowisher avatar

Stargazers

LeeTaeHwa avatar

Watchers

 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.