clean up files
This commit is contained in:
parent
906d7cd974
commit
3fed5b97e8
3 changed files with 11 additions and 19 deletions
|
@ -6,7 +6,7 @@ from compress import decompress_deck, decompress_actions, compress_actions, link
|
||||||
from hanabi import Action, GameState
|
from hanabi import Action, GameState
|
||||||
from hanab_live import HanabLiveInstance, HanabLiveGameState
|
from hanab_live import HanabLiveInstance, HanabLiveGameState
|
||||||
from sat import solve_sat
|
from sat import solve_sat
|
||||||
from download_data import export_game
|
from download_data import detailed_export_game
|
||||||
|
|
||||||
|
|
||||||
# returns number of first turn before which the game was infeasible (counting from 0)
|
# returns number of first turn before which the game was infeasible (counting from 0)
|
||||||
|
@ -58,15 +58,3 @@ def check_game(game_id: int) -> Tuple[int, GameState]:
|
||||||
|
|
||||||
assert(unsolvable_turn - 1 == solvable_turn)
|
assert(unsolvable_turn - 1 == solvable_turn)
|
||||||
return unsolvable_turn, solution
|
return unsolvable_turn, solution
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
game_id = 921269
|
|
||||||
export_game(game_id)
|
|
||||||
print("checking game {}".format(game_id))
|
|
||||||
turn, sol = check_game(game_id)
|
|
||||||
if turn != 0:
|
|
||||||
print(turn, link(sol))
|
|
||||||
else:
|
|
||||||
print("instance is unfeasible")
|
|
||||||
pass
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ def decompress_actions(actions_str: str) -> List[Action]:
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise InvalidFormatError(
|
raise InvalidFormatError(
|
||||||
"Invalid action type at action {}: Found {}, expected one of {}".format(
|
"Invalid action type at action {}: Found {}, expected one of {}".format(
|
||||||
index, actionTypeValue,
|
index, action_type_value,
|
||||||
[action_type.value for action_type in ActionType]
|
[action_type.value for action_type in ActionType]
|
||||||
)
|
)
|
||||||
) from e
|
) from e
|
||||||
|
@ -165,8 +165,8 @@ def decompress_deck(deck_str: str) -> List[DeckCard]:
|
||||||
# The GameState object has to be standard / fitting hanab.live variants,
|
# The GameState object has to be standard / fitting hanab.live variants,
|
||||||
# otherwise compression is not possible
|
# otherwise compression is not possible
|
||||||
def compress_game_state(state: GameState) -> str:
|
def compress_game_state(state: GameState) -> str:
|
||||||
if not state.instance.is_standard():
|
# if not state.instance.is_standard():
|
||||||
raise ValueError("Cannot compress non-standard hanabi instance")
|
# raise ValueError("Cannot compress non-standard hanabi instance")
|
||||||
out = "{}{},{},{}".format(
|
out = "{}{},{},{}".format(
|
||||||
state.instance.num_players,
|
state.instance.num_players,
|
||||||
compress_deck(state.instance.deck),
|
compress_deck(state.instance.deck),
|
||||||
|
|
|
@ -3,12 +3,16 @@ import requests
|
||||||
import requests_cache
|
import requests_cache
|
||||||
|
|
||||||
|
|
||||||
## Cache all requests to site to reduce traffic and latency
|
# Cache all requests to site to reduce traffic and latency
|
||||||
session = requests_cache.CachedSession('hanab.live')
|
session = requests_cache.CachedSession('hanab.live')
|
||||||
|
|
||||||
|
|
||||||
def get(url):
|
def get(url):
|
||||||
# print("sending request for " + url)
|
# print("sending request for " + url)
|
||||||
response = session.get("https://hanab.live/" + url)
|
query = "https://hanab.live/" + url
|
||||||
|
response = session.get(query)
|
||||||
|
if not response:
|
||||||
|
raise RuntimeError("Failed to get request {} from hanab.live".format(query))
|
||||||
if not response.status_code == 200:
|
if not response.status_code == 200:
|
||||||
return None
|
return None
|
||||||
if "application/json" in response.headers['content-type']:
|
if "application/json" in response.headers['content-type']:
|
||||||
|
|
Loading…
Reference in a new issue