Professional Documents
Culture Documents
Practical: 1
}while(i==-1);
MGITER/CE/2018-19 Page 1
Artificial Intelligence (2180703) 150330107077
board();
if(i==1)
{
printf("\nPlayer %d ",--player);
printf(" win ");
}
else
printf("\nGame draw");
getch();
return 0;
}
int checkwin()
{
if (square[1] == square[2] && square[2] == square[3])
return 1;
else if (square[4] == square[5] && square[5] == square[6])
return 1;
else if (square[7] == square[8] && square[8] == square[9])
return 1;
else if (square[1] == square[4] && square[4] == square[7])
return 1;
else if (square[2] == square[5] && square[5] == square[8])
return 1;
else if (square[3] == square[6] && square[6] == square[9])
return 1;
else if (square[1] == square[5] && square[5] == square[9])
return 1;
else if (square[3] == square[5] && square[5] == square[7])
return 1;
else if (square[1] != '1' && square[2] != '2' && square[3] != '3' &&
square[4] != '4' && square[5] != '5' && square[6] != '6' && square[7] != '7' &&
square[8] != '8' && square[9] != '9')
return 0;
else
return -1;
}
/*******************************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
********************************************************************/
void board()
{
clrscr();
printf(" \n\n\tTic Tac Toe\n\n");
printf("Player 1 (X) - Player 2 (O)\n\n");
printf("\n");
printf(" | | \n");
printf(" %c" ,square[1]);
printf(" | %c",square[2]);
printf(" | %c",square[3]);
printf("\n");
MGITER/CE/2018-19 Page 2
Artificial Intelligence (2180703) 150330107077
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" %c" ,square[4]);
printf(" | %c",square[5]);
printf(" | %c",square[6]);
printf("\n");
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" %c" ,square[7]);
printf(" | %c",square[8]);
printf(" | %c",square[9]);
printf("\n");
}
Output:
MGITER/CE/2018-19 Page 3
Artificial Intelligence (2180703) 150330107077
Practical: 2
male(jack).
male(james).
male(jacob).
male(justin).
male(edward).
female(shanshan).
female(weiwei).
female(erxia).
female(xiaolin).
parent(jack,shanshan,james).
parent(jack,shanshan,jacob).
parent(james,weiwei,edward).
parent(jacob,erxia,justin).
parent(jacob,erxia,xiaolin).
brother(james,jacob).
brother(jacob,james).
brother(edward,justin).
brother(justin,edward).
sister(xiaolin,justin).
sister(xiaolin,edward).
father(X,Y) :- parent(X,Z,Y).
mother(X,Y) :- parent(Z,X,Y).
son(X,Y,Z) :- male(X),father(Y,X),mother(Z,X).
daughter(X,Y,Z) :- female(X),father(Y,X),mother(Z,X).
wife(X,Y) :- female(X),parent(Y,X,Z).
grandfather(X,Y) :- male(X),father(X,Z),father(Z,Y).
uncle(X,Y) :- male(X),brother(X,Z),father(Z,Y).
aunt(X,Y) :- wife(X,Z),uncle(Z,Y).
cousin(X,Y) :- father(Z,X),brother(Z,W),father(W,Y).
ancestor(X,Y,Z) :- parent(X,Y,Z).
ancestor(X,Y,Z) :- parent(X,Y,W),ancestor(W,U,Z).
MGITER/CE/2018-19 Page 4
Artificial Intelligence (2180703) 150330107077
Output:
MGITER/CE/2018-19 Page 5
Artificial Intelligence (2180703) 150330107077
MGITER/CE/2018-19 Page 6
Artificial Intelligence (2180703) 150330107077
Practical: 3
Output:
MGITER/CE/2018-19 Page 7
Artificial Intelligence (2180703) 150330107077
Practical: 4
Aim: Give an opportunity to user to re-enter the password ‘n’ no. Of Times, on
entering wrong password.
PROLOG PROGRAM:
db(ben,10).
Output:
MGITER/CE/2018-19 Page 8
Artificial Intelligence (2180703) 150330107077
Practical: 5
PROLOG PROGRAM:
hobby(tony,coding).
hobby(ninja,gaming).
hobby(quill,dancing).
hobby(howard,reading).
Output:
MGITER/CE/2018-19 Page 9
Artificial Intelligence (2180703) 150330107077
Practical: 6
PROLOG PROGRAM:
symtom(ben,fever).
symtom(ben,cold).
symtom(ben,stomachache).
symtom(ben,running_nose).
symtom(ben,body_ache).
dis(X,malaria):-symtom(X,fever),symtom(X,headache),symtom(X,running_nose).
dis2(X,jaundice):-symtom(X,fever),symtom(X,stomachache),symtom(X,body_ache).
Output:
MGITER/CE/2018-19 Page 10
Artificial Intelligence (2180703) 150330107077
Practical: 7
Aim: Write a PROLOG program To check if a given year is a Leap Year or not.
PROLOG PROGRAM:
Output:
MGITER/CE/2018-19 Page 11
Artificial Intelligence (2180703) 150330107077
Practical: 8
PROLOG PROGRAM:
fact(0, 1).
fact(N, F):-N > 0, N1 is N-1, fact(N1, F1), F is N*F1.
Output:
MGITER/CE/2018-19 Page 12
Artificial Intelligence (2180703) 150330107077
Practical: 9
PROLOG PROGRAM:
go:-write('Enter no='),read(N),fibo(1,1,0,N).
fibo(_,_,_,0).
Output:
MGITER/CE/2018-19 Page 13
Artificial Intelligence (2180703) 150330107077
Practical: 10
len_ls([],0).
len_ls([H|T],L):-len_ls(T,LL),L is LL+1.
Output:
m1(E,[E|T]).
m1(E,[_|T]):-m1(E,T).
Output:
MGITER/CE/2018-19 Page 14
Artificial Intelligence (2180703) 150330107077
Practical: 11
jug(integer, integer).
jug(2, _).
jug(0, 2):-
write('(0, 2)'), nl,
write('(2, 0)'), nl.
jug(4, 0):-
write('(4, 0)'), nl,
jug(0, 0).
jug(4, 3):-
write('(4, 3)'), nl,
jug(0, 0).
jug(3, 0):-
write('(3, 0)'), nl,
jug(3, 3).
jug(X, 0):-
write('('),write(X),write(', 0)'), nl,
jug(0, 3).
jug(0, 3):-
write('(0, 3)'), nl,
jug(3, 0).
jug(0, X):-
write('(0,'),write(X),write(' )'), nl,
jug(0, 0).
jug(3, 3):-
write('(3, 3)'), nl,
jug(4, 2).
jug(4, 2):-
write('(4, 2)'), nl,
write('(2, 0)'), nl,
jug(2, 0).
jug(X, Y):-
X>4,
fail,
Y>3,
fail.
MGITER/CE/2018-19 Page 15
Artificial Intelligence (2180703) 150330107077
Output:
MGITER/CE/2018-19 Page 16
Artificial Intelligence (2180703) 150330107077
Practical: 12
PROLOG PROGRAM:
road(newyork,boston,60).
road(newyork,philadelphia,40).
road(philadelphia,boston,180).
dist(X,Y):-road(X,Z,D),road(Z,Y,S),F is D + S,write('Distance='),write(F).
goal:-write('Enter source='),read(X),nl,write('Enter destination='),read(Y),nl,dist(X,Y,D).
dist(X,Y,D):-road(X,Y,D),nl,write('Distance between '),write(X),write(' & '),write(Y),nl,
write('Distance='),write(D).
dist(X,Y,D):-road(X,Z,D),road(Z,W,F),road(W,Y,G),N is D + F + G,nl,
write('Distance between '),write(X),write(' & '),write(Y),nl,
write('Distance='),write(N).
Output:
MGITER/CE/2018-19 Page 17
Artificial Intelligence (2180703) 150330107077
Practical: 13
reverse([],[]).
reverse([H|T],R):-reverse(T,RT),append(RT,[H],R).
Output:
sum([H|T],S):-sum(T,Temp),S is Temp+H.
Output:
MGITER/CE/2018-19 Page 18
Artificial Intelligence (2180703) 150330107077
Practical: 14
Output:
MGITER/CE/2018-19 Page 19
Artificial Intelligence (2180703) 150330107077
Practical: 15
Output:
MGITER/CE/2018-19 Page 20
Artificial Intelligence (2180703) 150330107077
Practical: 16
Answer:
MGITER/CE/2018-19 Page 21
Artificial Intelligence (2180703) 150330107077
Practical: 17
Answer:
(a)
(b)
MGITER/CE/2018-19 Page 22
Artificial Intelligence (2180703) 150330107077
Machine Learning:
Machine learning is the incredibly powerful application of a simple concept: Look at the
inputs, try some outputs, see what happens. Of course, the mechanics behind this application
are the life's work of many amazing researcher, so this simple formulation belies how
complicated the whole thing can be.
However, machine learning itself mostly revolves around training a machine learning
algorithm around a best-guess utility function until it can consistently produce outputs that
increase the resulting value of this utility function given a set of inputs. You'll note that this
sounds quite similar to the interpretation of "intelligence" I give in the description of AGI
above.
Natural Language Processing:
This is a specific field in which one attempts to create programs that will, given an input
formulated in a "natural" human language (usually in the form of a text string), attempt to use
various common techniques in order to construct a model as accurate as possible of what was
said and what those words correspond to.
Frequently, this is to connect this model into various subprograms that will give various
outputs, with purpose ranging from finding a hotel when asked to activating a timer program
with parameters taken from the derived model. There are various disciplines involved in this
type of work that aren't strictly "AI" related, but in common usage the term AI refers to this
type of program frequently enough to be worth mentioning.
Super Intelligence:
So far, most research on this type of intelligence is theoretical and attempts to predict the
conditions by which such an intelligence could arise and/or the properties such a being would
have. Some people would put this and AGI under the same label, with the assertion that one
naturally follows from the other, but this is not yet certain.
Hard coded Decisional Algorithms:
These are almost always unique, and involve looking at a set of inputs, following an
algorithm, and deriving an appropriate output, based on the internal model that the
MGITER/CE/2018-19 Page 23
Artificial Intelligence (2180703) 150330107077
programmer put into this program. In short, they're just programs (or subprograms), with
their algorithm tailored for a specific purpose that involves making decisions that appear
"intelligent" to an untrained observer, earning themselves the "AI programs" label early on in
computing history.
Video game AI:
Subprograms in a video game that control the behaviour of certain elements of said game.
They usually involve some graph algorithms (see below), especially for path finding, and
some tailored decisional algorithms created by the game developers specifically for a
particular game.
AI Paradigms:
MGITER/CE/2018-19 Page 24
Artificial Intelligence (2180703) 150330107077
We are witnessing in real time the changes that could potentially rethink every industry and
area of human activity.Among some the technologies expected to emerge, enter the market
and peak, over the next three decades are:
Artificial General Intelligence
Cognitive Computing
Conversational user interface
Autonomous vehicles
Virtual Reality
Robotics and Smart Dusts
When we say that technology is driving and shaping the future of tomorrow, we do mean that
technology has its definite effects on our lifestyle. With Artificial Intelligence in question,
success and failure are the same sides of the coin. Technology also has some disadvantages and
challenges related to it. In this article, we’ll discuss some problems of artificial intelligence and
its solutions.
You’ll find a lot of information on the Internet about artificial intelligence and its applications.
But not a lot of attention has been given to the challenges of artificial intelligence. Here are some
of the artificial intelligence challenges:
Building trust:
AI is all related to science and algorithms, which lies on the technical side. People who are
completely unaware of these algorithms and technology that lies behind the working of
Artificial intelligence find it difficult to understand its functioning.
Here is how artificial intelligence can face trust issues with humans, in spite of its ability to
cut down on tasks. It is a basic human psychology that we often neglect something that we
don’t understand.
We as humans tend to stay away from anything complicated. And artificial intelligence being
related to huge data, data science and algorithms, there are times when users do not grasp
these concepts.
AI human interface:
The challenge here is the shortage of data science skills within humans to get maximum
output from artificial intelligence. As for the businesses, there is a shortage of advanced skills.
MGITER/CE/2018-19 Page 25
Artificial Intelligence (2180703) 150330107077
Business owners need to train their professionals to be able to leverage the benefits of this
technology.Statistics reveal that 55% of survey respondents felt the biggest challenge was the
changing scope of human jobs when everything will be automated.
Investment:
Another challenge of artificial intelligence is that not all business owners or managers are
willing to invest in it. The funds required to set up and implement Artificial Intelligence is
very high, thus not every business owner or organization can invest in it or can try it for their
own business.
Software malfunction:
No technology or human is perfect. In case of software or hardware crashes, it is difficult to
put a finger on what went wrong. On the other hand, tasks performed by humans can be
traced.
However, with machines and inbuilt algorithms in the picture, it is difficult to blame
someone or find the cause of a software/hardware crash. A recent example of this is the self-
driving cars that took the life of a pedestrian.
AI can’t replace every task:
Ever since AI made its way into our lives, we have a notion that all tasks, minute or a
gigantic, can be managed by artificial intelligence. However, this can be true to a certain
extent. But not all the tasks can be undertaken by AI.
AI is more like a tool that helps increase the productivity of a task. It has the ability to replace
all the worldly tasks with machines and lets you do more productive tasks with your time.
This is a tool that strengthens and boost the performance and efficiency of an average worker.
Higher expectations:
AI could have serious issues with the expectations of the people around. People, in general,
don’t have a detailed understanding of how AI works and hence they have extremely high
expectations; some of which are not even possible.
Humans have a tendency to expect high from something that is trending and the outputs from
it are also going to be excellent. However, like any other technology, there are certain
limitations associated with AI.
Experts belonging to various industries are pretty sure that artificial intelligence will rule the
next era, but there are some challenges that are a problem for artificial intelligence.
MGITER/CE/2018-19 Page 26
Artificial Intelligence (2180703) 150330107077
As a matter of fact, artificial intelligence has seen much hype in the market. However, AI is
still in its initial phase. After reading this blog, we hope you have a better idea about the
future of artificial intelligence.
Search engines are incredible. Its algorithms and a lot of ideas from a lot of brilliant people. And
we’ve started to wonder: with all the brilliant minds behind them, to what extent are search
engines using artificial intelligence?
Thanks to those same search engines, I was able to find some great research explaining how
search engines use artificial intelligence.
MGITER/CE/2018-19 Page 27
Artificial Intelligence (2180703) 150330107077
Google moved beyond keywords a few years ago. This process intensified as users
explored different devices to use for their searches.
For example, you can see a lot of variation between a voice search on a mobile device
and a text search on a desktop computer.
Artificial Intelligence helps search engines match their needs. Every need search adds a
data point to help them improve their understanding of how humans search the web.
The AI is getting so smart that even Google and Bing have trouble ranking their own
products first on search engines today.
As you can see from the search below for web analytics, Google Analytics ranks near the
bottom of the page.
This is a huge problem for Google as they had trouble competing on their own search
engine to rank higher. If Google struggles with this, it means other companies must be
even more on the ball if they want to get the search traffic they need for their business.
Experts agree it is vital to avoid keyword stuffing and other black hat strategies that no
longer work.
Instead, as Anil Agarwal from BloggersPassion.com said, “User intent is still a top
priority. If you’re not focusing on giving the best experience to your target audience
through your content, no matter what tactics you adopt, they are of no use.”
The best way to engage consumers is to write naturally. When you speak like a human,
people who search like humans find your content. This was a problem early on in search.
Users could stuff in some keywords and the gobbled gook that came up was enough to
fool Google’s search engine to rank them high.
Factors like location, date, time, and device make the intent of a search different for each
user.
If you research the new Star Wars movie from your desktop then you want to learn more
about the movie; check the reviews, see the trailer.
However, if you then check out the movie on your phone, it is more likely you want to
know where the nearest movie theatre is and the times for the movies.
This is the power of intent. It is the reason AI plays such a vital role in search engine
optimization today. The computer must read all these factors in addition to the searchers
query to come up with the best information.
MGITER/CE/2018-19 Page 28
Artificial Intelligence (2180703) 150330107077
It is not only enough to know the users’ intent for their search. They also want to know
what users want to do after they finish searching. For example, what do users do after
they go through your content?
For example, if you search for the phrase characters in game of thrones the first result is
Wikipedia.
This should not be surprising, because Wikipedia not only lists the Game of Thrones
characters. They also have links directly underneath this for secondary characters like the
High Sparrow and SibelKikelli (Shae) in the movie.
The importance here is that using Schema data Wikipedia is predicting what other titbits
of information is important to searchers.
Google wants sites that keep your attention. This means improving the time on site as
well as decreasing the bounce rate to your website.
Visitors who stay for 3-5 seconds and bounce off to another site are not valuable to
Google and you, because your content is not relevant or good enough for them to keep
looking at right now.
Think of sites you visit and 30 minutes later you wonder where all the time went? You
just went down the rabbit hole of great content on a website. Your site needs to deliver
this type of user experience.
Google uses this information to find how valuable your site is to users.
3. Understand the buyer cycle
If you want to get users excited about your content, then segment your content to specific
phases of the buying cycle.
Users typically go through three phases of the buying process: Curiosity, Interest, and
Decision. The names vary a little if you are reading about this on Hub Spot or Facebook.
However, the process is similar.
MGITER/CE/2018-19 Page 29