Coder Social home page Coder Social logo

ai-assignment-oct2021's Introduction

AI-Assignment-Oct2021


This project is an implementation of AI-based agents
  • VaccuumBot - A simple reflex agent
  • NimBot - A rational agent utilizing minimax algorithm


Vaccuum Bot

The environment consists of 2 blocks: A and B which can hold the status of Clean or Dirty.
The agent is a vacuum bot which decides its action based on the status of the location:

  1. If the location is Dirty, the agent cleans the location
  2. If the location is Clean, the agent moves randomly in any direction
    If the bot hits a wall, it remains in the same location, else it moves to the other block.

Each action is considered as a time step. A performance measure of the agent, the number of cleaned locations is measured upon each time step.
After a lifetime of 1000 timesteps, the agent is terminated and the performance is measured.
This simulation is repeated on all possible configurations to understand the performance of the agent.

The state space graph is shown below:
![State Space Graph](./images/q1_statespacegraph.png "State Space Graph")

Configurations from the simulation run are shown below:
![Configurations](./images/ss_q1_output.png "Configurations")

How to Use:

Run the script using python .\q1_simplex_reflex_agent_simulation.py
The simulations will run and report will be generated for the test runs
The simulation call can also be modified to accomodate changes to lifetime and to show action report for each timestep

Nim Bot

The game space consists of 2 piles of stones, each having a equal number of stones initially.
The game rules are as follows:

  1. A player can remove any number of stones from any pile.
  2. The player who has to remove the last stone loses the game

The agent is a Nim bot which decides its action based on the number of stones in the piles using the minimax algorithm.
An evaluation score is decided based on who won the game.
A map is computed from the game that the bot plays with another bot, created using the minimax algorithm with the initial evaluation score on the leaf nodes.
The bot is then able to play the game against the humans or other bots using the map.
The winning map after training over the minimax is as follows:
Winning Map

The output of the bot vs bot game played is shown below:
Bot vs Bot

The output of the Human vs bot game 1 played is shown below:
Human vs Bot

The output of the bot vs bot game 2 played is shown below:
Human vs Bot

How to Use:

Run the script using python .\q2.py_nim_minimax.py
Decide if a human wants to play with the bot or not
A game will be initiated and a coin toss decides who goes first
A sequence of inputs for pile no. and number of stones will be requested on the console for input
The game tree will be displayed after every move
Winning will be declared when the stack reaches [0, 0] or if the bot concedes(No giving up for the user!!)

ai-assignment-oct2021's People

Contributors

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