-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start an emu cup analysis script (#265)
- **Add emu cup analysis script** - **Only include play actions** - **Pull logic into GameLogEventData**
- Loading branch information
1 parent
557b5af
commit 782c6bf
Showing
8 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
ark_nova_stats/bga_log_parser/fixtures/non_play_event.log.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"uid": "669cd9fd255eb", | ||
"type": "chooseActionCard", | ||
"log": "${player_name} chooses action card ${action_card_name}${action_card_icon}${action_card_level} with strength ${strength_icon}${strength}", | ||
"args": {"actionCard": {"id": 4, "strength": 5, "pId": 93481498, "extraDatas": null, "type": "Association", "status": 1, "level": 1}, "strength": 5, "player_name": "Darcelmaw", "player_id": 93481498, "i18n": ["action_card_name"], "action_card_name": "Association", "action_card_level": "I", "action_card_icon": "", "action_card_type": "Association", "preserve": ["action_card_type"], "strength_icon": ""}, | ||
"lock_uuid": null, | ||
"synchro": null, | ||
"h": "939340" | ||
} |
12 changes: 12 additions & 0 deletions
12
ark_nova_stats/bga_log_parser/fixtures/play_event.log.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"uid": "669cd3629ee68", | ||
"type": "buyAnimal", | ||
"log": "${player_name} plays ${card_name} for ${amount_money} and places it in ${building_name}", | ||
"args": {"card": {"id": "A445_CrestedPorcupine", "location": "inPlay", "state": 19, "pId": 94929538, "extraDatas": null}, "amount": 8, "amount_money": 8, "total": 5, "building": {"id": 8, "location": "board", "state": 1, "pId": 94929538, "type": "size-1", "x": 1, "y": 8, "rotation": 0}, "icons": {"Bird": 1, "Predator": 1, "Herbivore": 1, "Bear": 1, "Reptile": 1, "Pet": 0, "Primate": 0, "Africa": 0, "Europe": 1, "Asia": 1, "Americas": 1, "Australia": 0, "Partner-Zoo": 0, "AnimalsII": 0, "CardsII": 0, "Science": 1, "Fac": 0, "Rock": 2, "Water": 2, "SeaAnimal": 0}, "fromDisplay": false, "player_name": "Duci9", "player_id": 94929538, "i18n": ["building_name", "card_name"], "building_name": {"log": "a size-${n} enclosure", "args": {"n": 1}}, | ||
"card_id": "A445_CrestedPorcupine", | ||
"card_name": "Crested Porcupine", | ||
"preserve": ["card_id"]}, | ||
"lock_uuid": "one", | ||
"synchro": "one", | ||
"h": "08137c" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load("@rules_python//python:defs.bzl", "py_binary") | ||
|
||
filegroup( | ||
name = "game_data", | ||
srcs = glob(["data/*.json"]), | ||
) | ||
|
||
py_binary( | ||
name = "analyze_games", | ||
srcs = ["analyze_games.py"], | ||
data = [":game_data"], | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
"//ark_nova_stats/bga_log_parser:game_log", | ||
"@rules_python//python/runfiles", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
from collections import Counter | ||
from pathlib import Path | ||
from typing import Iterator | ||
|
||
from python.runfiles import Runfiles | ||
|
||
from ark_nova_stats.bga_log_parser.game_log import GameLog | ||
|
||
|
||
def list_game_datafiles() -> Iterator[Path]: | ||
r = Runfiles.Create() | ||
known_game = Path( | ||
r.Rlocation( | ||
"_main/ark_nova_stats/emu_cup/data/539682665_sorryimlikethis_darcelmaw.json" | ||
) | ||
) | ||
return known_game.parent.glob("*.json") | ||
|
||
|
||
def main() -> int: | ||
all_cards: Counter[str] = Counter() | ||
event_logs: set[str] = set() | ||
skipped_event_logs: set[str] = set() | ||
|
||
for p in list_game_datafiles(): | ||
# print(p) | ||
with open(p, "r") as f: | ||
log = GameLog(**json.loads(f.read().strip())) | ||
|
||
game_cards = set() | ||
for event in log.data.logs: | ||
for event_data in event.data: | ||
if not event_data.is_play_action: | ||
continue | ||
|
||
game_cards.add(event_data.args["card_name"]) | ||
|
||
all_cards.update(game_cards) | ||
|
||
print("Most common cards:") | ||
for card, count in all_cards.most_common(10): | ||
print(f" - {card}: {count}") | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
raise SystemExit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.json |
Empty file.