diff --git a/leaderboard/README b/leaderboard/README new file mode 100644 index 0000000..1475a87 --- /dev/null +++ b/leaderboard/README @@ -0,0 +1,13 @@ +To run the leaderboard server: + +Make sure Django is installed: +- pip install django + +Make sure rlcard is installed: +- git clone https://github.com/datamllab/rlcard.git +- cd rlcard +- pip install -e . + +Run server: +(Make sure you are in the same folder as manage.py) +- python3 manage.py runserver diff --git a/leaderboard/db.sqlite3 b/leaderboard/db.sqlite3 new file mode 100644 index 0000000..ee8d71a Binary files /dev/null and b/leaderboard/db.sqlite3 differ diff --git a/leaderboard/leaderboard/__init__.py b/leaderboard/leaderboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leaderboard/leaderboard/__pycache__/__init__.cpython-36.pyc b/leaderboard/leaderboard/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..c4813bc Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/__init__.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/__init__.cpython-37.pyc b/leaderboard/leaderboard/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..d2c4d3a Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/__init__.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/admin.cpython-36.pyc b/leaderboard/leaderboard/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000..a32b3c1 Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/admin.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/admin.cpython-37.pyc b/leaderboard/leaderboard/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..5a1a41c Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/admin.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/apps.cpython-36.pyc b/leaderboard/leaderboard/__pycache__/apps.cpython-36.pyc new file mode 100644 index 0000000..e6b44ee Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/apps.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/apps.cpython-37.pyc b/leaderboard/leaderboard/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000..2ff1e31 Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/apps.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/models.cpython-36.pyc b/leaderboard/leaderboard/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000..194da61 Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/models.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/models.cpython-37.pyc b/leaderboard/leaderboard/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..8201de0 Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/models.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/urls.cpython-36.pyc b/leaderboard/leaderboard/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..b71fd80 Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/urls.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/urls.cpython-37.pyc b/leaderboard/leaderboard/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..6f1968c Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/urls.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/views.cpython-36.pyc b/leaderboard/leaderboard/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..82decfa Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/views.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/__pycache__/views.cpython-37.pyc b/leaderboard/leaderboard/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000..eafcca5 Binary files /dev/null and b/leaderboard/leaderboard/__pycache__/views.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/admin.py b/leaderboard/leaderboard/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/leaderboard/leaderboard/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/leaderboard/leaderboard/apps.py b/leaderboard/leaderboard/apps.py new file mode 100644 index 0000000..db7750d --- /dev/null +++ b/leaderboard/leaderboard/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class LeaderboardConfig(AppConfig): + name = 'leaderboard' diff --git a/leaderboard/leaderboard/migrations/0001_initial.py b/leaderboard/leaderboard/migrations/0001_initial.py new file mode 100644 index 0000000..280b6c3 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0001_initial.py @@ -0,0 +1,42 @@ +# Generated by Django 3.0.3 on 2020-02-19 23:33 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Agent', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('modelID', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='Game', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('gameID', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='winRate', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('winRate', models.DecimalField(decimal_places=3, max_digits=3)), + ('agent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leaderboard.Agent')), + ], + ), + migrations.AddField( + model_name='agent', + name='game', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leaderboard.Game'), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0002_remove_agent_game.py b/leaderboard/leaderboard/migrations/0002_remove_agent_game.py new file mode 100644 index 0000000..77545e7 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0002_remove_agent_game.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0.3 on 2020-02-19 23:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='agent', + name='game', + ), + ] diff --git a/leaderboard/leaderboard/migrations/0003_auto_20200219_2352.py b/leaderboard/leaderboard/migrations/0003_auto_20200219_2352.py new file mode 100644 index 0000000..d81323d --- /dev/null +++ b/leaderboard/leaderboard/migrations/0003_auto_20200219_2352.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.3 on 2020-02-19 23:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0002_remove_agent_game'), + ] + + operations = [ + migrations.AlterField( + model_name='game', + name='gameID', + field=models.CharField(max_length=100), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0004_auto_20200220_0006.py b/leaderboard/leaderboard/migrations/0004_auto_20200220_0006.py new file mode 100644 index 0000000..0d5e9bd --- /dev/null +++ b/leaderboard/leaderboard/migrations/0004_auto_20200220_0006.py @@ -0,0 +1,35 @@ +# Generated by Django 3.0.3 on 2020-02-20 00:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0003_auto_20200219_2352'), + ] + + operations = [ + migrations.CreateModel( + name='Rate', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('rate', models.DecimalField(decimal_places=3, max_digits=3)), + ('agent', models.CharField(max_length=100)), + ('game', models.CharField(max_length=100)), + ], + ), + migrations.DeleteModel( + name='Game', + ), + migrations.RemoveField( + model_name='winrate', + name='agent', + ), + migrations.DeleteModel( + name='Agent', + ), + migrations.DeleteModel( + name='winRate', + ), + ] diff --git a/leaderboard/leaderboard/migrations/0005_agent_game.py b/leaderboard/leaderboard/migrations/0005_agent_game.py new file mode 100644 index 0000000..34e1e85 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0005_agent_game.py @@ -0,0 +1,34 @@ +# Generated by Django 3.0.3 on 2020-02-20 21:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0004_auto_20200220_0006'), + ] + + operations = [ + migrations.CreateModel( + name='Agent', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('gamesPlayed', models.IntegerField()), + ('winRate', models.DecimalField(decimal_places=3, max_digits=3)), + ('gamesWon', models.IntegerField()), + ('opponent', models.CharField(max_length=100)), + ('agentID', models.CharField(max_length=100)), + ('totalGamesPlayed', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='Game', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('gameID', models.IntegerField()), + ('replayID', models.IntegerField()), + ('replayLink', models.CharField(max_length=100)), + ], + ), + ] diff --git a/leaderboard/leaderboard/migrations/0006_auto_20200220_2208.py b/leaderboard/leaderboard/migrations/0006_auto_20200220_2208.py new file mode 100644 index 0000000..a0fb296 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0006_auto_20200220_2208.py @@ -0,0 +1,26 @@ +# Generated by Django 3.0.3 on 2020-02-20 22:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0005_agent_game'), + ] + + operations = [ + migrations.DeleteModel( + name='Rate', + ), + migrations.AddField( + model_name='game', + name='agent1', + field=models.CharField(default='agent', max_length=100), + ), + migrations.AddField( + model_name='game', + name='agent2', + field=models.CharField(default='agent', max_length=100), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0007_agent_rank.py b/leaderboard/leaderboard/migrations/0007_agent_rank.py new file mode 100644 index 0000000..f4b025a --- /dev/null +++ b/leaderboard/leaderboard/migrations/0007_agent_rank.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.3 on 2020-02-21 22:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0006_auto_20200220_2208'), + ] + + operations = [ + migrations.AddField( + model_name='agent', + name='rank', + field=models.IntegerField(default=1), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0008_auto_20200221_2307.py b/leaderboard/leaderboard/migrations/0008_auto_20200221_2307.py new file mode 100644 index 0000000..ca2f22f --- /dev/null +++ b/leaderboard/leaderboard/migrations/0008_auto_20200221_2307.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.3 on 2020-02-21 23:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0007_agent_rank'), + ] + + operations = [ + migrations.AlterField( + model_name='game', + name='gameID', + field=models.CharField(default='blackjack', max_length=100), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0009_auto_20200224_0216.py b/leaderboard/leaderboard/migrations/0009_auto_20200224_0216.py new file mode 100644 index 0000000..60b9546 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0009_auto_20200224_0216.py @@ -0,0 +1,67 @@ +# Generated by Django 3.0.3 on 2020-02-24 02:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0008_auto_20200221_2307'), + ] + + operations = [ + migrations.RemoveField( + model_name='agent', + name='rank', + ), + migrations.AddField( + model_name='agent', + name='agentName', + field=models.CharField(default='DQN', max_length=100), + ), + migrations.AlterField( + model_name='agent', + name='agentID', + field=models.CharField(default='agent007', max_length=100, unique=True), + ), + migrations.AlterField( + model_name='agent', + name='gamesPlayed', + field=models.IntegerField(default=1), + ), + migrations.AlterField( + model_name='agent', + name='gamesWon', + field=models.IntegerField(default=1), + ), + migrations.AlterField( + model_name='agent', + name='opponent', + field=models.CharField(default='DQN', max_length=100), + ), + migrations.AlterField( + model_name='agent', + name='totalGamesPlayed', + field=models.IntegerField(default=1), + ), + migrations.AlterField( + model_name='agent', + name='winRate', + field=models.DecimalField(decimal_places=3, default=0.5, max_digits=3), + ), + migrations.AlterField( + model_name='game', + name='gameID', + field=models.IntegerField(default=1, unique=True), + ), + migrations.AlterField( + model_name='game', + name='replayID', + field=models.IntegerField(default=1, unique=True), + ), + migrations.AlterField( + model_name='game', + name='replayLink', + field=models.CharField(default='replay00001', max_length=100), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0010_auto_20200224_2034.py b/leaderboard/leaderboard/migrations/0010_auto_20200224_2034.py new file mode 100644 index 0000000..efcd570 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0010_auto_20200224_2034.py @@ -0,0 +1,38 @@ +# Generated by Django 3.0.3 on 2020-02-24 20:34 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0009_auto_20200224_0216'), + ] + + operations = [ + migrations.RemoveField( + model_name='agent', + name='opponent', + ), + migrations.AddField( + model_name='agent', + name='rank', + field=models.IntegerField(default=1), + ), + migrations.AlterField( + model_name='agent', + name='agentID', + field=models.CharField(default=uuid.UUID('23a054be-5119-44f7-b770-60556c8767e4'), max_length=100, unique=True), + ), + migrations.AlterField( + model_name='game', + name='gameID', + field=models.CharField(default=uuid.UUID('f524b126-2ee6-4a5d-ab4a-02af1bbd5347'), max_length=100, unique=True), + ), + migrations.AlterField( + model_name='game', + name='replayID', + field=models.CharField(default=uuid.UUID('f5003307-246e-473c-b9d4-fc814c832a1a'), max_length=100, unique=True), + ), + ] diff --git a/leaderboard/leaderboard/migrations/0011_auto_20200225_0146.py b/leaderboard/leaderboard/migrations/0011_auto_20200225_0146.py new file mode 100644 index 0000000..0ae59c8 --- /dev/null +++ b/leaderboard/leaderboard/migrations/0011_auto_20200225_0146.py @@ -0,0 +1,34 @@ +# Generated by Django 3.0.3 on 2020-02-25 01:46 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('leaderboard', '0010_auto_20200224_2034'), + ] + + operations = [ + migrations.AddField( + model_name='game', + name='gameName', + field=models.CharField(default="Leduc Hold'em", max_length=100), + ), + migrations.AlterField( + model_name='agent', + name='agentID', + field=models.CharField(default=uuid.UUID('63db4377-14d9-495c-be7f-4f202226277e'), max_length=100, unique=True), + ), + migrations.AlterField( + model_name='game', + name='gameID', + field=models.CharField(default=uuid.UUID('fcc0a8ae-ade7-4abe-9e70-2cc64bd4230b'), max_length=100, unique=True), + ), + migrations.AlterField( + model_name='game', + name='replayID', + field=models.CharField(default=uuid.UUID('44ec8c34-9cf5-4cc9-8779-51baf936c7d2'), max_length=100, unique=True), + ), + ] diff --git a/leaderboard/leaderboard/migrations/__init__.py b/leaderboard/leaderboard/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leaderboard/leaderboard/migrations/__pycache__/0001_initial.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000..a54ca6b Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0001_initial.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0001_initial.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000..7e75b89 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0002_remove_agent_game.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0002_remove_agent_game.cpython-36.pyc new file mode 100644 index 0000000..c1264d1 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0002_remove_agent_game.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0002_remove_agent_game.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0002_remove_agent_game.cpython-37.pyc new file mode 100644 index 0000000..9df5f46 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0002_remove_agent_game.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0003_auto_20200219_2352.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0003_auto_20200219_2352.cpython-36.pyc new file mode 100644 index 0000000..b22030f Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0003_auto_20200219_2352.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0003_auto_20200219_2352.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0003_auto_20200219_2352.cpython-37.pyc new file mode 100644 index 0000000..3a062ca Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0003_auto_20200219_2352.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0004_auto_20200220_0006.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0004_auto_20200220_0006.cpython-36.pyc new file mode 100644 index 0000000..d585e63 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0004_auto_20200220_0006.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0004_auto_20200220_0006.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0004_auto_20200220_0006.cpython-37.pyc new file mode 100644 index 0000000..432488a Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0004_auto_20200220_0006.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0005_agent_game.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0005_agent_game.cpython-36.pyc new file mode 100644 index 0000000..102ce96 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0005_agent_game.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0005_agent_game.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0005_agent_game.cpython-37.pyc new file mode 100644 index 0000000..c9c6fbf Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0005_agent_game.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0006_auto_20200220_2208.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0006_auto_20200220_2208.cpython-36.pyc new file mode 100644 index 0000000..c0f27ec Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0006_auto_20200220_2208.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0006_auto_20200220_2208.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0006_auto_20200220_2208.cpython-37.pyc new file mode 100644 index 0000000..4a33418 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0006_auto_20200220_2208.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0007_agent_rank.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0007_agent_rank.cpython-36.pyc new file mode 100644 index 0000000..44032fa Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0007_agent_rank.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0007_agent_rank.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0007_agent_rank.cpython-37.pyc new file mode 100644 index 0000000..f9ce1cf Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0007_agent_rank.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0008_auto_20200221_2307.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0008_auto_20200221_2307.cpython-36.pyc new file mode 100644 index 0000000..b926985 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0008_auto_20200221_2307.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0008_auto_20200221_2307.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0008_auto_20200221_2307.cpython-37.pyc new file mode 100644 index 0000000..72734c9 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0008_auto_20200221_2307.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0009_auto_20200224_0216.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0009_auto_20200224_0216.cpython-36.pyc new file mode 100644 index 0000000..53e897f Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0009_auto_20200224_0216.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0009_auto_20200224_0216.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0009_auto_20200224_0216.cpython-37.pyc new file mode 100644 index 0000000..deb7ad5 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0009_auto_20200224_0216.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0010_auto_20200224_2034.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0010_auto_20200224_2034.cpython-36.pyc new file mode 100644 index 0000000..88dda6e Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0010_auto_20200224_2034.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0010_auto_20200224_2034.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0010_auto_20200224_2034.cpython-37.pyc new file mode 100644 index 0000000..1ba81a3 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0010_auto_20200224_2034.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0011_auto_20200225_0146.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/0011_auto_20200225_0146.cpython-36.pyc new file mode 100644 index 0000000..7b1d3d5 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0011_auto_20200225_0146.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/0011_auto_20200225_0146.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/0011_auto_20200225_0146.cpython-37.pyc new file mode 100644 index 0000000..15d8ce3 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/0011_auto_20200225_0146.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/__init__.cpython-36.pyc b/leaderboard/leaderboard/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..db26633 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/leaderboard/leaderboard/migrations/__pycache__/__init__.cpython-37.pyc b/leaderboard/leaderboard/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..b842404 Binary files /dev/null and b/leaderboard/leaderboard/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/leaderboard/leaderboard/models.py b/leaderboard/leaderboard/models.py new file mode 100644 index 0000000..a09048f --- /dev/null +++ b/leaderboard/leaderboard/models.py @@ -0,0 +1,30 @@ +from django.db import models +import uuid + + +class Agent(models.Model): + gamesPlayed = models.IntegerField(default = 1) + winRate = models.DecimalField(max_digits=3, decimal_places=3, default = 0.5) + gamesWon = models.IntegerField(default = 1) + rank = models.IntegerField(default = 1) + agentID = models.CharField(max_length=100, unique = True, default = uuid.uuid4()) + agentName = models.CharField(max_length=100, default = 'DQN') + totalGamesPlayed = models.IntegerField(default = 1) + + +class Game(models.Model): + gameID = models.CharField(max_length=100, unique = True, default = uuid.uuid4()) + gameName = models.CharField(max_length=100, default="Leduc Hold'em") + agent1 = models.CharField(max_length=100, default="agent") + agent2 = models.CharField(max_length=100, default="agent") + replayID = models.CharField(max_length=100, unique = True, default = uuid.uuid4()) + replayLink = models.CharField(max_length=100, default = 'replay00001') + + + + + + + + + diff --git a/leaderboard/leaderboard/static/leaderboard/main.css b/leaderboard/leaderboard/static/leaderboard/main.css new file mode 100644 index 0000000..92db384 --- /dev/null +++ b/leaderboard/leaderboard/static/leaderboard/main.css @@ -0,0 +1,84 @@ +body { + background: #fafafa; + color: #333333; + margin-top: 5rem; + } + + h1, h2, h3, h4, h5, h6 { + color: #444444; + } + + ul { + margin: 0; + } + + .bg-steel { + background-color: #4882c5; + } + + .site-header .navbar-nav .nav-link { + color: #cbd5db; + } + + .site-header .navbar-nav .nav-link:hover { + color: #ffffff; + } + + .site-header .navbar-nav .nav-link.active { + font-weight: 500; + } + + .content-section { + background: #ffffff; + padding: 10px 20px; + border: 1px solid #dddddd; + border-radius: 3px; + margin-bottom: 20px; + } + + .article-title { + color: #444444; + } + + a.article-title:hover { + color: #428dca; + text-decoration: none; + } + + .article-content { + white-space: pre-line; + } + + .article-img { + height: 65px; + width: 65px; + margin-right: 16px; + } + + .article-metadata { + padding-bottom: 1px; + margin-bottom: 4px; + border-bottom: 1px solid #e3e3e3 + } + + .article-metadata a:hover { + color: #333; + text-decoration: none; + } + + .article-svg { + width: 25px; + height: 25px; + vertical-align: middle; + } + + .account-img { + height: 125px; + width: 125px; + margin-right: 20px; + margin-bottom: 16px; + } + + .account-heading { + font-size: 2.5rem; + } \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/about.html b/leaderboard/leaderboard/templates/leaderboard/about.html new file mode 100644 index 0000000..90fc62b --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/about.html @@ -0,0 +1,22 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: About +{% endblock title %} + +{% block header %} +About RLCard +{% endblock header %} + +{% block content %} +
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc lobortis mattis aliquam faucibus purus. Pretium aenean pharetra magna ac placerat vestibulum lectus mauris. Lacus laoreet non curabitur gravida arcu ac tortor. Pulvinar elementum integer enim neque volutpat ac. Enim sit amet venenatis urna. Amet risus nullam eget felis. Eu consequat ac felis donec et odio pellentesque diam. Congue nisi vitae suscipit tellus mauris a diam. Tellus elementum sagittis vitae et leo duis ut diam. Id leo in vitae turpis. Metus dictum at tempor commodo ullamcorper. Turpis cursus in hac habitasse platea dictumst. Lacus viverra vitae congue eu consequat ac felis. Justo donec enim diam vulputate ut. Donec pretium vulputate sapien nec sagittis.

+ +

Sit amet risus nullam eget felis eget nunc lobortis. Quam vulputate dignissim suspendisse in. Tortor posuere ac ut consequat semper. Pretium aenean pharetra magna ac placerat vestibulum. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt. Iaculis urna id volutpat lacus laoreet non curabitur gravida. Odio facilisis mauris sit amet massa vitae tortor condimentum. Viverra adipiscing at in tellus integer. Et egestas quis ipsum suspendisse ultrices gravida dictum fusce. Sapien pellentesque habitant morbi tristique senectus et netus et. Orci porta non pulvinar neque laoreet suspendisse interdum consectetur. Ornare suspendisse sed nisi lacus sed viverra tellus. In tellus integer feugiat scelerisque varius morbi enim nunc faucibus. Amet massa vitae tortor condimentum. Turpis tincidunt id aliquet risus.

+ +

Euismod lacinia at quis risus sed vulputate odio ut. Eu consequat ac felis donec. Mattis enim ut tellus elementum sagittis vitae et leo duis. Proin libero nunc consequat interdum varius sit amet mattis. Felis eget velit aliquet sagittis id consectetur purus ut. Eget egestas purus viverra accumsan in nisl nisi scelerisque eu. Cras semper auctor neque vitae tempus quam pellentesque nec. Id porta nibh venenatis cras sed felis eget. Neque viverra justo nec ultrices dui sapien eget mi. Nunc sed id semper risus in hendrerit gravida rutrum.

+ +

Orci sagittis eu volutpat odio facilisis mauris sit amet. Nisi est sit amet facilisis magna. Mi proin sed libero enim sed faucibus turpis. Magna sit amet purus gravida. A lacus vestibulum sed arcu non odio euismod. Massa tincidunt nunc pulvinar sapien et. Iaculis eu non diam phasellus vestibulum. Ultrices dui sapien eget mi proin sed. Blandit cursus risus at ultrices mi tempus imperdiet. Non arcu risus quis varius quam. Vitae congue mauris rhoncus aenean vel elit. Interdum velit laoreet id donec ultrices tincidunt arcu. Duis ultricies lacus sed turpis tincidunt id. Lacus vestibulum sed arcu non odio. Quis hendrerit dolor magna eget est. Nulla facilisi etiam dignissim diam quis enim lobortis. Placerat vestibulum lectus mauris ultrices.

+ +

Amet est placerat in egestas erat imperdiet sed euismod nisi. Volutpat est velit egestas dui id ornare arcu odio ut. At lectus urna duis convallis convallis tellus. Amet purus gravida quis blandit turpis cursus in hac. Ipsum suspendisse ultrices gravida dictum fusce ut placerat orci nulla. Viverra mauris in aliquam sem fringilla ut. Sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit. Ultricies tristique nulla aliquet enim. Vivamus arcu felis bibendum ut tristique et egestas quis ipsum. Euismod nisi porta lorem mollis aliquam ut. Sed viverra ipsum nunc aliquet bibendum enim facilisis. Vitae proin sagittis nisl rhoncus mattis. Etiam sit amet nisl purus in mollis nunc. Amet nisl suscipit adipiscing bibendum est ultricies integer. Tincidunt vitae semper quis lectus nulla at volutpat diam. Vel elit scelerisque mauris pellentesque.

+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/base.html b/leaderboard/leaderboard/templates/leaderboard/base.html new file mode 100644 index 0000000..2b3736b --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/base.html @@ -0,0 +1,85 @@ +{% load static %} + + +{% block title %}{% endblock %} + + + + + + + + + + + + + + +
+ + +
+ +
+
+ +
+ +
+ {% block header %}{% endblock %} +
+
+ + {% block content %}{% endblock %} +
+ +
+ © Copyright DATA Lab at Texas A&M University
+ Powered by w3.css +
+ + + + + + + + \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/blackjack.html b/leaderboard/leaderboard/templates/leaderboard/blackjack.html new file mode 100644 index 0000000..563e32b --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/blackjack.html @@ -0,0 +1,36 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Blackjack +{% endblock title %} + +{% block header %} +Blackjack Leaderboard +{% endblock header %} + +{% block content %} +
+

Currently Unavailable

+

Try Ludec Hold'em

+
+ + +{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/cfr.html b/leaderboard/leaderboard/templates/leaderboard/cfr.html new file mode 100644 index 0000000..e70b4ba --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/cfr.html @@ -0,0 +1,33 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: CFR +{% endblock title %} + +{% block header %} +CFR +{% endblock header %} + +{% block content %} +
+ + + + + + + + + + + {% for game in games %} + + + + + + + {% endfor %} + +
Replay IDOpponentGameReplay Link
{{ game.replayID }}{{ game.agent2 }}{{ game.gameName }}{{ game.replayLink }}
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/doudizhu.html b/leaderboard/leaderboard/templates/leaderboard/doudizhu.html new file mode 100644 index 0000000..8d58be7 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/doudizhu.html @@ -0,0 +1,36 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Dou Dizhu +{% endblock title %} + +{% block header %} +Dou Dizhu Leaderboard +{% endblock header %} + +{% block content %} +
+

Currently Unavailable

+

Try Ludec Hold'em

+
+ + +{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/dqn.html b/leaderboard/leaderboard/templates/leaderboard/dqn.html new file mode 100644 index 0000000..7c305cc --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/dqn.html @@ -0,0 +1,33 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: DQN +{% endblock title %} + +{% block header %} +DQN +{% endblock header %} + +{% block content %} +
+ + + + + + + + + + + {% for game in games %} + + + + + + + {% endfor %} + +
Replay IDOpponentGameReplay Link
{{ game.replayID }}{{ game.agent2 }}{{ game.gameName }}{{ game.replayLink }}
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/getting_started.html b/leaderboard/leaderboard/templates/leaderboard/getting_started.html new file mode 100644 index 0000000..6cb93f0 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/getting_started.html @@ -0,0 +1,22 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Getting Started +{% endblock title %} + +{% block header %} +Getting Started +{% endblock header %} + +{% block content %} +
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc lobortis mattis aliquam faucibus purus. Pretium aenean pharetra magna ac placerat vestibulum lectus mauris. Lacus laoreet non curabitur gravida arcu ac tortor. Pulvinar elementum integer enim neque volutpat ac. Enim sit amet venenatis urna. Amet risus nullam eget felis. Eu consequat ac felis donec et odio pellentesque diam. Congue nisi vitae suscipit tellus mauris a diam. Tellus elementum sagittis vitae et leo duis ut diam. Id leo in vitae turpis. Metus dictum at tempor commodo ullamcorper. Turpis cursus in hac habitasse platea dictumst. Lacus viverra vitae congue eu consequat ac felis. Justo donec enim diam vulputate ut. Donec pretium vulputate sapien nec sagittis.

+ +

Sit amet risus nullam eget felis eget nunc lobortis. Quam vulputate dignissim suspendisse in. Tortor posuere ac ut consequat semper. Pretium aenean pharetra magna ac placerat vestibulum. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt. Iaculis urna id volutpat lacus laoreet non curabitur gravida. Odio facilisis mauris sit amet massa vitae tortor condimentum. Viverra adipiscing at in tellus integer. Et egestas quis ipsum suspendisse ultrices gravida dictum fusce. Sapien pellentesque habitant morbi tristique senectus et netus et. Orci porta non pulvinar neque laoreet suspendisse interdum consectetur. Ornare suspendisse sed nisi lacus sed viverra tellus. In tellus integer feugiat scelerisque varius morbi enim nunc faucibus. Amet massa vitae tortor condimentum. Turpis tincidunt id aliquet risus.

+ +

Euismod lacinia at quis risus sed vulputate odio ut. Eu consequat ac felis donec. Mattis enim ut tellus elementum sagittis vitae et leo duis. Proin libero nunc consequat interdum varius sit amet mattis. Felis eget velit aliquet sagittis id consectetur purus ut. Eget egestas purus viverra accumsan in nisl nisi scelerisque eu. Cras semper auctor neque vitae tempus quam pellentesque nec. Id porta nibh venenatis cras sed felis eget. Neque viverra justo nec ultrices dui sapien eget mi. Nunc sed id semper risus in hendrerit gravida rutrum.

+ +

Orci sagittis eu volutpat odio facilisis mauris sit amet. Nisi est sit amet facilisis magna. Mi proin sed libero enim sed faucibus turpis. Magna sit amet purus gravida. A lacus vestibulum sed arcu non odio euismod. Massa tincidunt nunc pulvinar sapien et. Iaculis eu non diam phasellus vestibulum. Ultrices dui sapien eget mi proin sed. Blandit cursus risus at ultrices mi tempus imperdiet. Non arcu risus quis varius quam. Vitae congue mauris rhoncus aenean vel elit. Interdum velit laoreet id donec ultrices tincidunt arcu. Duis ultricies lacus sed turpis tincidunt id. Lacus vestibulum sed arcu non odio. Quis hendrerit dolor magna eget est. Nulla facilisi etiam dignissim diam quis enim lobortis. Placerat vestibulum lectus mauris ultrices.

+ +

Amet est placerat in egestas erat imperdiet sed euismod nisi. Volutpat est velit egestas dui id ornare arcu odio ut. At lectus urna duis convallis convallis tellus. Amet purus gravida quis blandit turpis cursus in hac. Ipsum suspendisse ultrices gravida dictum fusce ut placerat orci nulla. Viverra mauris in aliquam sem fringilla ut. Sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit. Ultricies tristique nulla aliquet enim. Vivamus arcu felis bibendum ut tristique et egestas quis ipsum. Euismod nisi porta lorem mollis aliquam ut. Sed viverra ipsum nunc aliquet bibendum enim facilisis. Vitae proin sagittis nisl rhoncus mattis. Etiam sit amet nisl purus in mollis nunc. Amet nisl suscipit adipiscing bibendum est ultricies integer. Tincidunt vitae semper quis lectus nulla at volutpat diam. Vel elit scelerisque mauris pellentesque.

+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/home.html b/leaderboard/leaderboard/templates/leaderboard/home.html new file mode 100644 index 0000000..b5c6c67 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/home.html @@ -0,0 +1,22 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard +{% endblock title %} + +{% block header %} +RLCard Leaderboard +{% endblock header %} + +{% block content %} +
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc lobortis mattis aliquam faucibus purus. Pretium aenean pharetra magna ac placerat vestibulum lectus mauris. Lacus laoreet non curabitur gravida arcu ac tortor. Pulvinar elementum integer enim neque volutpat ac. Enim sit amet venenatis urna. Amet risus nullam eget felis. Eu consequat ac felis donec et odio pellentesque diam. Congue nisi vitae suscipit tellus mauris a diam. Tellus elementum sagittis vitae et leo duis ut diam. Id leo in vitae turpis. Metus dictum at tempor commodo ullamcorper. Turpis cursus in hac habitasse platea dictumst. Lacus viverra vitae congue eu consequat ac felis. Justo donec enim diam vulputate ut. Donec pretium vulputate sapien nec sagittis.

+ +

Sit amet risus nullam eget felis eget nunc lobortis. Quam vulputate dignissim suspendisse in. Tortor posuere ac ut consequat semper. Pretium aenean pharetra magna ac placerat vestibulum. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt. Iaculis urna id volutpat lacus laoreet non curabitur gravida. Odio facilisis mauris sit amet massa vitae tortor condimentum. Viverra adipiscing at in tellus integer. Et egestas quis ipsum suspendisse ultrices gravida dictum fusce. Sapien pellentesque habitant morbi tristique senectus et netus et. Orci porta non pulvinar neque laoreet suspendisse interdum consectetur. Ornare suspendisse sed nisi lacus sed viverra tellus. In tellus integer feugiat scelerisque varius morbi enim nunc faucibus. Amet massa vitae tortor condimentum. Turpis tincidunt id aliquet risus.

+ +

Euismod lacinia at quis risus sed vulputate odio ut. Eu consequat ac felis donec. Mattis enim ut tellus elementum sagittis vitae et leo duis. Proin libero nunc consequat interdum varius sit amet mattis. Felis eget velit aliquet sagittis id consectetur purus ut. Eget egestas purus viverra accumsan in nisl nisi scelerisque eu. Cras semper auctor neque vitae tempus quam pellentesque nec. Id porta nibh venenatis cras sed felis eget. Neque viverra justo nec ultrices dui sapien eget mi. Nunc sed id semper risus in hendrerit gravida rutrum.

+ +

Orci sagittis eu volutpat odio facilisis mauris sit amet. Nisi est sit amet facilisis magna. Mi proin sed libero enim sed faucibus turpis. Magna sit amet purus gravida. A lacus vestibulum sed arcu non odio euismod. Massa tincidunt nunc pulvinar sapien et. Iaculis eu non diam phasellus vestibulum. Ultrices dui sapien eget mi proin sed. Blandit cursus risus at ultrices mi tempus imperdiet. Non arcu risus quis varius quam. Vitae congue mauris rhoncus aenean vel elit. Interdum velit laoreet id donec ultrices tincidunt arcu. Duis ultricies lacus sed turpis tincidunt id. Lacus vestibulum sed arcu non odio. Quis hendrerit dolor magna eget est. Nulla facilisi etiam dignissim diam quis enim lobortis. Placerat vestibulum lectus mauris ultrices.

+ +

Amet est placerat in egestas erat imperdiet sed euismod nisi. Volutpat est velit egestas dui id ornare arcu odio ut. At lectus urna duis convallis convallis tellus. Amet purus gravida quis blandit turpis cursus in hac. Ipsum suspendisse ultrices gravida dictum fusce ut placerat orci nulla. Viverra mauris in aliquam sem fringilla ut. Sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit. Ultricies tristique nulla aliquet enim. Vivamus arcu felis bibendum ut tristique et egestas quis ipsum. Euismod nisi porta lorem mollis aliquam ut. Sed viverra ipsum nunc aliquet bibendum enim facilisis. Vitae proin sagittis nisl rhoncus mattis. Etiam sit amet nisl purus in mollis nunc. Amet nisl suscipit adipiscing bibendum est ultricies integer. Tincidunt vitae semper quis lectus nulla at volutpat diam. Vel elit scelerisque mauris pellentesque.

+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/leducholdem.html b/leaderboard/leaderboard/templates/leaderboard/leducholdem.html new file mode 100644 index 0000000..284178f --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/leducholdem.html @@ -0,0 +1,31 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Leduc Hold'em +{% endblock title %} + +{% block header %} +Leduc Hold'em Leaderboard +{% endblock header %} + +{% block content %} +
+ + + + + + + + + + {% for agent in agents %} + + + + + + {% endfor %} + +
RankModelAverage Win Rate
{{ agent.rank }}{{ agent.agentName }}{{ agent.winRate }}
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/limitholdem.html b/leaderboard/leaderboard/templates/leaderboard/limitholdem.html new file mode 100644 index 0000000..d0ab847 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/limitholdem.html @@ -0,0 +1,36 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Limit Texas Hold'em +{% endblock title %} + +{% block header %} +Limit Texas Hold'em Leaderboard +{% endblock header %} + +{% block content %} +
+

Currently Unavailable

+

Try Ludec Hold'em

+
+ + +{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/mahjong.html b/leaderboard/leaderboard/templates/leaderboard/mahjong.html new file mode 100644 index 0000000..d91c86f --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/mahjong.html @@ -0,0 +1,36 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Mahjong +{% endblock title %} + +{% block header %} +Mahjong Leaderboard +{% endblock header %} + +{% block content %} +
+

Currently Unavailable

+

Try Ludec Hold'em

+
+ + +{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/nfsp.html b/leaderboard/leaderboard/templates/leaderboard/nfsp.html new file mode 100644 index 0000000..b204937 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/nfsp.html @@ -0,0 +1,33 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: NFSP +{% endblock title %} + +{% block header %} +NFSP +{% endblock header %} + +{% block content %} +
+ + + + + + + + + + + {% for game in games %} + + + + + + + {% endfor %} + +
Replay IDOpponentGameReplay Link
{{ game.replayID }}{{ game.agent2 }}{{ game.gameName }}{{ game.replayLink }}
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/nolimitholdem.html b/leaderboard/leaderboard/templates/leaderboard/nolimitholdem.html new file mode 100644 index 0000000..602e7a2 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/nolimitholdem.html @@ -0,0 +1,36 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: No-Limit Texas Hold'em +{% endblock title %} + +{% block header %} +No-Limit Hold'em Leaderboard +{% endblock header %} + +{% block content %} +
+

Currently Unavailable

+

Try Ludec Hold'em

+
+ + +{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/templates/leaderboard/uno.html b/leaderboard/leaderboard/templates/leaderboard/uno.html new file mode 100644 index 0000000..815d706 --- /dev/null +++ b/leaderboard/leaderboard/templates/leaderboard/uno.html @@ -0,0 +1,36 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +RLCard Leaderboard: Uno +{% endblock title %} + +{% block header %} +Uno Leaderboard +{% endblock header %} + +{% block content %} +
+

Currently Unavailable

+

Try Ludec Hold'em

+
+ + +{% endblock content %} \ No newline at end of file diff --git a/leaderboard/leaderboard/tests.py b/leaderboard/leaderboard/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/leaderboard/leaderboard/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/leaderboard/leaderboard/urls.py b/leaderboard/leaderboard/urls.py new file mode 100644 index 0000000..944a92a --- /dev/null +++ b/leaderboard/leaderboard/urls.py @@ -0,0 +1,18 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.home, name='leaderboard-home'), + path('about/', views.about, name='leaderboard-about'), + path('leaderboards/blackjack', views.blackjack, name='leaderboard-blackjack'), + path('leaderboards/doudizhu', views.doudizhu, name='leaderboard-doudizhu'), + path('leaderboards/leducholdem', views.leducholdem, name='leaderboard-leducholdem'), + path('leaderboards/limitholdem', views.limitholdem, name='leaderboard-limitholdem'), + path('leaderboards/nolimitholdem', views.nolimitholdem, name='leaderboard-nolimitholdem'), + path('leaderboards/mahjong', views.mahjong, name='leaderboard-mahjong'), + path('leaderboards/uno', views.uno, name='leaderboard-uno'), + path('getting_started/', views.getting_started, name='leaderboard-getting_started'), + path('leaderboards/nfsp', views.nfsp, name='leaderboard-nfsp'), + path('leaderboards/cfr', views.cfr, name='leaderboard-cfr'), + path('leaderboards/dqn', views.dqn, name='leaderboard-dqn'), +] diff --git a/leaderboard/leaderboard/views.py b/leaderboard/leaderboard/views.py new file mode 100644 index 0000000..a74988c --- /dev/null +++ b/leaderboard/leaderboard/views.py @@ -0,0 +1,69 @@ +from django.shortcuts import render +from .models import Agent +from .models import Game +import operator + + +def home(request): + return render(request, 'leaderboard/home.html') + + +def about(request): + return render(request, 'leaderboard/about.html') + + +def getting_started(request): + return render(request, 'leaderboard/getting_started.html') + + +def blackjack(request): + return render(request, 'leaderboard/blackjack.html') + + +def doudizhu(request): + return render(request, 'leaderboard/doudizhu.html') + + +def leducholdem(request): + context = { + 'agents': Agent.objects.all() + } + return render(request, 'leaderboard/leducholdem.html', context) + + +def limitholdem(request): + return render(request, 'leaderboard/limitholdem.html') + + +def nolimitholdem(request): + return render(request, 'leaderboard/nolimitholdem.html') + + +def mahjong(request): + return render(request, 'leaderboard/mahjong.html') + + +def uno(request): + return render(request, 'leaderboard/uno.html') + + +def nfsp(request): + context = { + 'games': Game.objects.filter(agent1="NFSP") + } + return render(request, 'leaderboard/nfsp.html', context) + + +def cfr(request): + context = { + 'games': Game.objects.filter(agent1="CFR") + } + return render(request, 'leaderboard/cfr.html', context) + + +def dqn(request): + context = { + 'games': Game.objects.filter(agent1="DQN") + } + return render(request, 'leaderboard/dqn.html', context) + diff --git a/leaderboard/manage.py b/leaderboard/manage.py new file mode 100755 index 0000000..253a4c2 --- /dev/null +++ b/leaderboard/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'research_env.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/leaderboard/media/RLCard.jpg b/leaderboard/media/RLCard.jpg new file mode 100644 index 0000000..9d65e3d Binary files /dev/null and b/leaderboard/media/RLCard.jpg differ diff --git a/leaderboard/media/RLCard.png b/leaderboard/media/RLCard.png new file mode 100644 index 0000000..3274105 Binary files /dev/null and b/leaderboard/media/RLCard.png differ diff --git a/leaderboard/media/default.jpg b/leaderboard/media/default.jpg new file mode 100644 index 0000000..36ef5e1 Binary files /dev/null and b/leaderboard/media/default.jpg differ diff --git a/leaderboard/media/profile_pics/default.jpg b/leaderboard/media/profile_pics/default.jpg new file mode 100644 index 0000000..0b6cea5 Binary files /dev/null and b/leaderboard/media/profile_pics/default.jpg differ diff --git a/leaderboard/media/profile_pics/default_cqLOpRI.jpg b/leaderboard/media/profile_pics/default_cqLOpRI.jpg new file mode 100644 index 0000000..36ef5e1 Binary files /dev/null and b/leaderboard/media/profile_pics/default_cqLOpRI.jpg differ diff --git a/leaderboard/research_env/__init__.py b/leaderboard/research_env/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leaderboard/research_env/__pycache__/__init__.cpython-36.pyc b/leaderboard/research_env/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..e701da0 Binary files /dev/null and b/leaderboard/research_env/__pycache__/__init__.cpython-36.pyc differ diff --git a/leaderboard/research_env/__pycache__/__init__.cpython-37.pyc b/leaderboard/research_env/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..8d2f9c8 Binary files /dev/null and b/leaderboard/research_env/__pycache__/__init__.cpython-37.pyc differ diff --git a/leaderboard/research_env/__pycache__/settings.cpython-36.pyc b/leaderboard/research_env/__pycache__/settings.cpython-36.pyc new file mode 100644 index 0000000..753733a Binary files /dev/null and b/leaderboard/research_env/__pycache__/settings.cpython-36.pyc differ diff --git a/leaderboard/research_env/__pycache__/settings.cpython-37.pyc b/leaderboard/research_env/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000..532677b Binary files /dev/null and b/leaderboard/research_env/__pycache__/settings.cpython-37.pyc differ diff --git a/leaderboard/research_env/__pycache__/urls.cpython-36.pyc b/leaderboard/research_env/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..e462fd4 Binary files /dev/null and b/leaderboard/research_env/__pycache__/urls.cpython-36.pyc differ diff --git a/leaderboard/research_env/__pycache__/urls.cpython-37.pyc b/leaderboard/research_env/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..a1b38f8 Binary files /dev/null and b/leaderboard/research_env/__pycache__/urls.cpython-37.pyc differ diff --git a/leaderboard/research_env/__pycache__/wsgi.cpython-36.pyc b/leaderboard/research_env/__pycache__/wsgi.cpython-36.pyc new file mode 100644 index 0000000..f2e3362 Binary files /dev/null and b/leaderboard/research_env/__pycache__/wsgi.cpython-36.pyc differ diff --git a/leaderboard/research_env/__pycache__/wsgi.cpython-37.pyc b/leaderboard/research_env/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000..b2d4551 Binary files /dev/null and b/leaderboard/research_env/__pycache__/wsgi.cpython-37.pyc differ diff --git a/leaderboard/research_env/settings.py b/leaderboard/research_env/settings.py new file mode 100644 index 0000000..131425e --- /dev/null +++ b/leaderboard/research_env/settings.py @@ -0,0 +1,130 @@ +""" +Django settings for research_env project. + +Generated by 'django-admin startproject' using Django 2.2.7. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.2/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '2fw%$$6n0fnqap&^&#l+qnknff(r&eb7qqx3w8f91k@1dqx%p0' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'users.apps.UsersConfig', + 'leaderboard.apps.LeaderboardConfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'research_env.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'research_env.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.2/howto/static-files/ + +STATIC_URL = '/static/' + +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +MEDIA_URL = '/media/' + +CRISPY_TEMPLATE_PACK = 'bootstrap3' + +LOGIN_REDIRECT_URL = 'leaderboard-home' +LOGIN_URL = 'login' diff --git a/leaderboard/research_env/urls.py b/leaderboard/research_env/urls.py new file mode 100644 index 0000000..e678833 --- /dev/null +++ b/leaderboard/research_env/urls.py @@ -0,0 +1,35 @@ +"""research_env URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.conf.urls.static import static +from django.conf import settings +from django.contrib import admin +from django.contrib.auth import views as auth_views +from django.urls import path, include +from users import views as user_views + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('leaderboard.urls')), + path('register/', user_views.register, name='register'), + path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), + path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'), + path('profile/', user_views.profile, name='profile'), +] + + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, + document_root=settings.MEDIA_ROOT) diff --git a/leaderboard/research_env/wsgi.py b/leaderboard/research_env/wsgi.py new file mode 100644 index 0000000..f409cef --- /dev/null +++ b/leaderboard/research_env/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for research_env project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'research_env.settings') + +application = get_wsgi_application() diff --git a/leaderboard/tests.py b/leaderboard/tests.py new file mode 100644 index 0000000..1c74979 --- /dev/null +++ b/leaderboard/tests.py @@ -0,0 +1,118 @@ +# when done python3 manage.py syncdb +import os, sys + +proj_path = "/Users/juanvargas/Desktop/Research/rlcard-leaderboard/research_env/" +# This is so Django knows where to find stuff. +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "research_env.settings") +sys.path.append(proj_path) + +# This is so my local_settings.py gets loaded. +os.chdir(proj_path) + +# This is so models get loaded. +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() +from leaderboard.models import Agent, Game + +# a = Agent(gamesPlayed = 100, winRate = 0.123, gamesWon = 12, opponent = '123', agentID = '321', totalGamesPlayed = 100) +# a.save() + +# game = Game(gameID='int',agent1='agent-name',agent2='agent-name',replayID='int',replayLink="http://link") +# game.save() +# a = Agent(gamesPlayed='int',winRate='1.234',gamesWon='int',opponent='char',totalGamesPlayed="http://link") +# a.save() + +# We may need a function to generate a unique random id or append to current + +# We need to unpack user data +# Should be in the form + +# These need to be gotten from DB +# replayID = 10000 +# gameID = 10000 + +data = [ + { + 'agent' : '1', + 'gamesWon' : 'int', + 'gamesPlayed': 'int', + 'winRate' : 'float', + 'path' : '~/Test', + 'opponent' : 'opp' + }, + { + 'agent' : '2', + 'gamesWon' : 'int', + 'gamesPlayed': 'int', + 'winRate' : 'float', + 'path' : '~/Test', + 'opponent' : 'opp' + } + +] + +agents = [] +games_won = [] +games_played = [] +win_rates = [] +opponents = [] +for item in range(len(data)): + agents.append(data[item]['agent']) + games_won.append(data[item]['gamesWon']) + games_played.append(data[item]['gamesPlayed']) + win_rates.append(data[item]['winRate']) + opponents.append(data[item]['opponent']) + + +def add_agent(games_Played, win_Rate, games_Won, _opponent, agent_ID, total_GamesPlayed): + agent = Agent(gamesPlayed = games_Played, winRate = win_Rate, gamesWon = games_Won, opponent = _opponent, agentID = agent_ID, totalGamesPlayed = total_GamesPlayed) + agent.save() + +def add_game(game_ID, agent_1, agent_2, replay_ID, replay_Link): + game = Game(gameID = game_ID, agent1 = agent_1, agent2 = agent_2, replayID = replay_ID, replayLink = replay_Link) + game.save() + +# Will return true on new entry, false otherwise +def checkAgentID(agent_ID): + if len(Agent.obejects.filter(agentID = agent_ID)) == 0 + return True + return False + +# Function to update agentID +def updateAgentID(opponent, gamesWon, gamesPlayed): + #if agent is new, then add to database, else modify agent + for i in range(len(data)): + if checkAgentID(agents[i]) == True: + add_agent(games_won[i], win_rates[i], games_won[i], opponents[i], agents[i, games_played[i]]) + else: + agent = Agent.objects.get(agentID = agents[i]) + + agent.save() + + +# Will return true on new entry, false otherwise +# def checkAgentID(agentID): +# command_line = os.popen("python3 manage.py shell < agenthelper.py").read() +# if command_line == '0': +# return True +# else: +# return False + +# #Should return a tuple in format ([agent1, winrate1], [agent2, winrate2]) +# def calculateWinRate(agent1ID, agent2ID, gamesAgent1, gamesAgent2, gamesPlayed): +# #Check to see if ID is in DB if so update currrent info else just return +# return([[agent1ID, gamesAgent1/gamesPlayed], [agent2ID, gamesAgent2/gamesPlayed]]) + +# # Function to update game +# def updateGame(replayID, gameID): +# os.system("a = Game(gameID='int',agent1='agent-name',agent2='agent-name',replayID='int',replayLink='path')") +# time.sleep(0.5) +# os.system("a.save()") + + + + +def updateRanking(): + print("brb") + +# when done python3 manage.py syncdb \ No newline at end of file diff --git a/leaderboard/updateDataBase.py b/leaderboard/updateDataBase.py new file mode 100644 index 0000000..6a770ac --- /dev/null +++ b/leaderboard/updateDataBase.py @@ -0,0 +1,126 @@ +# when done python3 manage.py syncdb +import os, sys +import uuid + +PATH = "/Users/juanvargas/Desktop/Research/rlcard-leaderboard/research_env/" +# This is so Django knows where to find stuff. +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "research_env.settings") +sys.path.append(PATH) + +# This is so my local_settings.py gets loaded. +os.chdir(PATH) + +# This is so models get loaded. +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() +from leaderboard.models import Agent, Game + +# a = Agent(gamesPlayed = 100, winRate = 0.123, gamesWon = 12, opponent = '123', agentID = '321', totalGamesPlayed = 100) +# a.save() + +# game = Game(gameID='int',agent1='agent-name',agent2='agent-name',replayID='int',replayLink="http://link") +# game.save() +# a = Agent(gamesPlayed='int',winRate='1.234',gamesWon='int',opponent='char',totalGamesPlayed="http://link") +# a.save() + +# We may need a function to generate a unique random id or append to current + +# We need to unpack user data +# Should be in the form + +# These need to be gotten from DB +# replayID = 10000 +# gameID = 10000 + +agentData = [ + { + 'gamesPlayed': 1, + 'winRate' : 0.5, + 'gamesWon' : 1, + 'opponent' : 'DQN', + 'agentID' : uuid.uuid4(), + 'agentName' : 'DQN', + 'totalGames' : 1 + } +] + +games_played = [] +win_rates = [] +games_won = [] +opponents = [] +agent_ids = [] +agent_names = [] +total_games = [] + +# b = Agent(gamesPlayed = 100, winRate = 0.5, gamesWon = 1, opponent = 'NFSP' , agentID = 'NFSP123', agentName = 'DQN', totalGamesPlayed = 100) + +for item in range(len(agentData)): + games_played.append(agentData[item]['gamesPlayed']) + win_rates.append(agentData[item]['winRate']) + games_won.append(agentData[item]['gamesWon']) + opponents.append(agentData[item]['opponent']) + agent_ids.append(agentData[item]['agentID']) + agent_names.append(agentData[item]['agentName']) + total_games.append(agentData[item]['totalGames']) + +gameData = [ + { + 'gameID' : 1, + 'agent1' : uuid.uuid4(), + 'agent2' : uuid.uuid4(), + 'replayID' : uuid.uuid4(), + 'replayLink' : '~/Test' + } +] + +game_ids = [] +agent_1_IDs = [] +agent_2_IDs = [] +replay_IDs = [] +replay_Links = [] + +for item in range(len(gameData)): + game_ids.append(gameData[item]['gameID']) + agent_1_IDs.append(gameData[item]['agent1']) + agent_2_IDs.append(gameData[item]['agent2']) + replay_IDs.append(gameData[item]['replayID']) + replay_Links.append(gameData[item]['replayLink']) + + +def add_agent(games_Played, win_Rate, games_Won, _opponent, agent_ID, agent_Name, total_GamesPlayed): + agent = Agent(gamesPlayed = games_Played, winRate = win_Rate, gamesWon = games_Won, opponent = _opponent, agentID = agent_ID, agentName = agent_Name, totalGamesPlayed = total_GamesPlayed) + agent.save() + +def add_game(game_ID, agent_1, agent_2, replay_ID, replay_Link): + game = Game(gameID = game_ID, agent1 = agent_1, agent2 = agent_2, replayID = replay_ID, replayLink = replay_Link) + game.save() + +# Will return true on new entry, false otherwise +def checkAgentID(agent_ID): + if len(Agent.obejects.filter(agentID = agent_ID)) == 0: + return True + return False + +# Function to update agentID +def updateAgentID(_opponent, games_Won, games_Played): + #if agent is new, then add to database, else modify agent + for i in range(len(data)): + if checkAgentID(agents[i]) == True: + add_agent(games_played[i], win_rates[i], games_won[i], opponents[i], agent_ids[i], agent_names[i], games_played[i]) + else: + agent = Agent.objects.get(agentID = agents[i]) + agent.gamesWon = agent.gamesWon + games_Won + agent.gamesPlayed = agent.gamesPlayed + games_Played + agent.winRate = agent.gamesWon / agent.gamesPlayed + agent.save() + + +# At the end of the game, update the rankings +def updateRanking(): + db_size = Agent.objects.all().count() + for i in range(db_size): + agent = Agent.objects.order_by('winRate')[i] + agent.Rank = i+1 + agent.save() + +updateRanking() \ No newline at end of file diff --git a/leaderboard/users/__init__.py b/leaderboard/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leaderboard/users/__pycache__/__init__.cpython-36.pyc b/leaderboard/users/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..78d26e2 Binary files /dev/null and b/leaderboard/users/__pycache__/__init__.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/__init__.cpython-37.pyc b/leaderboard/users/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..5641294 Binary files /dev/null and b/leaderboard/users/__pycache__/__init__.cpython-37.pyc differ diff --git a/leaderboard/users/__pycache__/admin.cpython-36.pyc b/leaderboard/users/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000..c25f645 Binary files /dev/null and b/leaderboard/users/__pycache__/admin.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/admin.cpython-37.pyc b/leaderboard/users/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..83c092c Binary files /dev/null and b/leaderboard/users/__pycache__/admin.cpython-37.pyc differ diff --git a/leaderboard/users/__pycache__/apps.cpython-36.pyc b/leaderboard/users/__pycache__/apps.cpython-36.pyc new file mode 100644 index 0000000..bd2249f Binary files /dev/null and b/leaderboard/users/__pycache__/apps.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/apps.cpython-37.pyc b/leaderboard/users/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000..0f71605 Binary files /dev/null and b/leaderboard/users/__pycache__/apps.cpython-37.pyc differ diff --git a/leaderboard/users/__pycache__/forms.cpython-36.pyc b/leaderboard/users/__pycache__/forms.cpython-36.pyc new file mode 100644 index 0000000..52dd571 Binary files /dev/null and b/leaderboard/users/__pycache__/forms.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/forms.cpython-37.pyc b/leaderboard/users/__pycache__/forms.cpython-37.pyc new file mode 100644 index 0000000..e55f269 Binary files /dev/null and b/leaderboard/users/__pycache__/forms.cpython-37.pyc differ diff --git a/leaderboard/users/__pycache__/models.cpython-36.pyc b/leaderboard/users/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000..0c63fc1 Binary files /dev/null and b/leaderboard/users/__pycache__/models.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/models.cpython-37.pyc b/leaderboard/users/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..fb78c7f Binary files /dev/null and b/leaderboard/users/__pycache__/models.cpython-37.pyc differ diff --git a/leaderboard/users/__pycache__/signals.cpython-36.pyc b/leaderboard/users/__pycache__/signals.cpython-36.pyc new file mode 100644 index 0000000..de243ec Binary files /dev/null and b/leaderboard/users/__pycache__/signals.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/signals.cpython-37.pyc b/leaderboard/users/__pycache__/signals.cpython-37.pyc new file mode 100644 index 0000000..c23b86a Binary files /dev/null and b/leaderboard/users/__pycache__/signals.cpython-37.pyc differ diff --git a/leaderboard/users/__pycache__/views.cpython-36.pyc b/leaderboard/users/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..2749d6c Binary files /dev/null and b/leaderboard/users/__pycache__/views.cpython-36.pyc differ diff --git a/leaderboard/users/__pycache__/views.cpython-37.pyc b/leaderboard/users/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000..020a824 Binary files /dev/null and b/leaderboard/users/__pycache__/views.cpython-37.pyc differ diff --git a/leaderboard/users/admin.py b/leaderboard/users/admin.py new file mode 100644 index 0000000..d914f1f --- /dev/null +++ b/leaderboard/users/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Profile + +admin.site.register(Profile) diff --git a/leaderboard/users/apps.py b/leaderboard/users/apps.py new file mode 100644 index 0000000..b8d67f1 --- /dev/null +++ b/leaderboard/users/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + name = 'users' + + def ready(self): + import users.signals diff --git a/leaderboard/users/forms.py b/leaderboard/users/forms.py new file mode 100644 index 0000000..ee5757a --- /dev/null +++ b/leaderboard/users/forms.py @@ -0,0 +1,26 @@ +from django import forms +from django.contrib.auth.models import User +from django.contrib.auth.forms import UserCreationForm +from .models import Profile + + +class UserRegisterForm(UserCreationForm): + email = forms.EmailField() + + class Meta: + model = User + fields = ['username', 'email', 'password1', 'password2'] + + +class UserUpdateForm(forms.ModelForm): + email = forms.EmailField() + + class Meta: + model = User + fields = ['username', 'email'] + + +class ProfileUpdateForm(forms.ModelForm): + class Meta: + model = Profile + fields = ['image'] diff --git a/leaderboard/users/migrations/0001_initial.py b/leaderboard/users/migrations/0001_initial.py new file mode 100644 index 0000000..732a3ea --- /dev/null +++ b/leaderboard/users/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 2.2.7 on 2019-11-15 00:57 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image', models.ImageField(default='default.jpg', upload_to='profile_pics')), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/leaderboard/users/migrations/__init__.py b/leaderboard/users/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leaderboard/users/migrations/__pycache__/0001_initial.cpython-36.pyc b/leaderboard/users/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000..acbc01b Binary files /dev/null and b/leaderboard/users/migrations/__pycache__/0001_initial.cpython-36.pyc differ diff --git a/leaderboard/users/migrations/__pycache__/0001_initial.cpython-37.pyc b/leaderboard/users/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000..e1be47a Binary files /dev/null and b/leaderboard/users/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/leaderboard/users/migrations/__pycache__/__init__.cpython-36.pyc b/leaderboard/users/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..1b14b42 Binary files /dev/null and b/leaderboard/users/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/leaderboard/users/migrations/__pycache__/__init__.cpython-37.pyc b/leaderboard/users/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..1d4adb5 Binary files /dev/null and b/leaderboard/users/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/leaderboard/users/models.py b/leaderboard/users/models.py new file mode 100644 index 0000000..498e479 --- /dev/null +++ b/leaderboard/users/models.py @@ -0,0 +1,21 @@ +from django.db import models +from django.contrib.auth.models import User +from PIL import Image + + +class Profile(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + image = models.ImageField(default='default.jpg', upload_to='profile_pics') + + def __str__(self): + return f'{self.user.username} Profile' + + def save(self, *args, **kwargs): + super(Profile, self).save(*args, **kwargs) + + img = Image.open(self.image.path) + + if img.height > 300 or img.width > 300: + output_size = (300, 300) + img.thumbnail(output_size) + img.save(self.image.path) diff --git a/leaderboard/users/signals.py b/leaderboard/users/signals.py new file mode 100644 index 0000000..3a691d7 --- /dev/null +++ b/leaderboard/users/signals.py @@ -0,0 +1,15 @@ +from django.db.models.signals import post_save +from django.contrib.auth.models import User +from django.dispatch import receiver +from .models import Profile + + +@receiver(post_save, sender=User) +def create_profile(sender, instance, created, **kwargs): + if created: + Profile.objects.create(user=instance) + + +@receiver(post_save, sender=User) +def save_profile(sender, instance, created, **kwargs): + instance.profile.save() diff --git a/leaderboard/users/templates/users/login.html b/leaderboard/users/templates/users/login.html new file mode 100644 index 0000000..c460d29 --- /dev/null +++ b/leaderboard/users/templates/users/login.html @@ -0,0 +1,25 @@ +{% extends "leaderboard/base.html" %} +{% load crispy_forms_tags %} +{% block title %} +Log In +{% endblock title %} + +{% block content %} +
+
+ {% csrf_token %} +
+ Log In + {{ form|crispy }} +
+
+ +
+
+
+ + Need An Account? Sign Up Now + +
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/users/templates/users/logout.html b/leaderboard/users/templates/users/logout.html new file mode 100644 index 0000000..b531d78 --- /dev/null +++ b/leaderboard/users/templates/users/logout.html @@ -0,0 +1,13 @@ +{% extends "leaderboard/base.html" %} +{% block title %} +Logged Out +{% endblock title %} + +{% block content %} +

You have been logged out

+
+ + Log In Again + +
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/users/templates/users/profile.html b/leaderboard/users/templates/users/profile.html new file mode 100644 index 0000000..30f66ce --- /dev/null +++ b/leaderboard/users/templates/users/profile.html @@ -0,0 +1,28 @@ +{% extends "leaderboard/base.html" %} +{% load crispy_forms_tags %} +{% block title %} +Profile +{% endblock title %} + +{% block content %} +
+
+ +
+ +

{{ user.email }}

+
+
+
+ {% csrf_token %} +
+ Profile Info + {{ u_form|crispy }} + {{ p_form|crispy }} +
+
+ +
+
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/users/templates/users/register.html b/leaderboard/users/templates/users/register.html new file mode 100644 index 0000000..a82c622 --- /dev/null +++ b/leaderboard/users/templates/users/register.html @@ -0,0 +1,25 @@ +{% extends "leaderboard/base.html" %} +{% load crispy_forms_tags %} +{% block title %} +Register +{% endblock title %} + +{% block content %} +
+
+ {% csrf_token %} +
+ Join Today + {{ form|crispy }} +
+
+ +
+
+
+ + Already Have An Account? Sign In + +
+
+{% endblock content %} \ No newline at end of file diff --git a/leaderboard/users/tests.py b/leaderboard/users/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/leaderboard/users/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/leaderboard/users/views.py b/leaderboard/users/views.py new file mode 100644 index 0000000..c9e6d3f --- /dev/null +++ b/leaderboard/users/views.py @@ -0,0 +1,42 @@ +from django.shortcuts import render, redirect +from django.contrib import messages +from django.contrib.auth.decorators import login_required +from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm + + +def register(request): + if request.method == 'POST': + form = UserRegisterForm(request.POST) + if form.is_valid(): + form.save() + # username = form.cleaned_data.get('username') + messages.success( + request, f'Your account has been created! You are now able to log in!') + return redirect('login') + else: + form = UserRegisterForm() + return render(request, 'users/register.html', {'form': form}) + + +@login_required +def profile(request): + if request.method == 'POST': + u_form = UserUpdateForm(request.POST, instance=request.user) + p_form = ProfileUpdateForm( + request.POST, request.FILES, instance=request.user.profile) + if u_form.is_valid() and p_form.is_valid(): + u_form.save() + p_form.save() + messages.success( + request, f'Your account has been updated!') + return redirect('profile') + else: + u_form = UserUpdateForm(instance=request.user) + p_form = ProfileUpdateForm(instance=request.user.profile) + + context = { + 'u_form': u_form, + 'p_form': p_form + } + + return render(request, 'users/profile.html', context)