Archiatrus / Sc2AutoObserver

Other
4 stars 0 forks source link

Sc2AutoObserver

How to use with sc2::Agent:

  1. Initialize the camera module with a sc2::Agent

    CameraModuleAgent cameraModuleAgent(sc2::Agent * const bot);
  2. Call the onStart and onFrame functions with the onStart and onStep functions of the agent.

    
    void sc2::Agent::OnGameStart() 
    {
    ...
    cameraModuleAgent.onStart();
    ...
    }

void sc2::Agent::OnStep() { ... cameraModuleAgent.onFrame(); ... }


3. Call the moveCameraUnitCreated function with the onUnitCreate function of the agent.
```c++
void sc2::Agent::OnUnitCreated(const sc2::Unit * unit)
{
    ...
    cameraModuleAgent.moveCameraUnitCreated(const sc2::Unit * unit)
    ...
}

An example of an bot that uses the Sc2AutoObserver can be found here: https://github.com/Archiatrus/5minBot A replay showcasing the camera movement can be found in examples. Just select the vision of the Terran player. In case of an unable to open map error, open a game vs AI on Interloper LE in the real game and try again.

How to use with sc2::ReplayObserver

  1. Initialize the camera module with a sc2::ReplayObserver

    CameraModuleObserver cameraModuleObserver(sc2::Agent * const bot);
  2. Call the onStart and onFrame functions with the onStart and onStep functions of the Observer.

    
    void sc2::Observer::OnGameStart() 
    {
    ...
    cameraModuleObserver.onStart();
    ...
    }

void sc2::Observer::OnStep() { ... cameraModuleObserver.onFrame(); ... }


3. Call the moveCameraUnitCreated function with the onUnitCreate function of the Observer.
```c++
void sc2::Observer::OnUnitCreated(const sc2::Unit * unit)
{
    ...
    cameraModuleObserver.moveCameraUnitCreated(const sc2::Unit * unit)
    ...
}

An example of an command line program that uses the Sc2AutoObserver and plays a replay can be found in the examples directory.