The International Simutrans Forum

 

Author Topic: Event logic  (Read 3624 times)

0 Members and 1 Guest are viewing this topic.

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Event logic
« on: May 15, 2009, 08:27:22 PM »
probably complex, however:

suggest adding a system of trigger events and actions.

e.g. a vehicle gets an event trigger when it enters a stop, and when it leaves. the event being notified what the stop is

e.g. a time based event similar to 'cron' which could be used to enforce a schedule of sorts in some areas.

something that could be added to any vehicle or stop, but as an option. essentially adding a very limited player controlled script language.

purpose:
allowing some vehicles to act with a degree of intelligence, e.g. a train enters a station, unloads and is then routed to a waypoint, where it will stop (a stabling siding, maybe a seperate station that never loads anything) here it waits until a time trigger routes it back to the station (maybe by removing a minimum load criteria holding it somewhere it can't load) thus allowing passengers to build up, without hogging a platform.

e.g. a bus operating a schedule where by as it enters a certain stop, it will wait until an event trigger releases it

this allows better use of a limited number of vehicles, and allows a 'commuter' type service, with some units operating part time, and spending the rest of the time stabled out of the way.

envisaged as a pure option, that would only be used on some units in special circumstances, but allows a vastly more flexible operation scheme to be devised

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Event logic
« Reply #1 on: May 15, 2009, 09:09:59 PM »
I have thought about exactly this some time ago. It would be useful mostly for goods transport... but probably not at all for Joe The Average Player.

Sometimes I wonder, what exactly is the audience Simutrans tries to capture - casual players, serious railroad modellers, "city builders", traffic coordinators... we can't have it all :-\

Offline Isaac.Eiland-Hall us

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3651
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Re: Event logic
« Reply #2 on: May 15, 2009, 10:00:18 PM »
Oh wow... that would be... AMAZING. And time-consuming. But amazing.

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Event logic
« Reply #3 on: May 15, 2009, 10:15:46 PM »
in thoery not too hard to do, in practice well you know. it depends if you need logic of a simple linear script (i.e. do you need 'if' statements)

its a case of tagging a text field into an object that the user can place a 'script' into, and having something that can process these scripts within the object class.

having written a script language for another project its not that hard, though its not fast (so you'd want to limit it to a few units where its needed, i think requiring the user to enter them will manage that)

then its a case of adding the 'triggers' somewhere, thats the harder bit.

still thinking about this, the potential is amazing, in some circumstances, but only in some.

the hard bit is allowing the script to 'see' the game envirnonment not strictly required but useful, the simple time based events would help hugely though and would be theoretically easier. have increments of say 1 hour, every 'hour' the vehicle object gets a prod to run the script, and is given the hour as a parameter, if the script is set to work on that hour its fired.

as a simple way of saying "go to sleep until the time is 'x'" this is very useful, even in the standard schedule system, e.g. a destination waypioint/station instead of getting a minimum load paramter (or in addition to it) could have an hour added, so the train pulls into a station, and will not leave until the hour is equal to a preset value (or values) forcing a delay and allowing some basic schedulling to be handled

that would probably be easier than a full blow event scripting system and provides many of the benefits.

thinking specifically for low density routes, as a way of forcing a train to wait a while at the end points, but after a set time to move, regardless of the load. allowing a more optimal usage of the investment

Offline Isaac.Eiland-Hall us

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3651
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Re: Event logic
« Reply #4 on: May 15, 2009, 10:19:53 PM »
Having a way to change which line a convoi was assigned to also would be nice, for example. :)

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18684
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Event logic
« Reply #5 on: May 15, 2009, 10:20:29 PM »
Leopard,

can you write C++? ;-)

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Event logic
« Reply #6 on: May 16, 2009, 08:22:44 PM »
I have a grounding in basic C, and am slowly getting better with objective-C (I run an apple mac c++ doesn't get much use here)

having said that I have written a reasonably powerful (and modular) script language in vb.net, and am about halfway through porting it to obj-c.

what I don't have is enough of an understanding of the way the game is structured to make this work.

it did occur to me that another way to handle this would be a special stop class, which 'captures' anything that visits it until a preset time before letting it go. thus allowing the idea of stabling sidings or a parking lot to be implemented without anything complex.

I'm still considering this one, Having added a hook or two into the core code I've got a few ideas as to how such events could be managed (essentially its just a case of expanding the code for loading/unloading, which should trigger at a stop) to call another function and pass it a string (the script).

needs more thought.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18684
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Event logic
« Reply #7 on: May 16, 2009, 08:32:56 PM »
The reason that I ask is that there isn't a great deal of spare coder capacity at present - the main developers are bevering away on underground mode and bug fixes (and the lead developer, I think, is generally very busy), and I'm spending much time debugging Simutrans-Experimental, and have frozen the features indefinitely some time ago to allow for debugging.

It would be extremely useful to have another developer on board. This particular idea is a rather complicated one, but perhaps you could start by implementing some minor improvements just to get used to the code?

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Event logic
« Reply #8 on: May 16, 2009, 08:57:14 PM »
sadly I won;t be on line much longer, a house move will knock me off line in any serious way for a year or so probably, I hope to get a 3G dongle whatsit but won't be right away. I will be grabbing a snapshot before I vanish though, to play with.

hopefully when I return I'll be more useful

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18684
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Event logic
« Reply #9 on: May 16, 2009, 09:01:20 PM »
Gosh - that must be some house move! Best wishes with 3G dongles, and with moving house... :-)

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Event logic
« Reply #10 on: May 16, 2009, 09:43:54 PM »
not exactly a huge move, a few miles at the most, just going rented, and not willing to sign up to an 18 month contract with BT with a 6 month house rental contract.

can play on the forum with an iPhone but won't be able to post stuff with it, or sadly download anything

Offline colonyan

  • Devotee
  • *
  • Posts: 526
  • Full and Warm
Re: Event logic
« Reply #11 on: May 16, 2009, 09:52:56 PM »
Um I guess its little late to say but I like this idea. Would certainly be fun...

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18684
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Event logic
« Reply #12 on: May 16, 2009, 09:53:33 PM »
Get cable?

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Event logic
« Reply #13 on: May 16, 2009, 10:18:02 PM »
cable... 18 month contract also, assuming the house is wired already. if its not forget it, chances are minimal.

not to mention I've had dealings with the f**kwits before, and won't touch them again with anything other than a club with a nail in it. the only company ever to make BT look competent, even worse than British Gas...

Offline whoami

  • Devotees (Inactive)
  • *
  • Posts: 693
Re: Event logic
« Reply #14 on: May 19, 2009, 08:06:24 PM »
@leopard: would UMTS be an option in you area/country? OK, 6 months of it might cost the same or more as 18 months with BT.

On topic (well, not really): using linear scripts (having only if and waitfor) with vehicles (running in loops) might allow to model a programming language with the simulator itself. It might even be Turing-complete. ;D