Author Topic: Distance Finder for Simutrans Suggestion  (Read 2900 times)

0 Members and 1 Guest are viewing this topic.

Offline rdepass

Distance Finder for Simutrans Suggestion
« on: May 10, 2016, 05:31:34 AM »
  Please forgive my very bad C. The following came from an idea I had whilst playing your game. For some reason I can't remember I wanted to know how many Simu-km it was from one town hall to another. Following is a badly written code for applying the pythagorean theorem: a² + b² = c² which would allow me to click on a townhall for example, click another town hall and know that it is x simu-km away. The measurement of moving objects is far too difficult for me to comprehend, and this code is definitely not for that function.
If anyone would like to use this to make the Distance Finder tool, please do so if you think it would be useful and if it is not too much hard work. If you make it into an app for satnav devices and make loads of money, I want half! lol

Distance Finder for Simutrans

 
*The following code is for adaptation into a version that actually works in the Simutrans environment. My coding skills leave a lot to be desired!

 
*call libs
void main
include # lib1, lib2, etc. ...;

 
*define variables
* I don't know if these are all necessary

 
Mapsize = &Mapsize
Xco = &mouseinput1xcoords
Yco = &mouseinput1ycoords
Xco1 =&mouseinput2ycoords
Yco1 = &mouseinput2ycoords
StartPoint = &StartPoint (&mouseinput1xcoords, &mouseinput1ycoords);
EndPoint = &EndPoint (&mouseinput2ycoords, &mouseinput2ycoords);
Distance = &Distance

 
printf “Click where are you measuring from?” ;
scanf  &StartPoint
printf “Click where you want to know the distance to?”;
scanf  &EndPoint
*I don't know how to say scanf for mouses

 
For

 
Distance = StartPoint = (Xco * Xco = Xco²);
         EndPoint = (Yco * Yco = Yco²);
 √(Xco² + Yco²) = &Distance
* I don't know how to say square root, I imagine it is a function in a maths lib somewhere


 
printf “Distance is: &Distance Simu-Kilometres

 
void main

Offline DrSuperGood

Re: Distance Finder for Simutrans Suggestion
« Reply #1 on: May 10, 2016, 04:41:39 PM »
That hard part is making the in game tool and not the underlying calculations. Being software engineers such calculations are trivial to make.

The big question is if distance should be Euclidian or Manhattan? Payment and travel cost between locations follows Manhattan distance, which is basically the sum of X and Y delta. I am unsure if movement is Euclidian or not however.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: Distance Finder for Simutrans Suggestion
« Reply #2 on: May 10, 2016, 06:46:21 PM »
I am unsure if movement is Euclidian or not however.

Since the length of diagonals is up to the pak set and advanced players, it is at most optionally Euclidian.

Offline rdepass

Re: Distance Finder for Simutrans Suggestion
« Reply #3 on: May 10, 2016, 10:54:45 PM »
"The hard part is making the in game tool and not the underlying calculations"
I totally agree! I was reading in another post that the code is very convoluted, mixed up and not at all streamlined in terms of most modern programming. If it were, however, where would I go for my 'sheeps'? This game is great!

"The big question is if distance should be Euclidian or Manhattan?"
Euclidian for Distance, Manhattan for Journey Length

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8830
  • Total likes: 324
  • Helpful: 229
  • Languages: De,EN,JP
Re: Distance Finder for Simutrans Suggestion
« Reply #4 on: August 04, 2016, 09:09:12 PM »
Such a tool would be very easy to write, since there is the two click tool already there.

But more useful might be such a tool for actual distance for convoys ...

Offline isidoro

Re: Distance Finder for Simutrans Suggestion
« Reply #5 on: August 04, 2016, 11:37:47 PM »
Maybe it isn't necessary to program a separate tool.  Now, when using some two click tools, the coordinates of origin (and perhaps destination when hovering the mouse) are printed.  Adding the distance information there could suffice.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: Distance Finder for Simutrans Suggestion
« Reply #6 on: August 05, 2016, 05:23:56 AM »
Such a tool would be very easy to write, since there is the two click tool already there.

But more useful might be such a tool for actual distance for convoys ...

Isn't that also mostly done already in two-click tools like add/remove electrification and remove track?

Maybe it isn't necessary to program a separate tool.  Now, when using some two click tools, the coordinates of origin (and perhaps destination when hovering the mouse) are printed.  Adding the distance information there could suffice.

Players may not be too happy about accidentally doings stuff if they fail to cancel the tool.

Offline Ves

Re: Distance Finder for Simutrans Suggestion
« Reply #7 on: August 05, 2016, 09:19:57 PM »
I would find it usefull to find the distance my vehicle would have to travel as well as the actual distance between two points. This way, you can see how efficient your infrastructure is constructed in terms of detours.

Offline Isaac.Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3440
  • Total likes: 332
  • Helpful: 91
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Re: Distance Finder for Simutrans Suggestion
« Reply #8 on: August 06, 2016, 02:55:01 AM »
I would find it usefull to find the distance my vehicle would have to travel as well as the actual distance between two points. This way, you can see how efficient your infrastructure is constructed in terms of detours.

That sounds extremely handy. Also to see how Simutrans would route it in case of surprises. :)

Offline DrSuperGood

Re: Distance Finder for Simutrans Suggestion
« Reply #9 on: August 06, 2016, 04:02:01 AM »
It would also be useful if all distance moved by a convoy cost money. You get free distance moved when convoys turns around or are displaced, especially visible with long trains at terminal stations. This makes through stops less efficient for multi-tile convoys as the convoy has to travel what is potentially free distance at a cost.

Offline Blacksmoker

Re: Distance Finder for Simutrans Suggestion
« Reply #10 on: August 06, 2016, 11:58:37 PM »
As far as I can tell from the source code that I found for routing, some kind of track keeping of the total length of the route is already done internally. Sadly, I'm not really that good with C++, but it seems like it should be not too complicated to make a tool which can be told what kind of waytype I want to use and to set a start and endpoint so it searches for a route in the same manner as it would for a vehicle.
Of course it may also be that I am completely mistaken there, I haven't spend that much time looking at this code, but I really would like to have such a tool as well.

Another good reason for this tool would also be to optimize the transport capacity on a certain line, since one can match the number of vehicles on a line depending on their speed, loading capacity and the distance they actually travel to get from some factory to their destination. For that purpose a result in tiles would be best, as the productivity is given in units/month and the speed can easily be calculated for tiles/month.