Example of prolog, Computer Engineering

Assignment Help:

Example of Prolog:

We can say that this is also true if there are four even numbers. Now we have our first rule:

• If there are three or four even numbered cards, such player one should choose the highest even numbered card in their first go probably.

Whenever there are three or four odd cards it's not difficult to see that the most rational action for player one is to choose the highest odd numbered card:

• If there are three or four odd numbered cards, such player one should choose the highest odd numbered card in their first go. The only other situation is when there are two even and two odd cards. However, this case, I'll leave it as an exercise to convince yourselves that there are no rules governing the choice of player one's first card: they can simply choose randomly, it means that they're not going to win unless player two makes a mistake.

Just to write an expert system to decide what type card to choose in a game, that we will require to translate our rules into first-order logic, then into a Prolog implementation. Now in our first rule states such in a game, eg:

2395_Example of Prolog.png


There is the meaning of the predicates is as obvious as it seems. Correspondingly our second rule can be written like:

2147_Example of Prolog1.png


So there are many different ways to encode these rules as a Prolog program but different implementations will differ in their execution time. Just for our simple program, there it doesn't truly matter that predicates we choose to implement. If we will make our top level predicate as:

player_one_chooses/2.

Than the predicate will take a list of card numbers such the first argument, it will choose a member of this list to put as the second argument. In fact in this way, there the same predicate can be used in order to make second choices.


Related Discussions:- Example of prolog

Two different ways of building a match code object, What are the two differ...

What are the two different ways of building a match code object? A match code can be built in two dissimilar ways: Logical structure: The matchcode data is set up not pe

Reading decision trees - artificial intelligence, Reading Decision Trees ...

Reading Decision Trees There is a link between decision tree representation and logical representations, which may be exploited to form it more easy  to understand and learned

What is matrix addressing mode, What is Matrix Addressing Mode. Ans. M...

What is Matrix Addressing Mode. Ans. Matrix Addressing Mode: The arrangement which needs the fewest address lines is a square array of n rows and n columns for a whole memory

Define deadlock with resource request and allocation graph, Define Deadlock...

Define Deadlock with Resource request and allocation graph (RRAG) Deadlocks can be described through a directed bipartite graph termed as a RRAG that is Resource Request All

Objectives of information distribution, Objectives After studying this ...

Objectives After studying this unit you should be able to: 1. list various types of reprographic methods, 2. describe uses of various kinds of typewriters, 3. explain

Write a program to input an address, Write a program to input an address i....

Write a program to input an address i.e. 20 Hex and read the byte (char) contents of that address   Answer   include void main() { char prompt; Date: 26th August 2012

What is error checking, What is error checking? It computes the error c...

What is error checking? It computes the error correcting code (ECC) value for the data read from the given sector and compares it with the corresponding ECC value read from the

In which page replacement policies balady’s anomaly occurs, In which page r...

In which page replacement policies Balady’s anomaly occurs? FIFO that is First in First Out.

Intuitively simple - user friendliness, Intuitively Simple - User Friendlin...

Intuitively Simple - User Friendliness This is the degree to which the system operates in congruence with human operation, in effect the machine does what we naturally think i

Why we need to construct state transition diagram, Why we need to construct...

Why we need to construct state transition diagram Basically you need to construct a state transition diagram for each object with important behaviour. You need not construct on

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd