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...

Idle Solar Defence Policy

  Privacy Policy This privacy policy applies to the Idle Solar Defence app (hereby referred to as "Application") for mobile devices that was created by krg (hereby referred to as "Service Provider") as a Free service. This service is intended for use "AS IS". Information Collection and Use The Application collects information when you download and use it. This information may include information such as Your device's Internet Protocol address (e.g. IP address) The pages of the Application that you visit, the time and date of your visit, the time spent on those pages The time spent on the Application The operating system you use on your mobile device The Application does not gather precise information about the location of your mobile device. The Service Provider may use the information you provided to contact you from time to time to provide you with important information, required notices and marketing promotions. For a better experience, while using ...

Build A Family Privacy

  Privacy policy This Service is provided by KRG at no cost and is intended for use as is. This page is used to inform visitors regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our Service. If you choose to use our Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that we collect is used for providing and improving the Service. We will never sell your information, and 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. Information Collection and Use For a better experience, while using our Service, we may require you to provide us with certain personally identifiable information, including but not limited to IDFA. The information that we request will be retained by us and used as described in this privacy policy. The a...