[WIP] Bug fix generating routine functionnality.

This commit is contained in:
Trullemans Gregory 2020-03-12 07:24:47 +01:00
parent bd66a52f28
commit 34482dd8bb
2 changed files with 28 additions and 15 deletions

View File

@ -42,6 +42,11 @@ routine_urlpatterns = [
views.del_skill_from_routine, views.del_skill_from_routine,
name="del_skill_from_routine", name="del_skill_from_routine",
), ),
path(
r"suggest/",
views.suggest_routine,
name="suggest_routine",
)
] ]
# Chrono # Chrono

View File

@ -370,6 +370,7 @@ def __construct_routine(
Returns: Returns:
??? (list): liste des séries correspondantes aux criètres. ??? (list): liste des séries correspondantes aux criètres.
""" """
print("Il reste " + str(routine_length) + " sauts à trouver.")
current_routine = [] current_routine = []
@ -407,18 +408,23 @@ def __construct_routine(
for skill in skill_list: for skill in skill_list:
current_routine.append(skill) current_routine.append(skill)
routine_length -= 1
if routine_length == 0:
break
current_routine.append( current_routine.append(
self.suggest_routine( __construct_routine(
total_difficulty_score - skill.difficulty, routine_length,
max_difficulty_score, total_difficulty_score - skill.difficulty if total_difficulty_score else None,
routine_length - 1,
competition, competition,
logic, logic,
gymnast, gymnast,
skill, skill,
) )
) )
if len(current_routine) == 10:
print(current_routine)
current_routine.pop() current_routine.pop()
routine_length += 1
# def knapSack(W, wt, val, n): # def knapSack(W, wt, val, n):
# K = [[0 for x in range(W+1)] for x in range(n+1)] # K = [[0 for x in range(W+1)] for x in range(n+1)]
# for i in range(n+1): # for i in range(n+1):
@ -441,12 +447,11 @@ def __construct_routine(
def suggest_routine( def suggest_routine(
request, request,
routine_length, routine_length = 10,
total_difficulty_score=None, total_difficulty_score=None,
competition=True, competition=True,
logic=True, logic=True,
gymnast=None, gymnast=None,
last_jump=None,
): ):
""" Construit et propose des séries. """ Construit et propose des séries.
@ -460,17 +465,20 @@ def suggest_routine(
Returns: Returns:
??? (list): liste des séries correspondantes aux criètres. ??? (list): liste des séries correspondantes aux criètres.
"""
current_routine = __construct_routine( >>> http://127.0.0.1:8000/routine/suggest/
routine_length, """
total_difficulty_score, routines = []
competition, routines.append(__construct_routine(
logic, routine_length,
gymnast, total_difficulty_score,
last_jump competition,
logic,
gymnast,
None
)
) )
print(current_routine) # print(routines)
@login_required @login_required