RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
1.01k stars 175 forks source link

In-game AI #2929

Closed tritonas00 closed 1 year ago

tritonas00 commented 2 years ago

It's now possible to set waypoints in survey map using right mouse button (or delete them with middle mouse button) or record a path, and fire up AI vehicles on various configurations, thanks to @only-a-ptr's on the fly script loading. Also waypoint presets for various maps are automatically fetched from github and shown in UI, on the fly. A new menu added in top menu bar:

kk

@AnotherFoxGuy's AI expanded to boats and airplanes. Three driving modes are available: Normal: Land vehicles modify their speed according to upcoming turns, and react to character and other vehicles. Race: Land vehicles always retain the user defined speed. Chase: Land vehicles follow the character and player vehicle.

Two waypoints are enough to set up airplanes, although they can steer and follow multiple waypoints, if set reasonable, while maintaining altitude.

ohlidalp commented 1 year ago

Machine precision 😏 obrazek

Also there's a glitch in the "parallel start" option - all vehicles think they're starting on waypoint 0, even though only one of them is, and they continue with this misconception for all other waypoints. Here they're really headed to waypoint 1: obrazek And this is further down the road: obrazek Guys, why don't you try it the other way around? obrazek

I couldn't find any way to delete individual waypoints. To reset all, I can only reload current terrain from top menubar. In the waypoints list, the positions could have less decimal points - use "%.2f" in the format strings for "0.00" for example.

tritonas00 commented 1 year ago

Also there's a glitch in the "parallel start" option - all vehicles think they're starting on waypoint 0, even though only one of them is, and they continue with this misconception for all other waypoints. Here they're really headed to waypoint 1:

When in parallel, the waypoints for the second+ vehicle have offset, internally, you don't see the offset in the survey map

I couldn't find any way to delete individual waypoints

hover the waypoint and click middle mouse button, it will remove only that waypoint

ohlidalp commented 1 year ago

When in parallel, the waypoints for the second+ vehicle have offset, you don't see the offset in the survey map.

OK, I didn't believe it could be a feature - it basically makes most of the vehicles unable to complete the track. I'd add an optionally visible checkbox "keep offset" to preserve this behavior, and by default I'd make the offseet gradually decrease starting with 2nd waypoint, so vehicles have bigger chance to find their way.

hover the waypoint and click middle mouse button, it will remove only that waypoint

Oh! That needs a hint, tho. In fact, I'd remake all the hints:

tritonas00 commented 1 year ago

it basically makes most of the vehicles unable to complete the track.

yes the do, the have their own "offsetted" path to complete, relative to the initial one, but in parallel :smile:

just the "route" must be parallel friendly in the terrain

tritonas00 commented 1 year ago

this is what parallel does internally (example 4 vehicles):

kk

the offset is the "Distance" in UI

sorry for unstable drawing but you got the idea :laughing:

tritonas00 commented 1 year ago

regular map view: "LMB to teleport character, RMB to add waypoint". waypoint hovered mode: "LMB to drag waypoint, MMB to delete waypoint" waypoint drag mode: "MMB to delete waypoint"

ok will do

CuriousMike56 commented 1 year ago

Fantastic work on this. Some things I noticed during testing:

tritonas00 commented 1 year ago

Thanks for testing!

It's possible to set all the menu values to negative, usually results in unexpected behavior/crashes

Done, except Distance -> Positive values: offset to behind/right, negative values offset to front/left (or the opposite, don't remember lol)

After selecting the AI vehicle, the menu should reappear. This would prevent possible confusion

Done

Any plans on improving the chase AI by making it follow waypoints if the player is also following them? Right now the chase AI will just target the player without taking its surroundings into account.

Chase mode works with only two waypoints-> 0: the initial spawn position 1:it is always live updated to character/vehicle position. Taking its surroundings into account: very hard