clean up unneeded files, ignore test.py file

This commit is contained in:
Maximilian Keßler 2023-07-05 19:02:09 +02:00
parent f94fe23f60
commit ec60d5f700
Signed by: max
GPG key ID: BCC5A619923C0BA5
3 changed files with 1 additions and 153 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@ hanab.live
venv/ venv/
# pycache dir # pycache dir
__pycache__ __pycache__
test.py
# a few output files # a few output files

63
old.py
View file

@ -1,63 +0,0 @@
def print_suits_and_attrs():
with open("variants.json") as f:
variants = json.loads(f.read())
x = set()
c = []
for var in variants:
for k in var.keys():
x.add(k)
for s in var['suits']:
if s not in c:
c.append(s)
for y in x:
print(y)
print()
for s in c:
print(s)
attributes = {
"nativeColors": ["Red"],
"ranks": 1, # 0: none, 1: default, 2: all
"colors": 1, # 0: none, 1: default, 2: all, 3: prism
"dark": False,
"reversed": False,
"prism": False
}
d = OrderedDict((s, attributes) for s in c)
if not os.path.isfile("colors.json"):
with open("colors.json", "w") as f:
f.writelines(json.dumps(d, indent=4, sort_keys=False))
# need: suit name -> colors
def create_suit_graph():
with open("variants.json") as f:
variants = json.loads(f.read())
G = nx.DiGraph()
for var in variants:
suits = var['suits']
for suit in suits:
if suit not in G.nodes:
G.add_node(suit)
for i in range(0, len(suits) - 1):
G.add_edge(suits[i], suits[i + 1], var=var['name'])
H = nx.DiGraph()
try:
while True:
cycle = nx.find_cycle(G)
# J = nx.DiGraph()
# J.add_edges_from(cycle)
# nx.draw(J, with_labels=True)
H.add_edges_from(cycle)
G.remove_edges_from(cycle)
except nx.NetworkXNoCycle:
pass
nx.draw(H, with_labels=True, font_weight='bold')
plt.show()

90
test.py
View file

@ -1,90 +0,0 @@
from hanabi.live.variants import Variant
from hanabi.live.variants import Suit
from hanabi.live.download_data import download_games, detailed_export_game
from hanabi.database.database import conn, cur
from hanabi.database import init_database
from hanabi.cli import hanabi_cli
def find_double_dark_games():
cur.execute("SELECT variants.id, variants.name, count(suits.id) from variants "
"inner join variant_suits on variants.id = variant_suits.variant_id "
"left join suits on suits.id = variant_suits.suit_id "
"where suits.dark = (%s) "
"group by variants.id "
"order by count(suits.id), variants.id",
(True,)
)
cur2 = conn.cursor()
r = []
for (var_id, var_name, num_dark_suits) in cur.fetchall():
if num_dark_suits == 2:
cur2.execute("select count(*) from games where variant_id = (%s)", (var_id,))
games = cur2.fetchone()[0]
cur2.execute("select count(*) from seeds where variant_id = (%s)", (var_id, ))
r.append((var_name, games, cur2.fetchone()[0]))
l = sorted(r, key=lambda e: -e[1])
for (name, games, seeds) in l:
print("{}: {} games on {} seeds".format(name, games, seeds))
def test_suits():
suit = Suit.from_db(55)
print(suit.__dict__)
def test_variant():
var = Variant.from_db(926)
print(var.__dict__)
def check_missing_ids():
# start = 357849
# end = 358154
start = 358393
end = 358687
# broken_ids = [357913, 357914, 357915] # two of these are no variant
# not_supported_ids = [357925, 357957, 358081]
broken_ids = [358627, 358630, 358632]
not_supported_ids = [
]
for game_id in range(start, end):
if game_id in broken_ids or game_id in not_supported_ids:
continue
print(game_id)
detailed_export_game(game_id)
conn.commit()
def export_all_seeds():
cur.execute(
"SELECT id FROM variants ORDER BY ID"
)
var_ids = cur.fetchall()
for var in var_ids:
download_games(*var)
if __name__ == "__main__":
hanabi_cli()
# init_database.init_database_tables()
# init_database.populate_static_tables()
exit(0)
find_double_dark_games()
exit(0)
var_id = 964532
export_all_seeds()
exit(0)
# init_database_tables()
# populate_static_tables()
download_games(1)
print(variant_name(17888))
for page in range(0, 4):
r = api("variants/0?size=20&col[0]=0&page={}".format(page))
ids = []
for game in r['rows']:
ids.append(game['id'])
r['rows'] = None
print(json.dumps(r, indent=2))
print(ids)