Creating protobuf message

In this step, we create protobuf message. The message defines the data transfered from Godot to Python.

  1. Create template message.proto file with the following command from your terminal:

    godot-gym-api create_proto <YOUR_PATH>/apple_seeker
    
  2. Change the created message.proto file as follows:

    syntax = "proto3";
    
    message WorldData {
        bool apple_caught = 1;
    }
    
    message AgentData {
        repeated float distances_to_obstacle = 1;
        repeated float distances_to_target = 2;
    }
    
    message Message {
        AgentData agent_data = 1;
        WorldData world_data = 2;
    }
    

Let’s breakdown, what’s happening here.

In Godot Gym API every message is assumed to have both Agent data and World data.

message Message {
    AgentData agent_data = 1;
    WorldData world_data = 2;
}

For this project we want the agent to return distances to the room walls and distances to the apple (float values). Thus, we define AgentData as follows:

message AgentData {
    repeated float distances_to_obstacle = 1;
    repeated float distances_to_target = 2;
}

Also, we want to know whether the apple is caught (boolean value). We will use this information in reward function and while checking the episode termination later. Thus, we define WorldData as follows:

message WorldData {
    bool apple_caught = 1;
}

3. The message should be compiled. For Godot see Godobuf/Usage section and store compiled file as <YOUR_PATH>/apple_seeker/godot/protobuf_message.gd. For Python use the following command:

protoc --python_out <YOUR_PATH>/apple_seeker/python <YOUR_PATH>/apple_seeker/message.proto