With these predicates, can you define a version of
act that drives a
coal-trader round the Colliery Row circle? It will be like
except that if he stops at a coal merchant, he should buy or sell as
appropriate. It is possible to make very complicated rules when trying
to squeeze out the maximum possible profit. Don't bother with that yet;
you probably don't know enough Prolog anyway. Just have him buy a fixed
amount at each wholesaler, if his lorry is empty; and sell a fixed
amount to each retailer, if his lorry is not empty. You can ignore the
need to buy fuel for the moment.
One possible solution is in the file COLLIER. I have pre-calculated the amount of coal to buy on each cycle. Later, you can try to build a more adaptable trader.