Detecting the surrounding environment - is there a method faster than trace?

Is there a way for an actor to ‘sense’ its surroundings (especially landscape) that is computationally faster than trace?

I’m a hobbyist using UE4 to build an evolved AI system with an evolutionary artificial neural network. I’m not using any of the higher level navigation built into the engine, because I want to instead feed sensory data into the neural network of each AI so they can evolve their own navigational decisions. I made a similar project in UDK using raytracing, but the computational cost of 100+ ‘bots’ raytracing in 28 directions every tick was prohibitive.

Any suggestions?

Thanks!
Zach

Very interesting… what kind of sense are you talking about?

If it’s just environmental landscape then I don’t think you need to call this every tick, since it won’t be changing much from time to time. :slight_smile:

You can spread out your environment data collection over many ticks!

You dont have to do all 28 traces in one tick.

You can have a global variable and then a tick function and increment that global variable and run the appropriate trace / angle for that tick :slight_smile:

End result: each bot is only doing 1 trace per tick, but still acquires sufficient environment data very quickly!

Keep in mind that in the C++ your code is running soooo much faster!

At least 10x times faster!

So you will get the data you need fast enough with even only 1 trace per tick per bot!

Welcome to UE4 C++ !

, you are absolutely awesome. :smiley:

I’m looking forward to seeing where AI System goes. Sounds very interesting. Keep us updated! Good Luck! XD

If the terrain isn’t changing, you can pre-compute the terrain input along some regularly spaced grid, and quickly look it up.
Then modify the static environment precomputation with dynamic actors on an as-needed basis.

Awww thanks!

Hee hee!

Thanks for the replies!

  1. Precomputing the terrain would be excellent. I could maintain an 3D array of values to lookup based on current bot location. Eventually I would like the terrain to be dynamic (maybe modular, maybe mesh warping), but certainly not to begin with. I haven’t looked much into UE4’s landscape/terrain system yet - is there a way to access its spatial coordinates somehow? Also, isn’t this basically how a navigation mesh works? Maybe if I could track down the engine code for the navmesh I could steal some ideas from there…

  2. Thanks for the tips on trying to speed up the traces! Indeed, when I did this in UDK I had each bot tracing only once every 5-15 ticks, with bots offset in groups so they weren’t all happening at once. By the time I got up to 100+ bots I was slowing down to 5 FPS on a relatively fast machine. The idea of only running one trace per bot per tick might work as well, but I can only use the traces as input for the artificial neural network when they are aggregated. So if I’m running at 60FPS (hopefully) then that means decision making would only happen once every 0.5 seconds. Which is probably OK, but it could result in noticeable latency between things occurring in the world and the AI reaction. And maybe doing this in C++ will speed things up - I’ve only just gotten my basic classes up and running, so now I need to port my artificial neural network code in.

I will update with results in the next week or so as I find time to work on this.

well good luck!

I do think you will enjoy the raw speed and power of UE4 C++ immensely!

Take a look at the Environment Query System; It’s still very experimental but you should be able to get some good data for AI. You still will be doing traces, but you’d be surprised how many you can do without any perf issues.

in your engine.ini add:

[EnvironmentQueryEd]
EnableEnvironmentQueryEd=True

Use the EQSTestingPawn to try things out

I’m not sure what data you need from the trace. If its just a hit position or normal then maybe you could render a low res cubemap around each of the bots using a very simple material to get depth and G-buffer. Then calculate what you need from that.

I haven’t even looked at the rendering code for UE4 yet, not sure if this would work, or even be better on performance with 100’s of bots. Just throwing that out there

Did you consider using SweepMulti or OverlapMulti instead of trace ? You can find them in World.h.

It’s very fast and it will return Array of all overlaped objects around impact point, you can also filter out objects types you don’t want to include in sweep.

Hello Uninventive, have you been able to create neurol network? I am really interested in it. I wonder if it was possible to make that system using blueprints… ANN looks so cool on youtube :smiley:

Awesome, that actually exists already? I’d love to be able to do a look-up on the terrains height and normal at a given location in the world. That would certainly be faster than a ray-trace… My hover-tank system is doing two ray-traces for each tank every frame (to keep the physics happy), and when rays & collisions are involved it can get pretty hectic.

Doing this via a look-up would probably be way quicker… Maybe. Does it only look up terrain/landscapes?

BTW, to learn more about EQS, take a look at: http://unreal-ai-tutorial.info/ . That’s the resources site of Mieszka Zielinski, the guy from Epic responsible for it.

It can actually do a lot. One of the recent Epic Twitch streams were about it.