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

IEEE802, 1. (a) Given a baseband bus with station 1 located at 10m, station...

1. (a) Given a baseband bus with station 1 located at 10m, station 2 located at 1000m, and station 3 located at 1010 meters (see diagram above). If the data rate of the bus is 10 M

Describe in brief about the internet, Describe in brief about The internet ...

Describe in brief about The internet Web sites need to be set up to maximise information supplied to customers and to ensure they are as self-contained and helpful as possible.

What is the function of cu, What is the function of CU? The control uni...

What is the function of CU? The control unit works as the nerve center that coordinates all the computer operations. It issues timing signals that governs the data transfer.

Learning weights in perceptrons, Learning Weights in Perceptrons: Furt...

Learning Weights in Perceptrons: Furthermore details are we will look at the learning method for weights in multi-layer networks next lecture. Thus the following description o

What are the modes in which any update tasks work, What are the modes in wh...

What are the modes in which any update tasks work? Synchronous and Asynchronous.

What is friend function in c++, As the name suggests, the function acts as ...

As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private & protected members. A friend function is not a member of the clas

Explain about interrupt-processing sequence, Q. Explain about Interrupt-Pro...

Q. Explain about Interrupt-Processing Sequence? The occurrence of an interrupt fires a numbers of events both in processor hardware and software. Figure below displays a sequen

What are the advantages of code optimization, What are the advantages of co...

What are the advantages of code optimization? Code optimization tends at enhancing the execution efficiency of a program. It is achieved in two manners. Redundancies in a progr

How to detect overflow condition, How to detect overflow condition An o...

How to detect overflow condition An overflow condition can be notice by observing the carry into the sign bit position and the carry out of sign bit position. If this carries a

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