Axelrod-Python / axelrod-api

A Django Rest Framework API for the Axelrod-Python library
2 stars 3 forks source link

Tournaments endpoint #5

Open meatballs opened 7 years ago

erik-sn commented 7 years ago

For GET I think a similar list of class inspection as the StrategySerializer uses would work. As of now this would provide id, name and description.

For params a similar init_param that exists on the Player class could be added to the Tournament, MoranProcess, and Match.

Additionally I think a min_players and max_players attribute on these classes would be helpful in a UI to guiding the user what is necessary to start a tournament. It could be useful for the python implementation too. For example passing one strategy to a Match results in an index error, passing three results in the first two being used and the third being ignored. Explicitly stating the min and max amount of players could let a more descriptive error be thrown, i.e.

if len(players) < self.min_players:
    raise ValueError('At least {} players are required'.format(min_players))
meatballs commented 7 years ago

I don't think we need anything adding to the library itself. Instead, I reckon we could use a django model (and db storage) to hold the details of tournaments which have been created and run.

erik-sn commented 7 years ago

I have a prototype that accepts post data and processes a Tournament/Match - right now it is just synchronous with no storage to try and make sure the endpoint is ok.

Right now you would:

verb: POST url: /tournaments/ data:

{
"name": "tournament",
"turns": 150,
"repetitions": 5,
"noise": 0.1,
"with_morality": false,
"player_list": ["adaptive", "allcoralld", "adaptive", "anticycler"]
}

It returns a JSON response with all the fields in a ResultSet axelrod object.