Giter VIP home page Giter VIP logo

tic-tac-toe-rl's Introduction

Implement tic-tac-toe using deep q network. The agent learns both the rules and the strategy of the game from experience. To force the agent to learn the rules, I apply a heavy penalty for cheating ( placing a move on an illegal spot )

  • game.py: implement a simple tic tac toe game environment
  • train.py: driver for gathering experiences and training
  • rl/deep_q_network.py: implementation for deep q network

Network Architecture:

A simple feedforward two hidden layer network

Reward Structure:

  • Won: 100
  • Draw: 10
  • Lost: -1
  • Cheating (placing a move on a taken spot): -10

Future rewards are discounted

Training Parameters

  • Initial exploration epsilon: 0.6
  • Final exploration epsilon: 0.1
  • Discount factor: 0.8
  • Regularization strength: 0.01
  • Target network update rate: 0.01

Experiments

The following shows the average reward from last 100 games that have been played over a training period of about 180k games. Orange is when the agent plays against a random player. Yellow is when the agent plays against a near-optimal strategy player. In both cases, the agent always makes the first move

Alt text

tic-tac-toe-rl's People

Contributors

yanji84 avatar

Watchers

DURIEZ 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.