syntax = "proto3";

import "google/protobuf/empty.proto";

message NumPlayers {
    int64 num_players = 1;
}

message String {
    string string = 1;
}

message PlayerAndPolicyNum {
    int64 player = 1;
    int64 policy_num = 2;
}

message NewActivePolicyRequest {
    int64 player = 1;
    string metadata_json = 2;
}

message PolicySpecJson {
    string policy_spec_json = 1;
}

message PolicyMetadataRequest {
    int64 player = 1;
    int64 policy_num = 2;
    string metadata_json = 3;
}

message PolicyNumList {
    repeated int64 policies = 1;
}

message P2SROStatusResponse {
    string payoff_table_json = 1;
    repeated PolicyNumList active_policies = 2;
    repeated PolicyNumList fixed_policies = 3;
}

message PayoffResult {
    repeated string json_policy_specs_for_each_player = 1;
    repeated float payoffs_for_each_player = 2;
    int64 games_played = 3;
    bool override_all_previous_results = 4;
}

message EvalRequest {
    repeated string json_policy_specs_for_each_player = 1;
}

message Confirmation {
    bool result = 1;
}

message Metadata {
    string json_metadata = 1;
}

service P2SROManager {
    rpc CheckNumPlayers (NumPlayers) returns (Confirmation) {}
    rpc GetManagerMetaData (google.protobuf.Empty) returns (Metadata) {}
    rpc GetLogDir (google.protobuf.Empty) returns (String) {}
    rpc ClaimNewActivePolicyForPlayer (NewActivePolicyRequest) returns (PolicySpecJson) {}
    rpc SubmitNewActivePolicyMetadata (PolicyMetadataRequest) returns (PolicySpecJson) {}
    rpc CanActivePolicyBeSetAsFixedNow (PlayerAndPolicyNum) returns (Confirmation) {}
    rpc IsPolicyFixed (PlayerAndPolicyNum) returns (Confirmation) {}
    rpc SetActivePolicyAsFixed (PolicyMetadataRequest) returns (PolicySpecJson) {}
    rpc GetCopyOfLatestData (google.protobuf.Empty) returns (P2SROStatusResponse) {}
    rpc SubmitEmpiricalPayoffResult (PayoffResult) returns (Confirmation) {}
    rpc RequestExternalEval (EvalRequest) returns (Confirmation) {}
}