Skip to content

Commit

Permalink
Merge pull request #47 from Kaszanas/scmisa-misa/dev
Browse files Browse the repository at this point in the history
[PR] Keyword Argument Fix, Transform Win/Loss dictionary fix
  • Loading branch information
Kaszanas authored Aug 21, 2024
2 parents e10252d + ea4bd53 commit a113502
Show file tree
Hide file tree
Showing 17 changed files with 286,652 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.4
3.11.3
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ Ready to contribute? Here's how to set up `sc2_datasets` for local development.

4. When you're done making changes, check that your changes conform to any code formatting requirements and pass any tests.

5. Commit your changes and open a pull request.
5. Before running tests make sure to setup environment variable name: `TEST_WORKSPACE` value: `YOUR_PATH_TO_APP`

6. Commit your changes and open a pull request.

## Pull Request Guidelines

Expand Down
93 changes: 22 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,81 +77,32 @@ Interested in contributing? Check out the contributing guidelines. Please note t

`sc2_datasets` project was created by Andrzej Białecki. It is licensed under the terms of the GNU General Public License v3.0 license.

## Citations
## Cite

### This Repository

If you wish to cite the official API for the SC2EGSet: StarCraft II Esport Game State Dataset.

```bibtex
@software{bialecki_andrzej_2022_6930224,
author = {Białecki, Andrzej and
Białecki, Piotr and
Szczap, Andrzej and
Krupiński, Leszek},
title = {Kaszanas/SC2\_Datasets: 1.0.0 SC2\_Datasets Release},
month = jul,
year = 2022,
publisher = {Zenodo},
version = {1.0.0},
doi = {10.5281/zenodo.6629005},
url = {https://doi.org/10.5281/zenodo.6629005}
}
```

### [Dataset Description Pre-print](https://arxiv.org/abs/2207.03428)
### [Dataset Description Article](https://www.researchgate.net/publication/373767449_SC2EGSet_StarCraft_II_Esport_Replay_and_Game-state_Dataset)

To cite the article that introduces [SC2ReSet](https://doi.org/10.5281/zenodo.5575796) and [SC2EGSet](https://doi.org/10.5281/zenodo.5503997) use this:

```bibtex
@misc{https://doi.org/10.48550/arxiv.2207.03428,
doi = {10.48550/ARXIV.2207.03428},
url = {https://arxiv.org/abs/2207.03428},
author = {Białecki, Andrzej and Jakubowska, Natalia and Dobrowolski, Paweł and Białecki, Piotr and Krupiński, Leszek and Szczap, Andrzej and Białecki, Robert and Gajewski, Jan},
keywords = {Machine Learning (cs.LG), Artificial Intelligence (cs.AI), Machine Learning (stat.ML), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {SC2EGSet: StarCraft II Esport Replay and Game-state Dataset},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
```

### [SC2ReSet: StarCraft II Esport Replaypack Set](https://doi.org/10.5281/zenodo.5575796)

To cite the replay collection that was used to generate the dataset use this:

```bibtex
@dataset{bialecki_andrzej_2022_5575797,
author = {Białecki, Andrzej},
title = {SC2ReSet: StarCraft II Esport Replaypack Set},
month = jun,
year = 2022,
publisher = {Zenodo},
version = {1.0.0},
doi = {10.5281/zenodo.5575797},
url = {https://doi.org/10.5281/zenodo.5575797}
}
```

### [SC2EGSet: StarCraft II Esport Game State Dataset](https://doi.org/10.5281/zenodo.5503997)

To cite the data itself use this:

```bibtex
@dataset{bialecki_andrzej_2022_6629349,
author = {Białecki, Andrzej and
Jakubowska, Natalia and
Dobrowolski, Paweł and
Szczap, Andrzej and
Białecki, Robert and
Gajewski, Jan},
title = {SC2EGSet: StarCraft II Esport Game State Dataset},
month = jun,
year = 2022,
publisher = {Zenodo},
version = {1.0.0},
doi = {10.5281/zenodo.6629349},
url = {https://doi.org/10.5281/zenodo.6629349}
@article{Białecki2023,
author = {Bia{\l}ecki, Andrzej
and Jakubowska, Natalia
and Dobrowolski, Pawe{\l}
and Bia{\l}ecki, Piotr
and Krupi{\'{n}}ski, Leszek
and Szczap, Andrzej
and Bia{\l}ecki, Robert
and Gajewski, Jan},
title = {SC2EGSet: StarCraft II Esport Replay and Game-state Dataset},
journal = {Scientific Data},
year = {2023},
month = {Sep},
day = {08},
volume = {10},
number = {1},
pages = {600},
issn = {2052-4463},
doi = {10.1038/s41597-023-02510-7},
url = {https://doi.org/10.1038/s41597-023-02510-7}
}
```
6 changes: 2 additions & 4 deletions docker/docker-test-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
version: '3'
services:

sc2_datasets:
build:
context: '../'
dockerfile: './docker/Dockerfile.dev'
context: "../"
dockerfile: "./docker/Dockerfile.dev"
container_name: test_sc2_datasets
environment:
- TEST_WORKSPACE=/app
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ DEPLOY_DIR = ./docker
TEST_COMPOSE = $(DEPLOY_DIR)/docker-test-compose.yml

action_compose_build:
docker-compose -f $(TEST_COMPOSE) build
docker compose -f $(TEST_COMPOSE) build

action_compose_test: ## Triggered from a GitHub Action to run the tests for CI.
docker-compose -f $(TEST_COMPOSE) run --rm sc2_datasets sh -c "poetry run pytest --ignore-glob='test_*.py' ./tests/test_cases/ --cov=sc2_datasets --cov-report term-missing --cov-report html --cov=xml 2>&1"
docker compose -f $(TEST_COMPOSE) run --rm --build sc2_datasets sh -c "poetry run pytest --ignore-glob='test_*.py' ./tests/test_cases/ --cov=sc2_datasets --cov-report term-missing --cov-report html --cov=xml 2>&1"

doc:
poetry run make html --directory docs/
Expand Down
46 changes: 46 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/sc2_datasets/transforms/mmr_vs_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mmr_vs_result(sc2_replay: SC2ReplayData) -> Tuple[torch.Tensor, torch.Tensor
dtype=torch.float,
)

result_dict = {"Loss": 0, "Win": 1}
result_dict = {"Loss": 0, "Win": 1, "Victory": 1, "Defeat": 0}
label_tensor = torch.tensor(
result_dict[sc2_replay.toonPlayerDescMap[0].toon_player_info.result],
dtype=torch.int8,
Expand Down
6 changes: 2 additions & 4 deletions src/sc2_datasets/transforms/pytorch/economy_vs_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,15 @@ def economy_average_vs_outcome(
If you don't set parameters or paste incorect parameters' type.
"""

average_player_features = average_player_stats(
player_tracker_events=sc2_replay.trackerEvents
)
average_player_features = average_player_stats(sc2_replay)
feature_list = [
player_features for player_features in average_player_features.values()
]

# Creating feature tensor:
feature_tensor = torch.tensor(feature_list, dtype=torch.float32)

result_dict = {"Loss": 0, "Win": 1}
result_dict = {"Loss": 0, "Win": 1, "Victory": 1, "Defeat": 0}
target = result_dict[sc2_replay.toonPlayerDescMap[0].toon_player_info.result]

return feature_tensor, target
2 changes: 1 addition & 1 deletion src/sc2_datasets/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def select_outcome_1v1(sc2_replay: SC2ReplayData) -> Dict[str, int]:

player_outcome = {"1": 0, "2": 0}

result_dict = {"Loss": 0, "Win": 1}
result_dict = {"Loss": 0, "Win": 1, "Victory": 1, "Defeat": 0}
for toon_desc_map in sc2_replay.toonPlayerDescMap:
result = result_dict[toon_desc_map.toon_player_info.result]
player_outcome[toon_desc_map.toon_player_info.playerID] = result
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cases/replay_data/replay_data_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest

import pytest
from pathlib import Path

from sc2_datasets.replay_data.sc2_replay_data import SC2ReplayData
import tests.test_utils.test_utils as test_utils
Expand Down Expand Up @@ -33,4 +34,4 @@ def test_loading_json(self):
def test_empty_json(self):
# Empty json should raise a KeyError:
with self.assertRaises(KeyError):
_ = SC2ReplayData(loaded_replay_object={})
_ = SC2ReplayData(filepath=Path(""), loaded_replay_object={})
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a113502

Please sign in to comment.