Fix list baseline bug and update README

This commit is contained in:
Daochen Zha 2020-12-06 13:24:59 -06:00
parent 0f39a362b8
commit e63f4626b4
2 changed files with 12 additions and 9 deletions

View File

@ -25,7 +25,7 @@ If you find this repo useful, you may cite:
```
## Installation
RLCard-Showdown has separated frontend and backend. The frontend part is built with React and the backend is with Django.
RLCard-Showdown has separated frontend and backend. The frontend is built with React and the backend is based on Django.
### Prerequisite
To set up the frontend, you should make sure you have [Node.js](https://nodejs.org/) and NPM installed. Normally you just need to manually install Node.js, and the NPM package would be automatically installed together with Node.js for you. Please refer to its official website for installation of Node.js.
@ -54,15 +54,15 @@ cd ..
```
### Run RLCard-Showdown
Run the following command under the project folder to start frontend in development mode.
```
npm start
```
Then launch the backend in a new terminal with
Launch the backend in with
```
cd server
python manage.py runserver
```
Run the following command in a new terminal under the project folder to start frontend in development mode:
```
npm start
```
The frontend would be started in port 3000 in localhost by default. You can view it at [http://127.0.0.1:3000/](http://127.0.0.1:3000/). The backend will run by default in [http://127.0.0.1:8000/](http://127.0.0.1:8000/).
More documentation can be found [here](docs/api.md).

View File

@ -2,6 +2,7 @@ import json
import os
import importlib.util
import math
import copy
from django.shortcuts import render
from django.http import HttpResponse
@ -18,6 +19,7 @@ from .models import Game, Payoff, UploadedAgent
from .tournament import Tournament
from .rlcard_wrap import rlcard, MODEL_IDS
MODEL_IDS_ALL = copy.deepcopy(MODEL_IDS)
def _reset_model_ids():
agents = UploadedAgent.objects.all()
@ -41,7 +43,8 @@ def _reset_model_ids():
model = self._entry_point()
return model
rlcard.models.registration.model_registry.model_specs[name] = ModelSpec()
MODEL_IDS[game].append(name)
MODEL_IDS_ALL[game].append(name)
_reset_model_ids()
PAGE_FIELDS = ['elements_every_page', 'page_index']
@ -102,7 +105,7 @@ def launch(request):
except:
return HttpResponse(json.dumps({'value': -1, 'info': 'parameters error'}))
games_data, payoffs_data = Tournament(game, MODEL_IDS[game], eval_num).launch()
games_data, payoffs_data = Tournament(game, MODEL_IDS_ALL[game], eval_num).launch()
Game.objects.filter(name=game).delete()
Payoff.objects.filter(name=game).delete()
for game_data in games_data:
@ -159,7 +162,7 @@ def list_uploaded_agents(request):
def list_baseline_agents(request):
if request.method == 'GET':
if not 'game' in request.GET:
return HttpResponse(json.dumps({'value': -2, 'info': 'name should be given'}))
return HttpResponse(json.dumps({'value': -2, 'info': 'game should be given'}))
result = MODEL_IDS[request.GET['game']]
return HttpResponse(json.dumps({'value': 0, 'data': result}))