mbaske / grid-sensor

Grid Sensor Components for Unity ML-Agents
MIT License
135 stars 28 forks source link

Using vis_encode_type: simple #18

Closed VieVaWaldi closed 11 months ago

VieVaWaldi commented 12 months ago

First of all: Thank you for this!

So I am currently writing my master thesis and trying to use RL using self play on a first person shooter with procedural maps. I had limited success using unitys 3d ray sensors.

I just finished a prototype using your grid sensor, but i didnt manage to use the vis_encode_type: simple, as provided in unitys yaml config.

Is there a way to use cnn's with this?

Best regards!

mbaske commented 11 months ago

Hi Walter, glad to hear this is helpful to you! Using a CNN shouldn't be an issue, since what MLAgents observes with this sensor is just a texture. Therefore any settings that work with MLAgents' visual sensors (camery & render texture) should work with the grid sensor as well. That being said, there are minimum dimension constraints on the various encoding types, for "simple" it's 20x20 pixels. Please see https://github.com/Unity-Technologies/ml-agents/blob/8b86648e5385bf393cc14e751bbb56503a48e10c/ml-agents/mlagents/trainers/torch_entities/utils.py#L26 MIN_RESOLUTION_FOR_ENCODER = { EncoderType.FULLY_CONNECTED: 1, EncoderType.MATCH3: 5, EncoderType.SIMPLE: 20, EncoderType.NATURE_CNN: 36, EncoderType.RESNET: 15, }

VieVaWaldi commented 11 months ago

Thank you for the answer! I probably just had some issues with my code, it all works now :)