Skip to main content

Artificial Neural Networks: A novel approach





Artificial Neural Networks, Seems to be a pretty novel approach to solve big scale problems. It actually works and mimics a Human brain and thinks as a mannered Human, full of consciousness and sophisticated Intelligence. 

I trained a neural net to play Tic-Tac-Toe at 3 different modes: Random, Easy and Smart.




So what does this mean??

The program uses a genetic algorithm to evolve neural networks to
play tic tac toe with some intelligence.  It's written in pure
JavaScript and runs completely in your browser.  It utilizes web workersto parallelize the work, and local storage to save your
progress.

How does it work??
First, we generate every tic tac toe game state where the next move has
more than one valid option, a mere 4,298 states.  We then use an AI
that plays a perfect game to determine the "right" move or set of equivalentmoves to make in each case.  Perfect means the AI 1) never
loses, 2) tries to win as quickly as possible, and 3) moves to take

advantage of opponent fumbles.

    We start with a randomly generated population of neural nets of fixed
     geometry.  Each individual net is scored on how many times it gives a
     " right" answer in response to being asked what move to make for each
        game state.  The top scoring nets are favored to populate the next
        generation through reproduction with a chance of random mutation.  The
        hope is that after letting it run for a while, you'll end up with a net
        that can play the game relatively well.

       The nets are simple feed-forward artificial neural networks.  They use
        a binary activation function with a variable bias (inverted in the code
        as a "threshold") and weight for each connection.


        Each net has 18 input neurons, two for each game square, a few internal
        layers of different sizes, and one output which represents the
        desirability of the input game state.  A square's first neuron receives
        input if that square is occupied by the player for whom we're finding
        moves, and the second neuron receives input if it's occupied by the
        opponent.  To find a move to make, each valid move is applied and the
        resulting game state is evaluated.  The move with the highest scoring
        state is chosen.


About the genetic Algorithm

        Each generation after the first is populated using genetic material
        from the previous generation.  A few of the top performing individuals
        are simply cloned into the next generation.  The rest of the generation
        is created from randomly combining the genomes of two parents chosen
        at random, biased toward the top scoring individuals.  Each child is
        mutated slightly to stir things up.  The same individual can be chosen
        as both parents of a child, in which case the slight mutation is the
        only change to its genome.  The genome consists of all the biases and

        weights of an individual's neural net.
    

Comments

Popular posts from this blog

Recommender System using Python

Recommender systems are everywhere. Amazon recommends buys we like, google recommends searches, Youtube recommends systems and Facebook recommends people. All of these implementations describe Recommender Systems. There are 2 types of Recommender Systems. Collaborative Systems - Systems that recommend information based on what you like and what the others like. Content Based Systems- Based on what you have viewed This is a simple ML based recommender System in python. It uses the LightFM library as the dataset import numpy as np from lightfm import LightFM from fetch_lastfm import fetch_lastfm data = fetch_lastfm() model = LightFM( loss = ' warp ' ) model.fit(data[ ' matrix ' ], epochs = 30 , num_threads = 2 ) # Get recommendationns function def get_recommendations ( model , coo_mtrx , users_ids ): n_items = coo_mtrx.shape[ 1 ] for user in users_ids: # TODO create known positives # Artists the model pred...

Why online learning needs AI augmentation

With a large portion of schools having moved to online based learning through platforms like Zoom and Microsoft Teams, students are required to grasp concepts in a one-dimensional online medium as opposed to a constructive and collaborative class environment. Being a student during the pandemic, I have first hand experience with the mundane manner of teaching- and why we need to augment this with Artificial Intelligence algorithms. In a classroom, teachers can somehow manage to personalise some parts of learning or pay attention to weak students. However, in an online medium, with all the latency issues and network constraints, also moving in a general pace can be tough. Therefore for online learning,AI can be key, by providing a personalised learning path for the students. Using algorithms like NLP ( Natural Language Processing ), the online class can be transcribed according to the student's intellectual levels. AI, in this case, can make a specific-tailored learning path ...

Making AI Play Games

The Artificial Intelligence era has started only a while ago and it is drastically augmenting and amplifying our lives But in this sphere of development, the developers have had a big problem to test their AI. This is where great minds like Elon Musk step in and create adroit and efficient resources to test the Intelligence that we create. His vision and aspiration led to the start of OpenAI, a free open source library and a company specializing in research. They create toolkits for Deep Learning developers like us to deploy models and make AI play games. This helps us to analyze the power of the intelligence by simulating game environments.  OpenAI provides enthusiasts with 2 toolkits to work with Gym - Toolkit for comparing and developing deep reinforcement learning algorithms... Universe - A collection of gym environments to train and measure an AI's general intelligence... Today we are going to write a simple script in python to help build a ...