Running a trader

next up previous
Next: What facts does act need?
Up: The game of Traveller (PP)
Previous: Trading
Back: to main list of student notes

Running a trader

Now, please do the following. Start up Prolog, then do

This will load the software which implements the game. Now do

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 displayed in 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 you call run, it starts by asserting some clauses which describe the trader's state. These are:

The name T of the trader is the first argument to run. So for run(trader,67), you get clauses

Note that, apart from carries, there is only one clause of each kind.

Having done this, run 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 I have written for act: to play Traveller, you must write some for your trader.

When act is called, it must set Action to one of move, buy, or sell. If Action is move, Arg1 must become the next square to move to, and Arg2 must become the atom dummy. If Action is buy or 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.

next up previous
Next: What facts does act need?
Up: The game of Traveller (PP)
Previous: Trading
Back: to main list of student notes

Jocelyn Paine
Tue Jun 4 17:58:48 BST 1996