Giter Site home page Giter Site logo

vishal815 / tictactoe_q_learing_ml Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 10 KB

Tic-Tac-Toe Q-Learning is a beginner-friendly example of using reinforcement learning.

Home Page: https://colab.research.google.com/github/vishal815/Tictactoe_q_learing_ML/blob/main/tictactoe_q.ipynb

Jupyter Notebook 100.00%
github-project machine-learning python-project q-learning q-learning-algorithm reinforcement-learning reinforcement-learning-algorithms tic-tac-toe tictactoe-game tictactoe-python vishallazrus q-table reinforcement-learning-environments reinforcementlearning

tictactoe_q_learing_ml's Introduction

Tictactoe_q_learing_ML

https://colab.research.google.com/github/vishal815/Tictactoe_q_learing_ML/blob/main/tictactoe_q.ipynb

1_KBrRlD4jlyeOQMI-usMfIw

Tic-Tac-Toe Q-Learning

Overview

Welcome to the Tic-Tac-Toe Q-Learning project! This repository contains a Python implementation of a Tic-Tac-Toe game using Q-learning, a type of reinforcement learning. The goal is to train an agent to play Tic-Tac-Toe optimally through self-play and learning from its experiences.

Features

  • Tic-Tac-Toe Environment: A simple implementation of the Tic-Tac-Toe game.
  • Q-Learning Algorithm: Train an agent using Q-learning to play Tic-Tac-Toe.
  • Interactive Gameplay: Play against the trained agent.
  • Visualization: Visualize the game board and the agent's decisions.

Colab Notebook

You can also run the project directly in your browser using Google Colab. The Colab notebook contains all the code and explanations.

Open in Colab and Play

Installation

  1. Clone the repository:
    git clone https://github.com/vishal815/Tictactoe_q_learing_ML.git

Code Explanation

Tic-Tac-Toe Environment

The TicTacToe class defines the game environment, including the board, player moves, and winning conditions.

  1. Reinforcement Learning: Q-learning is a reinforcement learning algorithm that involves training an agent to make decisions by interacting with an environment. In the case of Tic-Tac-Toe, the agent learns to make moves on the game board to maximize its chances of winning.

  2. Q-Table: In Q-learning, a Q-table is used to store the expected rewards for taking various actions in different states of the game. The agent updates this table through iterative learning to make better decisions over time.

  3. States and Actions: In the context of Tic-Tac-Toe, states represent the current arrangement of Xs and Os on the board, and actions correspond to valid moves the agent can make. The agent chooses actions based on the information in the Q-table.

  4. Rewards: The agent receives rewards for its actions, with a positive reward for winning the game, a negative reward for losing, and potentially smaller rewards for other outcomes like drawing the game.

  5. Exploration vs. Exploitation: Q-learning balances exploration (trying new actions to discover their rewards) and exploitation (choosing the best-known actions) to gradually improve its game-playing strategy.

Playing with Trained Agent

Tic-Tac-Toe Q-Learning is a beginner-friendly example of using reinforcement learning to solve a simple game. It can serve as a stepping stone to understanding more complex problems and reinforcement learning techniques. The end goal is to have an agent that can play Tic-Tac-Toe optimally, making the best moves possible to either win or force a draw in every game.

tictactoe_q_learing_ml's People

Contributors

vishal815 avatar

Stargazers

 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.