Last active
October 10, 2017 21:49
-
-
Save mucaho/12b8862c7f139c4b21ac50f7451412c0 to your computer and use it in GitHub Desktop.
Extract fastest Starcraft II replays that reach max supply, according to [MSC](https://github.com/wuhuikai/MSC)
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"TIME_STEP <> FRAME_ID <> REPLAY_FILE\n", | |
"************************************\n", | |
"508 0.223433893178 ./Protoss_vs_Protoss/Protoss\\1@02fa27ca51e9a1fff7076df41b35e182dda1b4e2f601dbe2def19077878e7b98.SC2Replay.npz\n", | |
"421 0.1708986707 ./Protoss_vs_Protoss/Protoss\\1@0e45174e854b7c08856553fdfe20eabf41429653118f39d24627c377df42fe06.SC2Replay.npz\n", | |
"356 0.147974209982 ./Protoss_vs_Protoss/Protoss\\1@2ffda0c109a9c302c718778644bfe5f0baf4666c0e2295ef4c990fcb7607bf87.SC2Replay.npz\n", | |
"353 0.155615696888 ./Protoss_vs_Zerg/Protoss\\2@9e72db8b0bcb314e49fb47b88eadbd56d7bb78bedd477595a854a3503ea3c085.SC2Replay.npz\n", | |
"************************************\n", | |
"437 0.10756804951 ./Protoss_vs_Terran/Terran\\1@000f8b1acb1daf979242bec5c2f3b458769e3e398d3de3c05b76bb95c438eb94.SC2Replay.npz\n", | |
"420 0.113861645775 ./Protoss_vs_Terran/Terran\\1@0edad2ebcb8f6828aa230319cf2edbe274c8ccab3855e8b5df0a2dba2ba74a19.SC2Replay.npz\n", | |
"373 0.102533172497 ./Protoss_vs_Terran/Terran\\1@7635f72c444347fd704f88fab4eff5bf50202ffd66008f548e1b04d0f85e1520.SC2Replay.npz\n", | |
"365 0.0974982954843 ./Protoss_vs_Terran/Terran\\2@975fe24c5b65c283bc67df759468199d928386e76e6230e0f772589619c07c93.SC2Replay.npz\n", | |
"346 0.0836523836996 ./Terran_vs_Zerg/Terran\\1@e7db05fe6151d91d49bad12f0689e8ffb53853eeb92ec6783dd7f58ad1f4350d.SC2Replay.npz\n", | |
"************************************\n", | |
"550 0.13308266042 ./Protoss_vs_Zerg/Zerg\\1@008f5ca26c45e0f5f6f8027ed75a9dae0c9a92a61bb9d0adb65557da2da84fc5.SC2Replay.npz\n", | |
"467 0.110707020896 ./Protoss_vs_Zerg/Zerg\\1@01937fc0eca2b55010e6c244d8826ae4eb41ab1edddec5cd7ef9a7751ac0c58c.SC2Replay.npz\n", | |
"412 0.119521666769 ./Protoss_vs_Zerg/Zerg\\1@062eb91168cd263677711f7917e2dca118603d51d7c3d75498b394c1a15b31c3.SC2Replay.npz\n", | |
"407 0.0975775134069 ./Protoss_vs_Zerg/Zerg\\1@11697d1dcd63e42aa1fa812d61548ea6934998d1c064d8a3eb2a59bec88fc04a.SC2Replay.npz\n", | |
"354 0.101275966221 ./Protoss_vs_Zerg/Zerg\\1@177c47760d80954ab860161e843b0586fd2d300cc9a994fadbd86f69117e526b.SC2Replay.npz\n", | |
"348 0.102015656784 ./Protoss_vs_Zerg/Zerg\\1@bb9b25c5573eec000402ed60af2c544f33b0bb795bd3facf083754341ab69d7d.SC2Replay.npz\n", | |
"334 0.100906120939 ./Protoss_vs_Zerg/Zerg\\2@25c450874293b0e4ae5bdd1e541f47efd18bdda1eefc84a1c5666116cf032ca2.SC2Replay.npz\n" | |
] | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"import os, os.path\n", | |
"from scipy import sparse\n", | |
"\n", | |
"race_paths = [\n", | |
" ['./Protoss_vs_Protoss/Protoss', './Protoss_vs_Terran/Protoss', './Protoss_vs_Zerg/Protoss'], # PvX\n", | |
" ['./Protoss_vs_Terran/Terran', './Terran_vs_Terran/Terran', './Terran_vs_Zerg/Terran'], # TvX\n", | |
" ['./Protoss_vs_Zerg/Zerg', './Terran_vs_Zerg/Zerg', './Zerg_vs_Zerg/Zerg'] # ZvX\n", | |
"]\n", | |
"\n", | |
"print('TIME_STEP <> FRAME_ID <> REPLAY_FILE')\n", | |
"for paths in race_paths:\n", | |
" print('************************************')\n", | |
" min_cap_time, min_cap_frame, min_cap_file = np.inf, np.inf, 'NULL'\n", | |
" for path in paths:\n", | |
" files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]\n", | |
" for f in files:\n", | |
" f = os.path.join(path, f)\n", | |
" F = np.asarray(sparse.load_npz(f).todense())\n", | |
" food_used = F[:, 19] # extract current supply used\n", | |
" food_cap_time = np.where(np.isclose(food_used, 1.0)) # max supply is when it's 1.0\n", | |
" if len(food_cap_time[0]) > 0:\n", | |
" if food_cap_time[0][0] < min_cap_time:\n", | |
" min_cap_file = f\n", | |
" min_cap_time = food_cap_time[0][0]\n", | |
" min_cap_frame = F[min_cap_time, 15] # extract frame_id\n", | |
" print(min_cap_time, min_cap_frame, min_cap_file) \n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment