fadster / TrafficManager_ImprovedAI

Original Traffic Manager with improved AI from Traffic++.
7 stars 3 forks source link

Disable parking -feature #1

Open armarayo opened 9 years ago

armarayo commented 9 years ago

As much as I dislike 4 lane roads I really cannot stand that there's cars parked on side of the roads. Could you perhaps fork out a feature that would disable parking on certain roads?

Thanks for considering. Armarayo

fadster commented 9 years ago

I don't know how parking is implemented but I can take a look. I'll let you know what I find.

armarayo commented 9 years ago

Thanks a lot! If it's easy I hope some kind of "parking on side of (some) roads could be disabled. Or maybe this idea is more of advanced vehicle option -mod material? Dunno. Would seem to fit TM+AI too :)

HEy btw did you see this video of gameplay footage of After Dark https://www.youtube.com/watch?v=7wYOxYlak6Y they show all the new stuff at the menus.

fadster commented 9 years ago

Almost done, excellent idea, thanks! It fits perfectly in fact, so well that the code was practically already written. It's just like the lane changer, you click on a segment. In this case, the click toggles the parking lanes. This got me wondering if I can actually recycle the lanes altogether. This means we could have 4-lane 2-ways (narrower, no middle portion) and 4-lane one-ways. Or 8-lane 1/2 ways!

I checked out the video, good stuff!

armarayo commented 9 years ago

Thank you, this sounds very exiting, cannot wait to get to test it. Yes it would be great to have some use for that extra available space from parking, great ideas. To my knowledge, those parked cars are merely props - it's not like in Skylines that there is car parking feature for cims, so it seems to be about looks. But I do wonder if parking is disabled would more cims flock to mass transit..?

One thing what I'm thinking that in After Dark that space from parking could be might be taken for such as bus lanes and bike lanes. Bus lanes are available at least for 6 lane road and 4 lane road, and bike lanes for 2 lane road and 4 lane road :)

Anyhow, looking forward to disable parking along (some roads) and perhaps even taken the space to such as car lane use - or even better - tram :)

So i'm thinking that disabling parking could be a feature that could be added quite soon and all the possible rest in a later update? :)

WillFa commented 9 years ago

As far as recycling lanes go, that's pretty much how Katalyst6 started over at the network extensions mod. https://github.com/Katalyst6/CSL.NetworkExtensions.

The thing that would worry me is the "feature creep" turning this into a huge, monolithic mod that has so much potential to conflict with something else or break with every update. (T++ has the reputation of being buggy simply because it tries to do so much)

Personally, I use the Toggle Traffic Lights mod since I can hotkey it, instead of TM's functionality. I have no desire to manually set timed lights. Really the aspect of TM that I use and want is the lane changer as I prefer it's simplicity over T++'s rather heavy/tedious/minutiae-driven implementation. If the Lane Changer (and Parking toggle, since that's a lane type too) were broken out into it's own mod, I'd happily just run that with either the IAI (but I like your changes too.... Too many forks!)

armarayo commented 9 years ago

I think Traffic Manager + Improved AI will be the hottest of the traffic mods. The code is much cleaner than any other traffic mod. Yes I agree should be cautious that this mod doesn't end up bloated, and the looks of it, it wont. Maybe eventually it should have it's own name?

I use some mods, a lot of basic ones and popular ones - simple mods more than complex - but still I haven't got Network Extensions mod to appear in the menu. Maybe it's road precision but I need that a lot more than lot's of different highways ~ which is the path Network Extensions seems to be going.

After Dark will have some amazing new roads :)

WillFa commented 9 years ago

I haven't completely deciphered everything that TM+IAI does, and fadsters changes, but my understanding from his comments from the initial release is that it's pretty much both AIs made to not fight with each other, and not merging TM's functionality into IAI's. i.e. Priority signs and timed traffic lights still run the original TM code, and aren't aware of what IAI is trying to do... I may be wrong though.

Network Extensions has just as many "avenues" (4L roads) as highways... https://github.com/Katalyst6/CSL.NetworkExtensions/commits/master They just appear as new roads in the same road build panels for me, not as a separate menu or button in the interface.

image

I run both Precision Engineering and Enhanced Road Heights and neither conflict for me. The only ones that I can think might have conflicts are Sapphire and Improved Build Panel.

fadster commented 9 years ago
  1. I'm not sure what you (armarayo) mean by parked cars being only props. They are the actual vehicles, complete with VehicleInfo objects attached. You can see the cars being driven to and from the actual parking spots. For parking lots, I believe the animation stops at the lot's entrance, at which point the car gets teleported to a vacant spot in the lot. I don't think this would have any effect on public transport use. Unless the inability to find parking spots would discourage the use of private vehicles. This would actually be quite interesting as it would model real life closely in this case. However, at first glance, it seems the AI starts looking for a parking spot only when it has reached its destination. It is, however, an interesting point to consider.
  2. Since the 'no parking' turned out to be quite straightforward (still ironing out some details), I will release it before any other feature, very soon now (without making promises, I aim for today or tomorrow). Also, WillFa, you are correct, this can easily be made into a standalone mod, and I plan to do just that :)
  3. I am well aware of the risks of feature creep and bloat. In my opinion, light, simple, single-purpose mods work better in all respects. The advantage of grouping functionality, of course, is that is simplifies interaction between related features. A case in point, in fact, is the interation between TM and IAI in this mod. Loosely speaking, when I use the term AI in the context of this mod, I'm referring specifically to the path finding logic. For this mod, all path finding code from TM is disabled, which is what its Traffic++ compatibility mode used to do. However, Traffic++ has an interface for lane configuration, which IAI lacks. All I did was take TM's interface for lane configuration and adapt it to IAI's path finding logic. All this logic needs is a function to tell it which lane can be reached from another lane. Incidentally, this is what will allow me to have both lane marking interfaces and have the best of both worlds. TM's simple interface is great for implementing things like "no left turn," while the finer control from T++ is perfect for implementing "stay-in-lane while turning."
  4. From all the above, you can see that a standalone lane changing mod is not possible without a compatible path finding component to actually use the lane configurations you specify.
fadster commented 9 years ago

By the way, there is still a lot of cleanup that can be done in the code. However, several things to keep in mind:

  1. When working with existing or legacy code, it is desirable to change as little code as possible. Unless there is a bug to fix or some glaring incompatibility to resolve, what works should be left alone. For this reason, wherever possible, I have kept the original code from Traffic Manager and Improved AI as they were written (which explains the different styles and formatting of code you can observe).
  2. There are big chunks of code that come straight from decompiled CO dll's. Again, this code is better left untouched, especially if the changes we'd like to make are purely cosmetic.
  3. New code should, of course, be written using a consistent and clean style.

Eventually, it would be nice if everything could be cleaned up and made consistent throughout. The priority right now, however, is to ensure continued functionality.

fadster commented 9 years ago

One more thing, WillFa, the control of timed lights is indeed done by TM code. However, actually obeying the traffic lights is done by the navigation and path finding logic, which is divided between vanilla and IAI code. As for priorities, I haven't looked closely, but I believe it is similar to traffic lights in terms of where they are implemented.

WillFa commented 9 years ago

I haven't peeked at the CO dll's code in quite sometime since trying to keep num2 and num13 and num664 straight makes my head hurt. So most of the learning I've been trying to do as of late is from reading several repos here on github and try to avail myself of the work y'all have already done...

That said, already in the pathfinding in the code in this very repo are 3 calls to the "GetClosestLane" function, although 2 of them are for calls to bicycles. BUT! There's one that's for general vehicles. This function is part of vanilla, so I've been trying to reason out why the processor cycles are spent finding this, but still "stay-in-lane" isn't the default behavior. Why is the code bothering to find which lane is closest and not use it? Is the int num2 just falling out of scope and needs to be moved up a closure? Is the look-ahead cycles in the a* calc overwriting it? Are the out params not actually "this is the right-hand lane" but "this is the first valid lane that isn't a sidewalk or parking/prop lane"? Since there's twice as many calls regarding bicycles than other vehicles, is it just not fully implemented yet in the CO dll? "Argh, too many questions for me... I'll come back to it later. "

Having read through your, and katalyst6's, and cbethax's code, I knew enough that this parking change would be simple(-er)... but I was hoping that your familiarity would be better able to answer the question. Or at the very least, get you interested in it.

fadster commented 9 years ago

Yeah I also had the same thought but it seems it doesn't quite do that. Still not entirely sure though.

armarayo commented 9 years ago

How is the parking disable mod coming along?

fadster commented 9 years ago

Hey sorry, got sidetracked, regular life got in the way :p Turns out toggling parking on lanes is a little more involved. This particular information is shared by all road segments of the same type. In order to toggle parking for individual segments, I need to create a new road type altogether, and this has to be done at a precise moment during level loading. In fact, it's exactly what T++ does for its special lanes, so I already have the code to do it. Just need to extract it and adapt it for this particular use.

armarayo commented 9 years ago

Oh.. I wasn't looking to add new roads, no - not since AD will bring plenty of those, with buslanes and bike lanes.

I really only wanted a tool to get rid of parked cars - from all roads if necessary :)

fadster commented 9 years ago

You can't do that without creating "no parking" lanes. That's the only way to tell the AI it can't park cars there.

armarayo commented 9 years ago

Ok, sound good :)

fadster commented 8 years ago

Development on this feature is on hold for now. I'll keep the issue open for the time being.