expand cli command solve
This commit is contained in:
parent
a1a5cfac20
commit
11807628fa
2 changed files with 16 additions and 10 deletions
|
@ -98,8 +98,8 @@ def subcommand_download(
|
|||
logger.info("Successfully exported games for all variants")
|
||||
|
||||
|
||||
def subcommand_solve(var_id, timeout: int):
|
||||
instance_finder.solve_unknown_seeds(var_id, timeout)
|
||||
def subcommand_solve(var_id: int, seed_class: int, num_players: Optional[int], timeout: int, ):
|
||||
instance_finder.solve_unknown_seeds(var_id, seed_class, num_players, timeout)
|
||||
|
||||
|
||||
def subcommand_gen_config():
|
||||
|
@ -165,6 +165,8 @@ def add_solve_subparser(subparsers):
|
|||
parser = subparsers.add_parser('solve', help='Seed solving')
|
||||
parser.add_argument('var_id', type=int, help='Variant id to solve instances from.', default=0)
|
||||
parser.add_argument('--timeout', '-t', type=int, help='Timeout [s] for individual seeds.', default=150)
|
||||
parser.add_argument('--class', '-c', type=int, dest='seed_class', help='Class of seed to analyze. 0 stands for hanab.live seeds', default=0)
|
||||
parser.add_argument('--num_players', '-p', type=int, help='Restrict to number of players. If not specified, all player counts are analyzed.', default = None)
|
||||
|
||||
def add_decompress_subparser(subparsers):
|
||||
parser = subparsers.add_parser('decompress', help='Decompress a hanab.live JSON-encoded replay link')
|
||||
|
|
|
@ -188,15 +188,19 @@ def solve_seed(seed, num_players, deck, var_name: str, timeout: Optional[int] =
|
|||
traceback.print_exc()
|
||||
|
||||
|
||||
def solve_unknown_seeds(variant_id, timeout: Optional[int] = 150):
|
||||
def solve_unknown_seeds(variant_id, seed_class: int = 0, num_players: Optional[int] = None, timeout: Optional[int] = 150):
|
||||
variant_name = variants.variant_name(variant_id)
|
||||
database.cur.execute(
|
||||
"SELECT seeds.seed, num_players, array_agg(suit_index order by deck_index asc), array_agg(rank order by deck_index asc) "
|
||||
"FROM seeds "
|
||||
"INNER JOIN decks ON seeds.seed = decks.seed "
|
||||
"WHERE variant_id = (%s) AND num_players = 2 AND class = 1 AND feasible is null "
|
||||
"GROUP BY seeds.seed order by num",
|
||||
(variant_id,)
|
||||
query = "SELECT seeds.seed, num_players, array_agg(suit_index order by deck_index asc), array_agg(rank order by deck_index asc) "\
|
||||
"FROM seeds "\
|
||||
"INNER JOIN decks ON seeds.seed = decks.seed "\
|
||||
"WHERE variant_id = (%s) "\
|
||||
"AND class = (%s) "\
|
||||
"AND feasible IS NULL "
|
||||
if num_players is not None:
|
||||
query += "AND num_players = {} ".format(num_players)
|
||||
query += "GROUP BY seeds.seed ORDER BY num"
|
||||
database.cur.execute(query,
|
||||
(variant_id, seed_class)
|
||||
)
|
||||
res = database.cur.fetchall()
|
||||
data = []
|
||||
|
|
Loading…
Reference in a new issue