Posts

Showing posts with the label AI

Teaching Computers to Play Tic Tac Toe: A Reinforcement Learning Approach

Image
 You can see the full code on GitHub: https://github.com/SQLNoggin/Smart-TicTacToe-RL_NaomiA.git This Python script implements a reinforcement learning agent to play the game of Tic Tac Toe. The agent is trained through Q-learning, a type of model-free reinforcement learning that uses a Q-table to estimate the value of taking specific actions in particular states. Let's break down the key aspects:   Overview The script uses the Tkinter library to create a graphical user interface (GUI) where the Tic Tac Toe game can be played. NumPy is used for numerical operations, and the pickle library is used to save and load the Q-table to/from a file. Constant and Hyperparameter Definitions PLAYER_X and PLAYER_O : Constants representing the two players (1 for X and -1 for O). EMPTY : Constant representing an empty cell on the Tic Tac Toe board. ALPHA : The learning rate used in the Q-learning updates. GAMMA : The discount factor used in the Q-learning updates. EPSILON_START, EPSILON_END,...

How to Create a Neural Network for Recognizing Hand-Drawn Shapes

Image
  by Naomi A. In this guide, we will walk through the process of developing a neural network that identifies hand-drawn shapes. The tutorial is broken down into three main sections: Preprocessing the hand-drawn shapes. Training a neural network to recognize these shapes. Creating a simple user interface to predict the drawn shapes.   All code is available on github under the MIT License. (LINK TO REPO)  1. MNIST Maker: Preprocessing Hand-Drawn Shapes Objective : Convert the images of hand-drawn shapes into a standardized format for machine learning. Steps: Load the images from a specified directory. Convert them to grayscale and resize them to 28x28 pixels. Normalize the pixel values. Label the images based on their filenames. Shuffle and split the data for training, validation, and testing.  SCRIPT for creating the MNIST Dataset: import cv2 import numpy as np import os import random # Path to the shapes directory base_folder = r"C:\yourpathgoeshere" shapes...