Skip to content

Commit

Permalink
Automatically add all packs to packs workflow (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmekeev authored Mar 13, 2024
1 parent 8b97a3b commit 7617fa5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/emulations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
python-version: '3.11'
- name: Run emulations
run: |
python top_trumps.py --pack ${{ matrix.pack }} --emulations ${{ matrix.emulations }}
python top_trumps.py --pack ${{ matrix.pack }} --emulations ${{ matrix.emulations }} >> $GITHUB_STEP_SUMMARY
13 changes: 11 additions & 2 deletions .github/workflows/packs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ on:
- main

jobs:
list-packs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(ls packs/*.csv | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
run_emulations:
needs: list-packs
runs-on: ubuntu-latest
strategy:
matrix:
pack: ["packs/cats.csv","packs/elements.csv","packs/famous-art-robberies.csv","packs/harry-potter-and-the-deathly-hallows-part-2.csv","packs/mcdonalds-baby-animals.csv","packs/mcdonalds-minions-rise-of-gru.csv","packs/star-wars-rise-of-the-bounty-hunters.csv","packs/star-wars-starships.csv","packs/the-art-game.csv","packs/the-big-bang-theory.csv"] # ls -1 packs/*.csv | jq -Rsc 'split("\n")[:-1]'
pack: ${{ fromJson(needs.list-packs.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -20,4 +29,4 @@ jobs:
python-version: '3.11'
- name: Run emulations
run: |
python top_trumps.py --pack ${{ matrix.pack }}
python top_trumps.py --pack ${{ matrix.pack }} >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion .github/workflows/players.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
python-version: '3.11'
- name: Run emulations
run: |
python top_trumps.py --pack ${{ matrix.pack }} --number_of_players ${{ matrix.players }}
python top_trumps.py --pack ${{ matrix.pack }} --number_of_players ${{ matrix.players }} >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion .github/workflows/strategies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
python-version: '3.11'
- name: Run emulations
run: |
python top_trumps.py --pack ${{ matrix.pack }} --get_stat_index_method ${{ matrix.strategy }}
python top_trumps.py --pack ${{ matrix.pack }} --get_stat_index_method ${{ matrix.strategy }} >> $GITHUB_STEP_SUMMARY
6 changes: 3 additions & 3 deletions top_trumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ def main(pack, number_of_players, emulations, max_exchanges, get_stat_index_meth
endless_games += 1
total_exchanges += exchanges

print(f"Average number of exchanges: {total_exchanges // emulations}")
print(f"Average number of minutes per game: {round(total_exchanges * AVERAGE_NUMBER_OF_SECONDS_PER_EXCHANGE / 60 / emulations)}")
print(f"Number of endless games: {endless_games} ({endless_games * 100 // emulations}%)\n\n")
print(f"* Average number of exchanges: {total_exchanges // emulations}")
print(f"* Average number of minutes per game: {round(total_exchanges * AVERAGE_NUMBER_OF_SECONDS_PER_EXCHANGE / 60 / emulations)}")
print(f"* Number of endless games: {endless_games} ({endless_games * 100 // emulations}%)\n\n")

if __name__ == '__main__':
# read parameters from the command line
Expand Down

0 comments on commit 7617fa5

Please sign in to comment.