Professional Documents
Culture Documents
UNIT 1
➢ Introduction, History, Intelligent systems, Foundations of AI, Applications, tic-
tac-toe game playing, Development of AI languages, Current trends in AI
INTRODUCTION :
What is AI ?
Artificial Intelligence is concerned with the design of intelligence in an artificial device.
The term was coined by McCarthy in 1956.
What is intelligence?
Artificial intelligence is the study of systems that act in a way that to any observer would appear
to be intelligent.
Artificial Intelligence involves using methods based on the intelligent behaviour of humans
and other animals to solve complex problems.
History :
If AI is being here from over half a century ? Why it suddenly came an importance?
And why we are talking about AI now
Artificial Intelligence is not a new word and not a new technology for researchers. This
technology is much older than you would imagine. Even there are the myths of Mechanical
men in Ancient Greek and Egyptian Myths. Following are some milestones in the history of
AI which defines the journey from the AI generation to till date development.
Application of AI
Artificial Intelligence has various applications in today's society. It is becoming essential
for today's time because it can solve complex problems with an efficient way in multiple
industries, such as Healthcare, entertainment, finance, education, etc. AI is making our daily
life more comfortable and fast.
1. AI in Astronomy
Artificial Intelligence can be very useful to solve complex universe problems. AI
technology can be helpful for understanding the universe such as how it works, origin, etc.
2. AI in Healthcare
In the last, five to ten years, AI becoming more advantageous for the healthcare industry
and going to have a significant impact on this industry.
Healthcare Industries are applying AI to make a better and faster diagnosis than humans.
AI can help doctors with diagnoses and can inform when patients are worsening so that medical
help can reach to the patient before hospitalization.
3. AI in Gaming
AI can be used for gaming purpose. The AI machines can play strategic games like chess,
where the machine needs to think of a large number of possible places.
Following are some sectors which have the application of Artificial Intelligence:
4. AI in Finance
AI and finance industries are the best matches for each other. The finance industry is
implementing automation, chatbot, adaptive intelligence, algorithm trading, and machine
learning into financial processes.
5. AI in Data Security
The security of data is crucial for every company and cyber-attacks are growing very
rapidly in the digital world. AI can be used to make your data more safe and secure. Some
examples such as AEG bot, AI2 Platform,are used to determine software bug and cyber-attacks
in a better way.
6. AI in Social Media
Social Media sites such as Facebook, Twitter, and Snapchat contain billions of user
profiles, which need to be stored and managed in a very efficient way. AI can organize and
manage massive amounts of data. AI can analyze lots of data to identify the latest trends,
hashtag, and requirement of different users.
7. AI in Travel &Transport
AI is becoming highly demanding for travel industries. AI is capable of doing various travel
related works such as from making travel arrangement to suggesting the hotels, flights, and
best routes to the customers. Travel industries are using AI-powered chatbots which can make
human-like interaction with customers for better and fast response.
8. AI in Automotive Industry
Some Automotive industries are using AI to provide virtual assistant to their user for better
performance. Such as Tesla has introduced TeslaBot, an intelligent virtual assistant.
Various Industries are currently working for developing self-driven cars which can make
your journey more safe and secure.
9. AI in Robotics:
Artificial Intelligence has a remarkable role in Robotics. Usually, general robots are
programmed such that they can perform some repetitive task, but with the help of AI, we can
create intelligent robots which can perform tasks with their own experiences without pre-
programmed.
Humanoid Robots are best examples for AI in robotics, recently the intelligent Humanoid
robot named as Erica and Sophia has been developed which can talk and behave like humans.
10. AI in Entertainment
We are currently using some AI based applications in our daily life with some
entertainment services such as Netflix or Amazon. With the help of ML/AI algorithms, these
services show the recommendations for programs or shows.
11. AI in Agriculture
Agriculture is an area which requires various resources, labor, money, and time for best
result. Now a day's agriculture is becoming digital, and AI is emerging in this field. Agriculture
is applying AI as agriculture robotics, solid and crop monitoring, predictive analysis. AI in
agriculture can be very helpful for farmers.
12. AI in E-commerce
AI is providing a competitive edge to the e-commerce industry, and it is becoming more
demanding in the e-commerce business. AI is helping shoppers to discover associated products
with recommended size, color, or even brand.
13. AI in education:
AI can automate grading so that the tutor can have more time to teach. AI chatbot can
communicate with students as a teaching assistant.
AI in the future can be work as a personal virtual tutor for students, which will be accessible
easily at any time and any place.
#include<bits/stdc++.h>
using namespace std;
#define COMPUTER 1
#define HUMAN 2
#define SIDE 3 // Length of the board
// Computer will move with 'O' and human with 'X'
#define COMPUTERMOVE 'O'
#define HUMANMOVE 'X'
// A function to show the current board status
void showBoard(char board[][SIDE])
{
printf("\n\n");
printf("\t\t\t %c | %c | %c \n", board[0][0], board[0][1], board[0][2]);
printf("\t\t\t--------------\n");
printf("\t\t\t %c | %c | %c \n", board[1][0], board[1][1], board[1][2]);
printf("\t\t\t--------------\n");
printf("\t\t\t %c | %c | %c \n\n", board[2][0], board[2][1], board[2][2]);
return;
}
// A function to show the instructions
void showInstructions()
{
printf("\t\t\t Tic-Tac-Toe\n\n");
printf("Choose a cell numbered from 1 to 9 as below" " and play\n\n");
printf("\t\t\t 1 | 2 | 3 \n");
printf("\t\t\t--------------\n");
printf("\t\t\t 4 | 5 | 6 \n");
printf("\t\t\t--------------\n");
printf("\t\t\t 7 | 8 | 9 \n\n");
printf("-\t-\t-\t-\t-\t-\t-\t-\t-\t-\n\n");
return;
}
// A function to initialise the game
void initialise(char board[][SIDE], int moves[])
{
// Initiate the random number generator so that the same configuration doesn't arises
srand(time(NULL));
// Initially the board is empty
for (int i=0; i<SIDE; i++)
{
for (int j=0; j<SIDE; j++)
board[i][j] = ' ';
}
// Fill the moves with numbers
for (int i=0; i<SIDE*SIDE; i++)
moves[i] = i;
// randomise the moves
random_shuffle(moves, moves + SIDE*SIDE);
return;
}
// A function to declare the winner of the game
void declareWinner(int whoseTurn)
{
if (whoseTurn == COMPUTER)
printf("COMPUTER has won\n");
else
printf("HUMAN has won\n");
return;
}
// A function that returns true if any of the row is crossed with the same player's move
bool rowCrossed(char board[][SIDE])
{
for (int i=0; i<SIDE; i++)
{
if (board[i][0] == board[i][1] &&
board[i][1] == board[i][2] &&
board[i][0] != ' ')
return (true);
}
return(false);
}
// A function that returns true if any of the column is crossed with the same player's move
bool columnCrossed(char board[][SIDE])
{
for (int i=0; i<SIDE; i++)
{
if (board[0][i] == board[1][i] &&
board[1][i] == board[2][i] &&
board[0][i] != ' ')
return (true);
}
return(false);
}
// A function that returns true if any of the diagonal is crossed with the same player's move
bool diagonalCrossed(char board[][SIDE])
{
if (board[0][0] == board[1][1] &&
board[1][1] == board[2][2] &&
board[0][0] != ' ')
return(true);
if (board[0][2] == board[1][1] &&
board[1][1] == board[2][0] &&
board[0][2] != ' ')
return(true);
return(false);
}
// A function that returns true if the game is over else it returns a false
bool gameOver(char board[][SIDE])
{
return(rowCrossed(board) || columnCrossed(board)
|| diagonalCrossed(board) );
}
// A function to play Tic-Tac-Toe
void playTicTacToe(int whoseTurn)
{
// A 3*3 Tic-Tac-Toe board for playing
char board[SIDE][SIDE];
int moves[SIDE*SIDE];
// Initialise the game
initialise(board, moves);
// Show the instructions before playing
showInstructions();
int moveIndex = 0, x, y;
// Keep playing till the game is over or it is a draw
while (gameOver(board) == false && moveIndex != SIDE*SIDE)
{
if (whoseTurn == COMPUTER)
{
x = moves[moveIndex] / SIDE;
y = moves[moveIndex] % SIDE;
board[x][y] = COMPUTERMOVE;
printf("COMPUTER has put a %c in cell %d\n", COMPUTERMOVE, moves[moveIndex]+1);
showBoard(board);
moveIndex ++;
whoseTurn = HUMAN;
}
else if (whoseTurn == HUMAN)
{
x = moves[moveIndex] / SIDE;
y = moves[moveIndex] % SIDE;
board[x][y] = HUMANMOVE;
printf ("HUMAN has put a %c in cell %d\n", HUMANMOVE, moves[moveIndex]+1);
showBoard(board);
moveIndex ++;
whoseTurn = COMPUTER;
}
}
1 | 2 | 3
--------------
4 | 5 | 6
--------------
7 | 8 | 9
- - - - - - - - - -
| |
--------------
| | O
--------------
| |
HUMAN has put a X in cell 7
| |
--------------
| | O
--------------
X | |
COMPUTER has put a O in cell 5
| |
--------------
| O | O
--------------
X | |
HUMAN has put a X in cell 1
X | |
--------------
| O | O
--------------
X | |
COMPUTER has put a O in cell 9
X | |
--------------
| O | O
--------------
X | | O
HUMAN has put a X in cell 8
X | |
--------------
| O | O
--------------
X | X | O
COMPUTER has put a O in cell 4
X | |
--------------
O | O | O
--------------
X | X | O
COMPUTER has won
AI Programming Languages
Java, Python, Lisp, Prolog, and C++ are major AI programming language used for
artificial intelligence capable of satisfying different needs in the development and
designing of different software.
Python
Python (official website) is among developers favorites programming
languages in AI development because of its syntax simplicity and versatility.
Python is very encouraging for machine learning for developers as it is less
complex as compared to C++ and Java. It also a very portable language as it
is used on platforms including Linux, Windows, Mac OS, and UNIX. It is
also likable from its features such as Interactive, interpreted, modular,
dynamic, portable and high level which make it more unique than Java.
Advantages
Drawbacks
C++
C++ is the fastest computer language, its speed is appreciated for AI
programming projects that are time sensitive. It provides faster execution
and has less response time which is applied in search engines and
development of computer games. In addition, C++ allows extensive use of
algorithms and is efficient in using statistical AI techniques. Another
important factor is that C++ supports re-use of programs in development due to inheritance and
data-hiding thus efficient in time and cost saving.
Advantages
Drawbacks
• Poor in multitasking; C++ is suitable only for implementing core or the base of specific
systems or algorithms.
• It follows the bottom-up approach thus, highly complex making it hard for newbies
developers at using it for writing AI programs.
Java
Java (official website) is another programming language to answer ‘which
computer language is used for artificial intelligence?’ Java is also a multi-
paradigm language that follows object-oriented principles and the principle of
Once Written Read/Run Anywhere (WORA). It is an AI programming language
that can run on any platform that supports it without the need for recompilation.
Java is one of the most commonly used and not just in AI development. It derives a major part
of its syntax from C and C++ in addition to its lesser tools that them. Java is not only appropriate
for NLP and search algorithms but also for neural networks.
Advantages
• Very portable; it is easy to implement on different platforms because of Virtual
Machine Technology.
• Unlike C++, Java is simple to use and even debug.
• Has an automatic memory manager which eases the work of the developer.
Disadvantages
• Java is, however, slower than C++, it has less speed in execution and more response
time.
• Though highly portable, on older platforms, java would require dramatic changes on
software and hardware to facilitate.
• Java is also a generally immature programming AI language as there are still some
developments ongoing such as JDK 1.1 in beta.
LISP
LISP is another language used for artificial intelligence development. It is
a family of computer programming language and is the second oldest
programming language after Fortran. LISP has developed over time to
become strong and dynamic language in coding.
Some consider LISP as the best AI programming language due to the favour of liberty
it offers developers. LISP is used in AI because of its flexibility for fast in prototyping and
experimentation which in turn facilitate LISP to grow to a standard AI language. For instance,
LISP has a unique macro system which facilitates exploration and implementation of different
levels of Intellectual Intelligence.
Advantages
Drawbacks
Prolog
Prolog is also one of the oldest programming languages thus also suitable for
the development of programming AI. Like Lisp, it is also a primary computer
language for artificial intelligence. It has mechanisms that facilitate flexible
frameworks developers enjoy working with. It is a rule-based and declarative
language as it contains facts and rules that dictate its artificial intelligence
coding language.
Prolog supports basic mechanisms such as pattern matching, tree-based data structuring, and
automatic backtracking essential for AI programming. Other than its extensive use in AI
projects, Prolog is also used for creation of medical systems.
Advantages
• Prolog has a built-in list handling essential in representing tree-based data structures.
• Efficient for fast prototyping for AI programs to be released modules frequently.
• Allows database creation simultaneous with running of the program.
Drawbacks
• Despite prolog old age, it has not been fully standardized in that some features differ in
implementation making the work of the developer cumbersome.
Current Trends in AI
1) Reinforcement Learning and its real-world applications
2) Deep Learning Optimisation
3) Deep Learning Applications
4) Meta Learning
5) Sequential Modeling
6) Machine Learning Optimization
7) Generative Models Applications
8) Natural Language Generation Architectures
9) Efficient Online Learning
10) Graph based algorithms