Skip to content

This repository contains all the files from the coding assignments for the graduate course on Elements of Artificial Intelligence at Indiana University Bloomington. All the codes are written in Python.

Notifications You must be signed in to change notification settings

arnkmish/MyAICodes

Repository files navigation

MyAICodes

This repository contains all the files from the coding assignments for the graduate course on Elements of Artificial Intelligence at Indiana University Bloomington. All the codes are written in Python.

HomeWork1:

This homework asks to implement a simple reflex agent that can play tic tac toe game against a human player. The simple reflex agent makes use of just the current percept of the world and based on rules defined, it makes the move. The agent doesn't keep track of any world situations.

arnkmish-hw1.py is the python file that contains the code for running this tic tac toe playing agent, and arnkmish-hw1-output.txt contains a brief snapshot of some sample outputs.

HomeWork2:

This homework asks to implement some basic AI Seach algorithms like BFS, DFS, Best First Search and A*. The search algorithms work on a box moving robot world, where the boxes are searched first and then their respective destinations for the purpose of moving the boxes. The varying level of power of the algorithms are evident on tougher problem instances, where A* is the only algorithms that is able to find a solution before timeout.

Search.py contains the code for implementing the various search algorithms.

HomeWork3:

This homework asks to utilize the alpha beta pruning algorithm for building a checkers playing agent. Based on the time limit, the look ahead depth can be changed in the code. This agent uses an evaluation function that takes into consideration number of Kings and Pawns, pieces being on the side squares for defense and pieces being in the middle squares for more board coverage.

checkerAgent.py contains the code for the checkers playing agent.

gamePlay.py plays two agents against each other. You will be using doMove(board, position) from this file to make a move. There are other utility functions in the file which you may want to use. From the command line, this function is invoked with:

% python gamePlay.py [-t] [-v] player1 player2

Where player1.py and player2.py are python files that contain a nextMove function. The flag -v stands for verbose output (display the board after every turn).

getAllPossibleMoves.py gets all possible moves possible for a color, on the board, as a list.

randomPlay.py sample agent that makes a random legal move

humanPlay.py a simple Python file that lets you play the game as a human player

simpleGreedy.py a sample agent that uses a brain-dead evaluation function, with no search.

HomeWork6:

This homework asks to solve the 0/1 Knapsack problem using Genetic Algorithm. Since its an NP Hard optimization problem, Genetic Algorithms tend to work quite well here. The solutions generated by the GA is not optimal in most of the cases but it does get quite nearer to the optimal solution when the number of generation, the initial population, level of mutation, and the level of elitism are tuned properly. The GA uses a single point crossover function to reproduce. The natural selection process implements a Roulette Wheel selection approach.

knapsack.py file contains the code for soving the knapsack problem. The code provides sample problem instances for checking the GA's performance, simple modfications can be made in the code for taking a new user input problem instance for the GA to work on.

About

This repository contains all the files from the coding assignments for the graduate course on Elements of Artificial Intelligence at Indiana University Bloomington. All the codes are written in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages