Skip to content
Snippets Groups Projects
Commit 08a679e1 authored by Rojikku98's avatar Rojikku98
Browse files

Some smallfixes

parent 9be6bd16
No related branches found
No related tags found
1 merge request!6Replays
IDABot
======
IDAReplayObserver
=================
.. class:: library.IDAReplayObserver
This is the basis of a replayObserver.
This is a class for following a replay. Se :ref:`Replays <replays>` for a example.
Inherited methods:
.. method:: IDAReplayObserver.on_game_start(self)
This method is called when a Starcraft replay has stared, when you inherit it you have to
This method is called when a replay has stared, when you inherit it you have to
call the parent's on_game_start method in order to make it work (see
:ref:`replays`).
......@@ -27,13 +27,13 @@ IDABot
Methods:
.. method:: IDABot.get_all_units(self) -> List[library.ReplayUnit]
.. method:: IDAReplayObserver.get_all_units(self) -> List[library.ReplayUnit]
Retrieves a list of all visible units
.. method:: IDAReplayObserver.get_player_race(self, player_id) -> library.Race
Attributes:
Returns the players race
.. autoattribute:: minerals
......@@ -28,6 +28,9 @@ Table of contents
types
coordinates
constants
replays
idareplayobserver
replayuinit
.. autosummary::
:toctree: _autosummary
......
Replays
=======
This page will describe two different techniques for handling replays. The
first technique parses the information saved in the replay file. The secund
first technique parses the information saved in the replay file. The second
uses the information in the replay file to actually replay the game. The
different techniques have serten advetedeges and disadvantages.
different techniques have certain advantages and disadvantages. The main
one is that the reader is a lot faster while replaying the game provides
a lot more information.
......@@ -89,12 +91,14 @@ that no action can be preform just observations. No debug actions can be taken.
IDAReplayObserver.on_game_end(self)
def main():
coordinator = Coordinator(r"D:\StarCraft II\Versions\Base69232\SC2_x64.exe")
print(coordinator.load_replay_list("D:\\Replays\\"))
my_observer = MyObserver()
coordinator.add_replay_observer(my_observer)
coordinator = Coordinator(r"D:/StarCraft II/Versions/Base69232/SC2_x64.exe")
if coordinator.load_replay_list("D:/Replays/"):
observer = MyObserver()
coordinator.add_replay_observer(observer)
while coordinator.update():
pass
else:
print("No replays found")
if __name__ == "__main__":
main()
......
Unit
====
ReplayUnit
==========
.. class:: library.ReplayUnit
......
......@@ -99,6 +99,7 @@ PYBIND11_MODULE(library, m)
.def("on_step", &IDAReplayObserver::OnStep)
.def("on_game_end", &IDAReplayObserver::OnGameEnd)
.def("get_all_units", &IDAReplayObserver::GetAllUnits, "Returns a list of all units")
.def("get_player_race", &IDAReplayObserver::GetPlayerRace,"player_id"_a)
;
py::class_<sc2::PlayerSetup>(m, "PlayerSetup");
......
......@@ -57,4 +57,19 @@ const std::vector<ReplayUnit>& IDAReplayObserver::GetAllUnits() const
return m_allUnits;
}
CCRace IDAReplayObserver::GetPlayerRace(int player) const
{
auto playerID = Observation()->GetPlayerID();
for (auto & playerInfo : Observation()->GetGameInfo().player_info)
{
if (playerInfo.player_id == playerID)
{
return playerInfo.race_actual;
}
}
BOT_ASSERT(false, "Failed to find the player's race!");
return sc2::Race::Random;
}
......@@ -25,6 +25,7 @@ public:
ReplayUnit GetUnit(const CCUnitID tag) const;
const std::vector<ReplayUnit> & GetAllUnits() const;
CCRace GetPlayerRace(int player) const;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment