clean up files

This commit is contained in:
Maximilian Keßler 2023-05-13 23:25:15 +02:00
parent 906d7cd974
commit 3fed5b97e8
Signed by: max
GPG key ID: BCC5A619923C0BA5
3 changed files with 11 additions and 19 deletions

View file

@ -6,7 +6,7 @@ from compress import decompress_deck, decompress_actions, compress_actions, link
from hanabi import Action, GameState
from hanab_live import HanabLiveInstance, HanabLiveGameState
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)
@ -58,15 +58,3 @@ def check_game(game_id: int) -> Tuple[int, GameState]:
assert(unsolvable_turn - 1 == solvable_turn)
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

View file

@ -88,7 +88,7 @@ def decompress_actions(actions_str: str) -> List[Action]:
except ValueError as e:
raise InvalidFormatError(
"Invalid action type at action {}: Found {}, expected one of {}".format(
index, actionTypeValue,
index, action_type_value,
[action_type.value for action_type in ActionType]
)
) 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,
# otherwise compression is not possible
def compress_game_state(state: GameState) -> str:
if not state.instance.is_standard():
raise ValueError("Cannot compress non-standard hanabi instance")
# if not state.instance.is_standard():
# raise ValueError("Cannot compress non-standard hanabi instance")
out = "{}{},{},{}".format(
state.instance.num_players,
compress_deck(state.instance.deck),

View file

@ -3,12 +3,16 @@ import requests
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')
def get(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:
return None
if "application/json" in response.headers['content-type']: