Skip to main content

HOW TO SOLVE AI PROBLEMS AND THINK LIKE COMPUTER?

Date : 08/02/2020

Many AI problems are hard to solve because they are difficult to be characterized. Not only the problem but a path to the solution is also hard to be characterized. While considering chess game ,
If we go and write every chess move, we may not be able to complete it in our lifetime.

Solving AI Problems

The first problem is called 3-4 gallon water jug problem as described in the book by Elaine Rich. We
begin with two empty jugs of the capacity of 3 and 4 gallons respectively. We have an infinite supply of water available and we want the 4-gallon jug to be filled with exactly 2 gallons of water.
Another problem is called 8-5-3 milk jug problem which begins with 8-gallon milk jug completely full while other two are empty. We want exactly 4 gallons of milk in the 8-gallon jug.

In either case, there are no other measuring devices available to us.

One solution for the first problem is

0-0, 0-4, 3-1, 0-1, 1-0, 1-4, 3-2.

(Where n-m indicates quantity of water in 3 and 4-gallon jugs respectively)

One solution to the second problem is

8-0-0, 3-5-0, 3-2-3, 6-2-0, 6-0-2, 1-5-2, 1-4-3, 4-4-0.

Where n-m-l are respective volumes of milk in 8, 5 and 3-gallon jugs.

Applying rules to solve the problem

Now let us see the sequence of rules applied for the solution.

Consider 8-5-3 as (X-Y-Z)

1. 8-0-0 -> 3-5-0 ( X+Y =8 > 5)

2. 3-5-0 -> 3-2-3 ( Y + Z = 5 > 3)

3. 3-2-3 -> 6-2-0 ( X +Z =6)

4. 6-2-0 -> 6-0-2 ( Y+Z = 2 < 3)

5. 6-0-2 -> 1-5-2 ( X + Y = 6 >5)

6. 1-5-2 -> 1-4-3 ( Y + Z = 7 > 3)

7. 1-4-3 -> 4-4-0 ( X + Z =4)

4-4-0 is a final state.

We have an initial state called (8,0,0), we apply a typical rule, record the new status, apply another rule and again look at the status and continue until we reach a state which is qualified as a final state.



code for above question is given :-

FIRST CODE OF AI


#include<iostream>
using namespace std;

int main()
{
int limX = 8, limY = 5, limZ = 3;
int x = 8, y = 0, z = 0;
int a,b,c;
for(int i = 0; i < 2; i++)
{
// Minus water from x
if((x - (limY - y)) >= 0)
{
a = x - (x - (limY - y));
y += a; // Add Required water
x -= a;
}
else
{
y += x;
x = 0;
}

if((y - (limZ - z)) >= 0)
{
b = y - (y - (limZ - z));
z += b;
y -= b;
}
else
{
z += y;
y = 0;
}

if((z - (limX - x)) >= 0)
{
c = z - (z - (limX - x));
x += c;
z -= c;
}
else
{
x += z;
z = 0;
}
if(i>0)
{
break;
}
else
{

z = y;
y = 0;
}

}

cout<<x<<y<<z;
}

Comments

Popular posts from this blog

Rinku privacy policy

Privacy Policy krg built the Rinku app as a Free app. This SERVICE is provided by krg at no cost and is intended for use as is. This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service. If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy. The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at Rinku unless otherwise defined in this Privacy Policy. Information Collection and Use For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retained on your device and is not...

first blog

date : 08/02/2020 I created my first blog today. I completed 1st module of artificial intelligence and started module 2. In module 1 introduction to AI is given. AI has many definitions associated with it. The AI  is a way of solving difficult problems. Difficult problems which are done by humans, like brushing teeth, brushing is very complicated process to be done by robot. If power is low or high it can not do work . It is the first time I think how chess game in android works. there are infinite numbers of moves to play. But with help of AI it is actually working . Old chess games at high difficulty level were taking so much time to play one move but now it takes only few seconds.           Humans are able to guess and work. but a program can not do that easily. Programs works  stepwise.    

HOW TO USE GITHUB ? WHAT IS GITHUB ? EVERYTHING YOU NEED TO KNOW ABOUT GITHUB.

DATE :- 09/02/2020 Today, I created  GitHub  account in my PC. it's name is krg72 you can find me there. I was not knowing what is  GitHub . Then I find some information from google . This blog is to give information about  GitHub  properly. Just read it and you will understand why and how  GitHub  is used. In this blog, you will learn: Introduction to GitHub Create repository in GitHub issues extras What is GitHub? Many people come to GitHub because they want to contribute to open source  projects, or they're invited by teammates or classmates who use it for their projects.  Why do people use GitHub for these projects? At its heart, GitHub is a collaboration platform. From software to legal documents, you can count on GitHub to help you do your best work with the collaboration and security tools your team needs. With GitHub, you can keep projects completely private, invite the world to collaborat...