# [i7] Voyage time (AKA Distance and Duration)

In my game you can sail your yacht between London, Le Havre and New York.

This works on a timer so that once x number of turns have elapsed from departure, the player is informed they have arrived and can exit the yacht and enter a new location.

Up until now I have used a very basic method defining how many game-turns it takes to travel between each destination, but I need to do something better to cope with the following:

1. If the player decides to change their destination partway through a trip, I need to determine what the transit time is from any point on their current route. Likewise, if they turn back to their starting point, or decide to take up the original destination again.

2. If I want to add new destinations, the current method involves adding a new “travel from point A to point D” entry, a “travel from point B to point D” entry, and a “travel from point C to point D” entry, etc.

3. If you change the speed of the yacht, transit time should be increased or decreased, or suspended if you stop at anchor.

(As an aside, the travel times are nowhere near realistic, and the player will spend the time on internal mysteries that open up within the yacht as they travel. No one has to sit at the keyboard with nothing to do but press ‘z’ for a week!)

I have a vague thought that perhaps the first two problems could be solved by using some kind of coordinate system and having the game calculate where you are with a journey time counter.

Any ideas? Is there some handy extension already covering this issue?

If you want some basic realism in terms of “I went most of the way to X but now want to go back to Y” taking twice as long, you can use a very basic coordinate system.

Table of Coordinates
place    x    y
[put your data here]

The current x coordinate is a number variable.
The current y coordinate is a number variable.

To take one step toward (the destination - a room):
choose a row corresponding to a place of (the destination) in the Table of Coordinates;
if the current x coordinate is less than the x entry, increment the current x coordinate;
if the current x coordinate is greater than the x entry, decrement the current x coordinate;
if the current y coordinate is less than the y entry, increment the y coordinate;
if the current y coordinate is greater than the y entry, decrement the current y coordinate;
if the current x coordinate is the x entry and the current y coordinate is the y entry:
say "You have arrived!";
move the player to the destination.

To set coordinates from the current location:
choose a row with a place entry of the location in the Table of Coordinates;
now the current x coordinate is the x entry;
now the current y coordinate is the y entry.
1 Like