GithubHelp home page GithubHelp logo

azmke / lcs-tictactoe Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 92 KB

A tic-tac-toe bot that you cannot defeat, written in JavaScript and based on a learning classifier system.

License: MIT License

JavaScript 73.76% HTML 22.74% CSS 3.50%
tic-tac-toe tic-tac-toe-bot bot learning-classifier-systems lcs game automation javascript artificial-intelligence

lcs-tictactoe's Introduction

lcs-tictactoe

lcs-tictactoe is a tic-tac-toe bot that you cannot defeat, written in JavaScript and based on a learning classifier system.

Screenshot

Let's play

In case you just want to play and find out what this tic-tac-toe bot is really capable of, we have something prepared for you. We trained the bot for a very long time and compiled the rule set into a single file that you can easily import.

  1. Open the index.html file in a browser of your choice.
  2. Under Import rule set click on Choose file and select the ruleset.json file.
  3. Click on Open file.
  4. Start playing!

Training

Feel free to train your own model with your parameter values.

Parameter Value Description
LEARNING_RATE 0 ... 1 To determine the new reward of a rule, the formula NEW_REWARD = (1 - LEARNING_RATE) * OLD_REWARD + LEARRNING_RATE * REWARD is used. A higher learning rate leads to a faster change of a rule's reward.
REWARD_DEFAULT n Sets the default reward for a rule that is added to the rule set for the first time.
REWARD_WIN n Sets the highest reward that can be included in the above formula (REWARD = REWARD_WIN) for a rule if the bot wins a game.
REWARD_TIE n Sets the highest reward that can be included in the above formula (REWARD = REWARD_TIE) for a rule if a game ends in a draw.
REWARD_LOSE n Sets the highest penalty that can be included in the above formula (REWARD = REWARD_LOSE) for a rule if the bot loses a game.
REWARD_DECREASE_RATE 0 ... 1 Only the bot's last move receives the highest reward/punishment. For each additional past move the reward/punishment is multiplied by (1 - REWARD_DECREASE_RATE). A higher decrease rate leads to a faster decrease of the reward/punishment for each move further back.
TRAINING_CYCLES 1 ... n Sets the number of games the bot will play during the training. A game is considered complete when the bot either wins, loses, or the game ends in a draw.

Statistics

The rule set coded in ruleset.json achieved the following performance during training:

Total training cycles 5,000,000 100.00 %
Total wins 4,373,340 87.47 %
Total ties 624,449 12.49 %
Total losses 2,211 0.04 %

A subsequent test run using the same rule set resulted in the following performance:

Total test cycles 10,000 100.00 %
Total wins 8,759 87.59 %
Total ties 1,241 12.41 %
Total losses 0 0.00 %

lcs-tictactoe's People

Contributors

azmke avatar

Stargazers

 avatar  avatar

Watchers

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