SRM INSTITUTE OF SCIENCE AND TECHNOLOGY Ramapuram,Chennai - 600089 FACULTY OF ENGINEERING AND TECHNOLOGY Department of Information Technology Academic Year (Even 2021 – 2022) Year : III year - B 18CSC305J ARTIFICIAL INTELLIGENCE SEMESTER - VI : Name Reg. No : Class : B.Tech (IT) BONAFIDE CERTIFICATE Certified that this is t he bonafide record of work done by of VI S emester - B B.Tech Information Technology during the academic year 2021 – 2022 , Even Semester in 18CSC305J – ARTIFICIAL INTELLIGENCE Staff - In charge Head of the Department ` SRM INSTITUTE OF SCIENCE AND TECHNOLOGY Ramapuram,Chennai - 600089 FACULTY OF ENGINEERING AND TECHNOLOGY Department of Information Technology REG NO: Submitted for the End Semester Practical Examination held at SRM Institute of Science & Technology, Ramapuram, Chennai - 89. Table of Contents S.NO EXPERIMENT NAME DATE 1. Implementation of Toy Problems 05.01.2022 2. Developing Agent Program to Solve Real World Problems 12.01.2022 3. Implementation Of Constraints Satisfaction Problem 19.01.2022 4. Implementation and An alysis of DFS and NFS Application 02.02.2022 5. Developing Best First Search and A* Algorithm for Real World Problems 09.02.2022 6. Implementation of Minimax Algorithm for an Application 16.02.2022 7. Implementation of Unification and Resolution for Rea l World Application 23.02.2022 8. Implementation of Knowledge Representation Schemes - Use Cases 02.03.2022 9. Implementation of Uncertain Methods for an Application 09.03.2022 10. Block World Problems 16.03.2022 11. Implementation of Learning Algorith m for an Application 23.03.2022 12. Classification Model using the Gradient Boosting Algorithm using Boston Housing Dataset 30.03.2022 13. Implementation of Code Generation 06.04.2022 14. Implementation of Storage Allocation Strategies 13.04.2022 15. A pplying Deep Learning Methods To Solve An Application 20.04.2022 Ex.No : 1 IMPLEMENTATION OF TOY PROBLEMS AIM: ALGORITHM: PROGRAM CODE: boaíd = [' ' foí x in íange(10)] def inseítLetteí(letteí, pos): boaíd[pos] = letteí def spaceIsFíee(pos): íet uín boaíd[pos] == ' ' def píintBoaíd(boaíd): píint(' | |') píint(' ' + boaíd[1] + ' | ' + boaíd[2] + ' | ' + boaíd[3]) píint(' | |') píint(' -------- ') píint(' | |') píint(' ' + boaíd[4] + ' | ' + boaíd[5] + ' | ' + boaíd[6]) píint(' | |') píint(' -------- ') píint(' | |' ) píint(' ' + boaíd[7] + ' | ' + boaíd[8] + ' | ' + boaíd[9]) píint(' | |') def isWinneí(bo, le): íetuín (bo[7] == le and bo[8] == le and bo[9] == le) oí (bo[4] == le and bo[5] == le and bo[6] == le) oí(bo[1] == le and bo[2] == le and bo[3] == le) oí(bo[1 ] == le and bo[4] == le and bo[7] == le) oí(bo[2] == le and bo[5] == le and bo[8] == le) oí(bo[3] == le and bo[6] == le and bo[9] == le) oí(bo[1] == le and bo[5] == le and bo[9] == le) oí(bo[3] == le and bo[5] == le and bo[7] == le) def playeíMove(): íun = ľ í u e while íun: move = input('Please select a position to place an \ 'X \ ' (1 - 9): ') tíy: move = int(move) if move > 0 and move < 10: if spaceIsFíee(move): íun = False inseítLetteí('X', move) else: píint('Soííy, this space is occupied!') else: píint('Ple ase type a numbeí within the íange!') except: píint('Please type a numbeí!') def compMove(): possibleMoves = [x foí x, letteí in enumeíate(boaíd) if letteí == ' ' and x != 0] move = 0 foí let in ['O', 'X']: foí i in possibleMoves: boaídCopy = boaíd[:] b oaídCopy[i] = let if isWinneí(boaídCopy, let): move = i íetuín move coíneísOpen = [] foí i in possibleMoves: if i in [1,3,7,9]: coíneísOpen.append(i) if len(coíneísOpen) > 0: move = selectRandom(coíneísOpen) íetuín move if 5 in possibleMoves: move = 5 í etuín move edgesOpen = [] foí i in possibleMoves: if i in [2,4,6,8]: edgesOpen.append(i) if len(edgesOpen) > 0: move = selectRandom(edgesOpen) íetuín move def selectRandom(li): impoít íandom ln = len(li) í = íandom.íandíange(0,ln) íetuín li[í] def isB oaídFull(boaíd): if boaíd.count(' ') > 1: íetuín False else: íe t u í n ľ í u e def main(): p í i n t( ' Wel c o m e t o ľ i c ľac ľo e! ' ) píintBoaíd(boaíd) while not(isBoaídFull(boaíd)): if not(isWinneí(boaíd, 'O')): playeíMove() píintBoaíd(boaíd) else: píint('Soííy, O \ 's won this time!') bíeak if not(isWinneí(boaíd, 'X')): move = compMove () if move == 0: píint('ľie Game!') else: inseítLetteí('O', move) píint('Computeí placed an \ 'O \ ' in position', move , ':') píintBoaíd(boaíd) else: píint('X \ 's won this time! Good Job!') bíeak if isBoaídFull(boaíd): píint('ľie Game!') while ľíue: answe í = input('Do you want to play again? (Y/N)') if answeí.loweí() == 'y' oí answeí.loweí == 'yes': boaíd = [' ' foí x in íange(10)] píint(' ') main() else: bíeak OUTPUT : RESULT : Ex.No : 2 DEVELOPING AGENT PROGRAM TO SOLVE REAL WORLD PROBLEMS AIM: ALGORITHM: PROGRAM : print("Enter the total: ") total=int(input()) print("Enter the distance: ") distance=int(input()) print("Enter the Load Capacity: ") load_capacity=int(input()) print("Enter the Actual Loss: ") loss=int(input()) st art=total for i in range(distance): while start>0: start=start - load_capacity if start==1: loss=loss - 1 loss=loss+2 loss=loss - 1 start=total - loss if start==0: break print("The total is: ",start) OUTPUT : RESULT: Ex.No : 3 Implementation Of Constraints satisfaction problem AIM: ALGORITHM : PROGRAM : colors = [ 'Red' , 'Blue' , 'Green' ] states = [ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' ] neighbors = {} neighbors[ 'A' ] = [ 'B' , 'C' ] neighbors[ 'B' ] = [ 'A' , 'C' , 'D' ] neighbors[ 'C' ] = [ 'A' , 'B' , 'D' , 'E' , 'F' ] neighbors[ 'D' ] = [ 'B' , 'C' , 'E' ] neighbors[ 'E' ] = [ 'C' , 'D' , 'F' ] neighbors[ 'F' ] = [ 'C' , 'E' ] neighbors[ 'G' ] = [ '' ] colors_of_states = {} def promising ( state , color ): for neighbor in neighbors.get(state): color_of_neighbor = colors_of_state s.get(neighbor) if color_of_neighbor == color: return False return True def get_color_for_state ( state ): for color in colors: if promising(state, color): return color return None if name == " main " : for state in states: colors_of_states[state] = get_col or_for_state(state) print (colors_of_states) OUTPUT : RESULT: Ex.No : 4 IMPLEMENTATION AND ANALYSIS OF DFS AND NFS APPLICATION AIM: ALGORITHM: PROGRAM: { "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "AI LAB 2(BANANAS AND MONKEYS).ipynb", "provenance": [], "collapsed_sections": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": " SRIjX5LBcgIs", "outputId": "9ed50291 - 0c17 - 4ad3 - bb83 - 8894ff401891" }, "source": [ "print( \ "Enter the total: \ ") \ r \ n", "total=int(input()) \ r \ n", "print( \ "Enter the distance: \ ") \ r \ n", "distance=int(input()) \ r \ n", "print( \ "Enter the Load Capacity: \ ") \ r \ n" , "load_capacity=int(input()) \ r \ n", "print( \ "Enter the Actual Loss: \ ") \ r \ n", "loss=int(input()) \ r \ n", "start=total \ r \ n", "for i in range(distance): \ r \ n", " while start>0: \ r \ n", " start=start - load_capacity \ r \ n", " if start==1: \ r \ n", " loss=loss - 1 \ r \ n", " loss=loss+2 \ r \ n", " loss=loss - 1 \ r \ n", " start=total - loss \ r \ n", " if start==0: \ r \ n", " break \ r \ n", "print( \ "The total is: \ ",start) \ r \ n" ], "execution_count": 24, "outputs": [ { "output_type": "stream", "text": [ "Enter the total: \ n", "3000 \ n", "Enter the distance: \ n", "1000 \ n", "Enter the Load Capacity: \ n", "1000 \ n", "Enter the Actual Loss: \ n", "0 \ n", "The total is: 533 \ n" ], "name": "stdout" } ] } ] } OUTPUT: RESULT: