Coder Social home page Coder Social logo

alphahex's Introduction

AlphaHex

I enjoyed learning about AlphaGo, so I decided to try building a simple move predictor for my favorite game, Hex.

I decided to use Apache Spark because I have some experience with it and the Spark machine learning libraries are pretty dead-simple to use.

Status

You can train the model against a database of games. The games don't need to be complete. You can play against the model, the computer must go first and you cannot swap. (yet). The model is predicting what a human player would do based on the data it has trained. This means that a board state as input generates a move as output. The model doesn't have any idea of the rules of Hex, so it doesn't know it cannot play in a cell that is occupied. Unlike AlphaGo, the library I'm using only generates a move, it doesn't generate a probability distribution over moves, so there is no quick-and-dirty way to get the computer to choose a different cell, since it can't play in an occupied cell. My game database existed in SQLite, so I have some code for converting that to a list of comma-separated moves. That's the format you'll want to use.

Update: I implemented the logic again with an MLPC, and the results are much better! Downside is that as of Spark 1.6.1 there is no functionality to save off the model used for that classifier, so the UseMultiLayerPredictor class has to spend some time training the model before you can play hex against the model. Still no logic to esure that the model plays on an empty cell.

Update: I've added functionality to persist a model to disk with a sloppy wrapper around the MultiLayerPredictor. I've also checked in a serialized version of one trained model. The UseMultiLayerPredictor class is configured to load that model and let you play Hex against the AI. The wrapper also exposes all the output values, so it will always make a legal move.

alphahex's People

Contributors

mawise avatar

Stargazers

Uberto Barbini avatar

Watchers

James Cloos avatar  avatar

alphahex's Issues

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.