Now, please do the following. Start up Prolog, then do
This will load the software which implements the game. Now do
library(trader).This loads code which defines a particular kind of trader. Finally, type the question
run( trader, 67 ).
The game will start by giving the display below. The fuel and tank size
are written out in
units; each trader begins with a full tank. Initial cash is
£5000, and initial loads are all zero. The total load is
cubic feet, and the stock of each good is displayed both in units and in
cubic feet, using
unit_volume to provide conversion factors.
trader is on square 67. Fuel 20 in tank size 20. Cash 5000. Total load 0 cu ft in lorry size 1000. Stock of televisions = 0 units (0 cu ft). Stock of peaches = 0 units (0 cu ft). Stock of glasses = 0 units (0 cu ft). Stock of diamonds = 0 units (0.0 cu ft). Stock of coal = 0 units (0 cu ft).
As the game continues, you will see a summary of the actions the trader takes at each turn, and the result on his fuel, cash, position, and stocks. Wait until the trader makes his way to The Hub, and has gone through a few cycles of buying and selling; when you have seen enough, you can interrupt the game.
Now, how can you write a trader of your own? Well, when
starts by asserting some clauses which describe the trader's
state. These are:
at(T,Square): T is the name of the trader, and Square is the number of the square he is on. This always starts off as the second argument to
carries(T,Good,Qty): T is the name of the trader, Good is the name of one of his goods (
televisions) and Qty is the number of units he has.
cash(T,Cash): T is the name of the trader, and Cash is the amount of cash he has.
fuel(T,Qty): T is the name of the trader, and Qty is the number of units of fuel he has.
max_load(T,Vol): T is the name of the trader, and Vol is the maximum volume his lorry can hold. In this version of Traveller, it is 1000 cubic feet.
tank_size(T,Qty): T is the name of the trader, and Qty is the maximum number of units he can get into his tank. In this version of Traveller, it's 20.
total_load(T,Vol): T is the name of the trader, and Vol is the total load in cubic feet.
The name T of the trader is the first argument to
run. So for
run(trader,67), you get clauses
at(trader,67). cash(trader,5000). fuel(trader,20). carries(trader,coal,0). carries(trader,diamonds,0). carries(trader,glasses,0). carries(trader,peaches,0). carries(trader,televisions,0). max_load(trader,1000). tank_size(trader,20). total_load(trader,0).Note that, apart from
carries, there is only one clause of each kind.
Having done this,
then tries to find out what the trader's first action is to be. Will he
move to a new square, buy something, or sell something? It
does so by calling (i.e. by asking itself the question)
where T is the name of the trader. The file TRADER contained clauses
have written for
act: to play Traveller, you must write some for
act is called,
it must set Action to one of
sell. If Action is
move, Arg1 must become the next square to move to, and Arg2 must
become the atom
dummy. If Action is
sell, Arg1 must become
the name of a good, and Arg2 must become the quantity in units that is
to be bought or sold. Finally, if Action is
buy, Arg1 can also be
fuel. In this case, the trader is buying fuel, not a good for resale.