Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri Jun 23, 2017 10:32 am

All times are UTC




Post new topic  Reply to topic  [ 134 posts ]  Go to page Previous 13 4 5 6 7
Author Message
PostPosted: Tue Jun 13, 2017 4:25 am 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
Thanks supermop, that confirmed what i thought so far. At least you saved me from having to do trial and error.


Top
   
PostPosted: Tue Jun 13, 2017 4:16 pm 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2533
Cadde wrote:
IIRC, 2cc trainset (the non NML version) had variable running costs based on current consist speed. If the vehicle was stopped, running costs were low whereas if the consist went faster than one of it's wagons design speeds (required wagon speed limits to be off), running costs would exponentially increase with overspeeding.
Is there any chance of this happening in the NML version?

While the most recent versions do have the code restructured to make adding such a feature more trivial, I have no intention to add such a feature at this moment. Personally I do not see the big added value.

Quote:
Or, can someone better versed in NML explain to me how to set up that particular callback because i looked around and the documentation is unclear at best on that particular subject. I.E, where does the declaration for "running_cost_factor" go when one wants to use a callback? I assume in the "graphics" block.
And how do i access the current vehicle speed from within the callback?

But if you really want, supermop has given a nice explanation on what it should look like, although I prepared the code in this set to have those pieces of code hidden behind some #defines from C/make, to allow a single point of definition.

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Tue Jun 13, 2017 7:03 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
Transportman wrote:
While the most recent versions do have the code restructured to make adding such a feature more trivial, I have no intention to add such a feature at this moment. Personally I do not see the big added value.

I am not forcing anyone's hand here. But allow me to explain why it's useful or at least how it can add to gameplay. Of course, everyone has their own tastes and desires so we should all keep that in mind.

When your profit margins largely rely on whether you deliver some cargo in a timely manner. Say you only have 100 days of transport before you are being paid nickles rather than gold bars for your delivery. Then you are bound to have some trains just waiting around for the opportune moment to deliver that cargo.
While these trains are waiting (not loading, because then the cargo time ticker will tick) they are still costing just as much as they do transporting the cargo. So one could just send them more frequently instead and ignore the fact they don't carry that much cargo at the time.
This ofc also applies to transfers of cargo, where one train is waiting for another to arrive before departing.

So my idea (and even assumption after i switched to the NML version) was that idle trains would cost less while waiting around. And that therefore, trains that aren't fully loaded but still running around like headless chickens, would be less profitable than a carefully orchestrated schedule that minimizes actual travel times and thus maximizes the profits.
Again, i play a VERY different game to most others. Where every thousand credits can make or break an operation. Where not just picking the most powerful/fastest unit makes you more money. You can see my ideology for that in my other thread.

IF i were to implement this (i agree, it's a lot of work) i would also change another aspect that bothers me. The wagon running costs overriding any point in picking a loco that has a good running cost to power or speed ratio.
Because there's really no penalty (aside from initial investment cost) to having more locos on a 60 tile long train as far as running costs go. At least not when breakdowns are set to none which i unfortunately had to resort to because of how monotone setting up timetables is.
Either way, i would make it so the engine (again) stands for the brunt of the running cost of the whole train. Rather than picking an engine that costs 100,000/yr and 4 wagons that brings the total to twice that of the engine running cost.

On a side note, i have already reduced the reliability_decay from 20 to 2 on ALL vehicles in 2cc. As i am playing with "minutes" rather than days, it's kinda odd that a train can't make a 4 hour trip without already being at 50% reliability and having at least one breakdown.
But that had the unfortunate side effect that timetables are not that great when it comes to repeating routes. There's no copy/paste in timetables so i can't set it up so a train goes 22 hours on it's regular service and then spends 2 hours finding one of my very few (and expensive) depots.

Transportman wrote:
But if you really want, supermop has given a nice explanation on what it should look like, although I prepared the code in this set to have those pieces of code hidden behind some #defines from C/make, to allow a single point of definition.

Yes, i see what you did. If i were to do that change then ofc i would make use of the defines rather than hardcoding it in each graphics. I just didn't know where to put the declaration for the callback and how to access variables other than "extra_callback_info" but now i see how that works.

Thanks!


Top
   
PostPosted: Tue Jun 13, 2017 7:53 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Aug 16, 2008 10:26 pm
Posts: 3626
Skype: neko-master
Location: Oshawa, Ontario, CANADA
Honestly I'd prefer having variable running costs, but more like how NARS does it. Trains cost very little when they're stopped at a station, because all they're doing is idling. Trains will cost the most to run when accelerating as their engines are revving up and gunning it to pull a train and thus are burning more fuel, or in the case of Electric trains, they'd be drawing more power and this not only puts a strain on the system but the high current it would be pushing into its system might also wear them down a little.

I think NARS basically had somethig like this for the running costs

Stopped/Idling = 50% of the running cost
Accelerating = 150% of the cost
Running at the trains max speed (so no acceleration or slowing down) = 100% of the running cost.

Also, would it be possible to have trains only cost more when accelerating and not slowing down? The way I see in that code posted a few posts ago, trains running at certain speeds will end up costing the most if its not running at full speed if I set that up.

_________________
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!


Top
   
PostPosted: Tue Jun 13, 2017 8:18 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
NekoMaster wrote:
... Trains will cost the most to run when accelerating as their engines are revving up and gunning it to pull a train and thus are burning more fuel ...

Yes, that's entirely possible to achieve. There's no "acceleration" variable to get at but one can store the previous callback speed in permanent storage and use that to derive the current acceleration of the train.

NekoMaster wrote:
I think NARS basically had somethig like this for the running costs

Stopped/Idling = 50% of the running cost
Accelerating = 150% of the cost
Running at the trains max speed (so no acceleration or slowing down) = 100% of the running cost.

I would have it as...
  • 25% when stopped and not loading/unloading. (I.E, no cargo is being moved)
  • 50% when loading/unloading.
  • 150% when accelerating. (but not when slowing down)
  • 100% for everything else.

NekoMaster wrote:
Also, would it be possible to have trains only cost more when accelerating and not slowing down? The way I see in that code posted a few posts ago, trains running at certain speeds will end up costing the most if its not running at full speed if I set that up.

Yes, it's of course possible to determine if the train is accelerating vs decelerating. It's also possible to determine how fast it's currently accelerating so a very heavy train could cost even more to accelerate, to the point where having two engines at 150% running cost each vs one running at 300% for longer could be beneficial. And of course make it so wagons aren't taking up the majority of the whole trains running costs. Say, instead of the engine having running_cost_factor 25 and it's wagons having a factor of 12 it could have 100 for the engine and 1-2 for each wagon. Or that's how skewed i find it currently.

The only thing that cannot be detected (AFAIK) is when the train is going up a hill at full throttle. Unless one could abuse the particle effect system somehow? I doubt it.

On a side note, each part of the consist has it's own running cost calculations. It's possible to make wagons cost the same unless loading/unloading for example.


Top
   
PostPosted: Thu Jun 15, 2017 3:47 am 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
Does the Italian FS ETR300 'Settebello' EMU have a typo by any chance? It's supposed to have a max speed of 200 km/h, not 300 km/h?

I would put it on the tracker but i don't feel like making yet another online account for it.


Top
   
PostPosted: Sat Jun 17, 2017 6:34 am 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2533
Regarding the discussion about running costs: I will consider lowering the wagon and coach running costs, and a system with variable running costs depending on acceleration does sound interesting (at least more interesting than just some penalty for driving above a certain speed). Is there a set that implements such a behavior at the moment? Then I can look at that for the code instead of reinventing the wheel.

Cadde wrote:
Does the Italian FS ETR300 'Settebello' EMU have a typo by any chance? It's supposed to have a max speed of 200 km/h, not 300 km/h?

I would put it on the tracker but i don't feel like making yet another online account for it.

Yes it does. I will put it on the tracker for you.

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Sat Jun 17, 2017 1:08 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
I do not know of any NML version of that code off hand. Unless NARS which was mentioned is NML, i doubt it.
But i can give it a try on a particular vehicle and see what i come up with. The reason i haven't done it yet is because i too understand how much work goes into it.

However, i did replace all wagon running costs (all but the powered ones) with "running_cost_factor: 1" using regex. Making an inline conditional using a parameter in it's place would be trivial.
And i then made a small application to replace powered wagons running costs with half of what they were before.
Finally, i added 1/32, 1/64, 1/128, 1/256 and 1x32, 1x64, 1x128 and 1x256 running cost factors in the parameters. I don't know why because after the wagon changes, i am still only running 16 times running costs but i anticipated i would need more for some reason.

But that begs the question, do you keep a database of all vehicles parameters or do you manually edit each and every file? Because i've contemplated reading the files with an application and putting it all into a DB and then auto generating the NML with that application instead. Then, adding running cost callbacks to every file that matters would be trivial. Well, it's kinda trivial already as i can just use DEFINE as you said and just adding the related switches in the respective *_graphics files programmatically but if i were working on such a large set of vehicles from the start, then i would make a GUI for it where changing the vehicle parameters would be easier and i could use the same application to do some other monotone tasks automatically.

However it's not my set, i am just trying to play without OCD'in about certain things. :P


Top
   
PostPosted: Sat Jun 17, 2017 5:22 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Dec 28, 2009 9:47 am
Posts: 10951
Location: Rijeka, Croatia
Transportman wrote:
. Is there a set that implements such a behavior at the moment? Then I can look at that for the code instead of reinventing the wheel.

IIRC, NARS and UKRS use this system, maybe even Michael's DB set as well. Hasn't this been done to the Dutch set too, I can't recall...

_________________
Leon

Image Image Image Image
"... all I ask is a tall ship and a star to steer her by..." - John Masefield


Top
   
PostPosted: Sat Jun 17, 2017 7:38 pm 
Offline
Tycoon
Tycoon

Joined: Tue Feb 22, 2011 6:34 pm
Posts: 2533
Cadde wrote:
I do not know of any NML version of that code off hand. Unless NARS which was mentioned is NML, i doubt it.
But i can give it a try on a particular vehicle and see what i come up with. The reason i haven't done it yet is because i too understand how much work goes into it.

However, i did replace all wagon running costs (all but the powered ones) with "running_cost_factor: 1" using regex. Making an inline conditional using a parameter in it's place would be trivial.
And i then made a small application to replace powered wagons running costs with half of what they were before.
Finally, i added 1/32, 1/64, 1/128, 1/256 and 1x32, 1x64, 1x128 and 1x256 running cost factors in the parameters. I don't know why because after the wagon changes, i am still only running 16 times running costs but i anticipated i would need more for some reason.

But that begs the question, do you keep a database of all vehicles parameters or do you manually edit each and every file? Because i've contemplated reading the files with an application and putting it all into a DB and then auto generating the NML with that application instead. Then, adding running cost callbacks to every file that matters would be trivial. Well, it's kinda trivial already as i can just use DEFINE as you said and just adding the related switches in the respective *_graphics files programmatically but if i were working on such a large set of vehicles from the start, then i would make a GUI for it where changing the vehicle parameters would be easier and i could use the same application to do some other monotone tasks automatically.

However it's not my set, i am just trying to play without OCD'in about certain things. :P

There is an out-of-date Google docs sheet with vehicle properties, but that is not complete and I didn't update it. However, in recent versions of this set (nightly only, I should make a proper alpha release one of these days) things like running costs are already in a DEFINE, although the DEFINE is empty for the callbacks and only sets the cost properties based on the other vehicle properties.

Voyager One wrote:
Transportman wrote:
. Is there a set that implements such a behavior at the moment? Then I can look at that for the code instead of reinventing the wheel.

IIRC, NARS and UKRS use this system, maybe even Michael's DB set as well. Hasn't this been done to the Dutch set too, I can't recall...

The Dutch set does not have this, but I'll have to check NARS and UKRS for this at a later moment.

_________________
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML


Top
   
PostPosted: Sat Jun 17, 2017 11:38 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
Yeah but i meant more like for automation. Not manually updating.

Either way, i am currently ankle (soon to be knee) deep in code to mass implement all the changes I want to see in 2ccts. However, i am going to have to disappoint you (for now at least) as i am NOT planning to do it the "#define" way at the moment.
It is of course possible to do so! But for a start, i am just looking to implement the changes i want in the fastest possible manner so i can keep playing...

Main goal here is to implement variable running costs based on current speed alone. (at least for a start)

Basically, if a loco has a running_cost_factor of 100, a max speed of 200 and it's current speed is 20 km/h. Then the following will happen in a switch...

Code:
return current_speed * 100 / max_speed * running_cost_factor / 100;
or in numbers...
return 6 * 100 / 56 * 100 / 100; // = 10.7142857143


Now you may ask, why the multiplication by 100 on "current_speed"? Because otherwise it would for example divide 6 by 56 and return 0 rather than 10 or 11 because of integers. Also, it could very well be 5 and 55 for current and max speed respectively. I don't know and i don't care to look at sources.
And in case you are wondering, current and max speed variables are in meters/s, not km/h. Mathematically, the result should be exactly 10. But i am purrty sure that current and max speed variables are ints, not floats. So i am working from that assumption. And either way, the result of this operation surely is cast to an int either way so there's bound to be some rounding/flooring.

Of course, it's "trivial" to store current speed in PSTO and compare with the last stored value and do acceleration based running costs instead. I just find it more natural to have a linear curve. Of course, an exponential curve is also possible but i am fed up with math as it is.

btw, the "running_cost_factor" in the above formula has to be hardcoded as there's no "original_running_cost_factor" to use here. Nor is there even a variable for the current factor applied. Sure, a define can do that but like i said, i just don't wanna go that far yet because i am already coding automated replacements and i don't want to involve another step in that procedure.

BTW BTW... I hate makefiles. Compiling without using make takes around 6 seconds. Using make it takes 15-20 or more seconds! I hate waiting for pointless garbage to finish.
Yes, i am re-implementing my own compile process because of that.

Anyways, back to coding!

EDIT: I am actually quite proud of myself. :P

Attaching screenshot to brag about how silly i can get.
No, i am not done doing replacements. I am merely testing something in the compiled GRF.


Attachments:
2cc trainset powered wagon running cost.vshost_2017-06-18_04-04-54.png [59.74 KiB]
Not downloaded yet
Top
   
PostPosted: Mon Jun 19, 2017 4:38 am 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
I've run into a little problem. Not major in any way but it seems current_speed is not set/valid when doing the running_cost_factor callbacks on wagons. Only on engines.
So apparently, i cannot make wagons have dynamic running costs. And no, i didn't know at the time but permanent storage is only valid for towns, industries, airports and objects.

I am sure the old 2cc solved this with hardcoded speeds in the action2 chain somehow. I.e, the locomotive made use of count_veh_id and if > 0 then one of said wagons was on the consist and the lowest of those hardcoded speeds would be used.

Also, the formula in my previous post was incorrect. Don't use that. ;)

EDIT: Or, technically i could have dynamic running costs on wagons if i count the number of wagons on the train by ID like i said above. But that is taking things waaaay to far down the rabbit hole for me.


Top
   
PostPosted: Mon Jun 19, 2017 7:07 am 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
I honestly truly don't know if this is correct. I need to test it thoroughly to be sure.
And i don't even know if the diff file is correct.

And there are some dangling language entries (because no dynamic wagon running costs possible as i said) and the switches all have dynamic running cost code in them despite not all of them being able to work with it.
Yes, i can make it prettier but to be frank i don't give a hoot. My code simply takes a clean source and slaps on running cost stuff.

But anyways, here's what my little mass replace program produced in the end...

EDIT: Oh yeah, keep in mind that the vehicle info window is not dirtied by this callback. You have to make it redraw to see the values update. Simply clicking the titlebar or the info button will refresh it.


Attachments:
File comment: A massive diff
2cc nml caddelito.diff [1.28 MiB]
Downloaded 6 times
Top
   
PostPosted: Mon Jun 19, 2017 8:04 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 244
First of all... I am STUPID. STUUPEEEHD!

current_speed and max_speed and even current_max_speed is available... If only i use PARENT rather than SELF on the switches.

And secondly, the diff i provided has a little bug. In that it doesn't provide a proper running_cost_factor in the purchase list. I've added that now though!

Either way, dynamic running costs for locos, coaches, wagons and powered/unpowered wagons incoming!

Here: https://github.com/TheCadde/OTTD-2cc-in ... /0.1-alpha

(diff file exists in that location as well)

Code:
2.0 ala CADDE - alpha 1 (19/06/2017)
-----------------------
- Add: New (optional) dynamic (speed based) running cost behavior for locomotives, coaches and regular, powered and unpowered wagons.
- Add: Modifiable running costs for locomotives, coaches and regular, powered and unpowered wagons as a percentage of the default values.
- Add: Modifiable reliability decay.
- Add: Parameters for the above mentioned additions. (NOTE: This requires a complete reload of the GRF, no NOT use this GRF on an existing save!)
- Changed: Modified loading speed of coaches. They used to be "Intercity" with a default value of 16 but now have a default value of 12. Coaches are slower to load now.
- Fix: Italy FS ETR300 Settebello max speed was incorrectly set at 300 km/h, it's now 200 km/h.


And here's the C# app that i crudely made to make these changes: https://github.com/TheCadde/OTTD-2cc-in ... /0.1-alpha

Cry me a river if it's not to your tastes. I meant to make these changes for myself. :D
That includes the application that makes the changes! You would have to compile it yourself if you want to use it for other changes. Or ask me.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 134 posts ]  Go to page Previous 13 4 5 6 7

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.