-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_data.py
44 lines (32 loc) · 1.64 KB
/
generate_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import sys
import django
import argparse
import names
import random
TEAM_NAMES = ['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega']
TABLE_NAMES = ['Astratti', 'Europei', 'Africani', 'Asiatici', 'Traguardo', 'Connessione', 'Scacchi', 'Dama', 'Atipici', 'Classici', 'Allineamento', 'Gigamic', 'Neoclassici']
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate random teams, players, and tables.')
parser.add_argument('num_teams', type=int, nargs='?', default=8, help='number of teams')
parser.add_argument('num_players', type=int, nargs='?', default=6, help='number of players per team')
parser.add_argument('num_tables', type=int, nargs='?', default=10, help='number of tables')
args = parser.parse_args()
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mtt.settings')
django.setup()
from tournament.models import *
# create teams
print("Create teams")
Team.objects.all().delete()
team_names = TEAM_NAMES[:args.num_teams]
teams = [Team.objects.create(name=name) for name in team_names]
# create players
for team in teams:
players = [Player.objects.create(name=names.get_full_name(), team=team) for i in range(args.num_players)]
print(players)
# create tables
print("Create tables")
Table.objects.all().delete()
table_names = random.sample(TABLE_NAMES, args.num_tables)
tables = [Table.objects.create(name=name, priority=random.randint(0,100)) for name in table_names]
print(tables)