Self-Driving Neural Network Cop Cars

I’m so glad this got bumped. I’ve been wanting to dip my feet into neural networks for AI, and seeing that something like this is possible on Roblox is CRAZY.

I probably will get off my butt and actually try it now. I know I’m a year late, but thanks for sharing.

1 Like

Why is the police car in the video very jittery?

I run it in Studio and the chase camera stutters there.

I don’t really have anything I can release (this is something I was paid to make for someone else), but I’d be happy to help anyone that has questions. Please stop DMing me and ask them here instead so everyone can benefit!

1 Like

Dang, really? I would love to play a game with this, and get chased around by some ‘self driving cops’.

1 Like

Welp, my web-based neural network stuff I’m working on won’t be relevant anymore. In all seriousness, great job!

I wonder if I could try to make a NN that tries to play an RPG/other game at approximately the same skill level as a player… try to get it to match delta Score with the player. Would allow me to have allied NPCs that couldn’t carry the player but also never become useless…

With lots of training data and a good architecture for the thing you want to do you definitely could. I’m not sure how you’d manage to train with a player’s rating since you need a lot of training data. Most game AIs are actually played against themselves to get better which ends up in constant progression but you’re looking to also limit based on skill.

I think what you’d end up doing is recording matches including the actions the player took and their skill level. Then you’d feed the neural net with this data and try and get it to learn from players. I know that this has been done before with other things but I’m not sure what architecture you’d use for that to be honest.

Most games just limit their progression by adding delays in their actions or decreasing stats.

1 Like

I’d use delta score as an input - so the “ally” AI would train to try to match pace with another AI/player. Then I could just feed it a lower delta score and it, in theory, will play “worse”.

I’d also probably separate scores from different sources (since some allies are planned to be specialized in different styles, like support) so that I could apply the player’s highest sub score to the “primary” score, and so on.

Now I just need to figure out how to make a NN in Lua.

That makes sense and I’m not sure why I didn’t think of that to be honest. I guess you would train the network given a target score, score the network as it plays, and punish/reward the network based on how well its doing (given the architecture works that way).

Such a ML AI might even be the best possible ally AI, being honest. The AI would never be too strong or weak.

I just haven’t found any tutorials on how to do ML yet.

1 Like

I like your ideas. I’ve been brainstorming my own concepts with cars that learn to drive like you drive. I’ve got some basic stuff set up - I get in a car and give myself a GPS route in-game and follow it. The entire time my inputs and location and velocity relative to the GPS routes are recorded every 0.1 seconds. Then I train a new network to see the inputs (position relative to GPS route, last set of outputs, velocity, etc) to match the recorded outputs (the steering, throttle, and handbraking I decided to do in said scenario).

After some time the AI learns to take those inputs and outputs results that look somewhat like mine, AKA mimicking what I would do in a driving situation. It works okay right now and still needs some work. I’ve been thinking of making police chases use cars that are just as good as the player, if not a little better (only train on the players “good” data, aka delete training data that results in the player crashing).

1 Like

I don’t think having a ML AI against a player is good though - you’d have to be careful to prevent the enemies from getting so stupidly perfect that the AI wins every time or is unnecessarily aggravating to play against, at least in certain games. In Smash, for example, a ML AI trained on top players would be monstrously out of tune and one trained on average players would be too weak for top players to get a challenge from.

By the way, massive fan. Felt awesome to notice you had replied to me lol

1 Like

Btw this has been properly released (finally!) in Vehicle Simulator after some performance improvements on roblox’s end. To trigger a cop go left down the road from the spawn and hit the cop car with your car!

https://www.roblox.com/games/171391948/Huge-Sale-Vehicle-Simulator-Beta?refPageId=3bc8c6cd-fc25-4367-9c16-6ae4e0a9ffb8

5 Likes

What made it so performance heavy? I have played the game, and touched the cop-car, but when I get chased, it gets soo laggy, and my ping is unusually high.

Roblox used to do ALL of the physics on one core, + it used to run Lua much slower.

As of 2 days ago we re published and roblox’s new changes helped quite a bit.

How big are those improvements? Is there a noticeable difference before those changes, and after?

(My pc it total garbage tbh :joy: I only have like 2 cores on this low 'n slow tower, so maybe its not going to be that much of a difference on my pc.)

Enough for my laptop to be able to run them without chugging. Last time we enabled the cops the avg player visit time went down. This time it’s gone up a bit which loosely translates to “the cops don’t lag as hard on most people’s PCs anymore.”

3 Likes

Roblox recently made physics performance changes?

It was like a month before RDC.

1 Like