[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,
name="del_skill_from_routine",
),
path(
r"suggest/",
views.suggest_routine,
name="suggest_routine",
)
]
# Chrono

View File

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