Giter Club home page Giter Club logo

connect-four-ml-lab's Introduction

Connect Four ML Lab

The dependencies are in environment.yml. Create a conda environment with these, and all python code should work. For the user interface, run npm install then npm run dev in the react-app directory.

To run the server for the UI, run server.py in the set up conda environment.

To train the model, just run main.py. Ml.py has various commented out options for things like training for more/less time, testing vs. different opponents/strategies, playing a game against the DQN yourself, etc. I plan to make this more straightforwardly customizable in future releases.

The DQN only receives reward at the end of each episode - ie. once per game. This causes it not to do very well against stronger strategies. It can do very well against deterministic strategies it's trained on, or against random strategies if trained against random strategies.

A few possible ways to improve performance:

  • Give the DQN reward based on straightforward Connect 4 heuristics - ie. give it some reward if it has a threat to win, or negative reward if the opponent has the same.
  • Give the DQN observations other than the pure, unfiltered game state - ie. give it an observation bool for each column for each of "I can win by playing this column" or "opponent can win by playing this column".
  • Try using self-play, maybe with something like a lightweight AlphaZero style implementation.

The third option would be pure improvement, though it'd be a pretty different project - I may add some extra, different files that explore this. The first two options are more like tradeoffs: the DQN would surely do better if it had Connect 4 heuristics "baked in", but to some degree that defeats the purpose; part of the point of the project is for the agent to learn how Connect 4 works in the first place!

Other potential enhancements:

  • Saving/loading trained models - this is really easy, but the models aren't really good enough to justify it yet. If I make them perform better, this could be used for...
  • A hosted GUI for people to play against Connect 4 bots of various levels. Probably the heuristics I use for testing, plus some trained agents of varying strength.

connect-four-ml-lab's People

Watchers

Justis Mills 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.