Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

race_actual always defaults to sc2::Race::Protoss #294

Open
pedronahum opened this issue Dec 25, 2018 · 2 comments
Open

race_actual always defaults to sc2::Race::Protoss #294

pedronahum opened this issue Dec 25, 2018 · 2 comments

Comments

@pedronahum
Copy link

Hi,
Maybe someone can point me in the right direction.
I am currently trying to analyze replays (3.16.1 Pack 1) using the Linux package 3.16.1 and regardless of the UnitTypeData (eg, CommandCenter), player_info always returns "sc2::Race::Protoss".

void OnGameStart() final {
        const sc2::ObservationInterface* obs = Observation();
        assert(obs->GetUnitTypeData().size() > 0);
        count_units_built_.resize(obs->GetUnitTypeData().size());
        std::fill(count_units_built_.begin(), count_units_built_.end(), 0);
        
        std::cout << "Map name: " << obs->GetGameInfo().map_name << std::endl;
        
        // Get the race of the players
        sc2::GameInfo game_info = obs->GetGameInfo();
        std::vector<sc2::PlayerInfo> player_information = game_info.player_info;

        for (uint32_t i = 0; i < player_information.size(); ++i){
            sc2::PlayerInfo player = player_information[i];
            sc2::Race race = player.race_actual;
            if(race == sc2::Race::Protoss) {
                std::cout << "Player ID: " << player.player_id << "; Player's Race : " << "Protoss" << std::endl;
            } else if(race == sc2::Race::Terran){
                std::cout << "Player ID: " << player.player_id << "; Player's Race : " <<"Terran" << std::endl;
            } else if(race == sc2::Race::Zerg){
                std::cout << "Player ID: " << player.player_id << "; Player's Race : " << "Zerg" << std::endl;
            } else {
                std::cout << "Player ID: " << player.player_id << "; Player's Race : " << "Random" << std::endl;
            }
        }
    }

I am seeing a similar issue with the map_name, but maybe I am very lucky that all my replay tests have been done in the map "Odyssey LE".

Any pointer is greatly appreciated.

Thanks,

@pedronahum
Copy link
Author

Hi,
I see that there was an attempt to address this issue (at least for maps) in #259 via force_refresh, yet the most recent version of GetGameInfo (in ObservationInterface) do not expose force_refresh. Could the cache be creating a similar issue for the player's race?

virtual const GameInfo& GetGameInfo() const = 0;

@pedronahum
Copy link
Author

Hi,
ReplayControl() would output the correct race, yet GetGameInfo() would not.

sc2::ReplayInfo replay_info = ReplayControl()->GetReplayInfo();
std::cout << "player_1_race: " << replay_info.players[0].race << std::endl;
std::cout << "player_2_race: " << replay_info.players[1].race << std::endl;

I replicated #259, and I can confirm that obs->GetGameInfo(true) would address the issue. But not sure if that is the design you want to follow. I just think that is not good if two different approaches to obtain the race of a player provide different information.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant