User:Taneb/Salesman

From Esolang
Jump to navigation Jump to search

Draft copy The program is made up of a series of nodes with integer co-ordinates on the cartesian plane.

The shortest route going through each of these nodes is then calculated, and the squares of the distances between them (in some order) are executed as following:

First, the current value mod n is calculated:

0    adds the two accumulators together, storing the result in the right accumulator, then resets the left
1    resets the right accumulator
2    adds the square of the distance just travelled, minus 2, divided by n to the left accumulator
3    changes the distance between the current node and the node that would be visited in (left accumulator) steps to the square root of the
     right accumulator. Changing the distance from a node to itself does nothing. This does not change co-ordinates at all, nor does it affect
     any other distances
4    creates a new node at the coordinate (left accumulator, right accumulator)
5    deletes the node that would have been visited in (right accumulator) steps, unless that would be the current node
6    reverses direction and skip next node
7    if the left accumulator is odd, output the right accumulator. If it is even, set the right accumulator to input.
8    halt

Whenever a node is created or destroyed, or a distance is changed, the shortest path is recalculated. Travel begins anti-clockwise (as it is initially purely cartesian, this should be well defined, the only exception being straight lines, in which case it takes the route which is initially shorter, i.e., down the line as is expected.), starting in the one closest to (0,0) and continues as such until reversed. The direction can be worked out as, after any instruction, either the node that would be gone to next or the node that was previous will still be connected.

Random thoughts

build road build wall sell type a buy type a sell type b buy type b conditional reverse make node output goods input cash

Cities will sacrifice one of the goods type they have more of to create two of the other type every tick until they are equal, after which they will remain the same.

When buying goods, the salesman spends half of his money, rounded down to the nearest whole good. This means, if goods are REALLY expensive, the salesman may not be able to buy anything. When selling, the salesman sells half of the goods he has, rounded upwards.

The price when buying is roughly proportional to the inverse of the number of that good the town has, and when selling is roughly proportional to the number they have.

Roads require an amount of good type a proportional to the distance between the cities, and walls require a fixed amount of goods type b.

Building cities requires goods type a and goods type b in equal amounts.

Writing programs in Salesman is exceedingly difficult, but the language is believed Turing Complete.

Execution continues until the halt instruction is reached.