Skip to content

Commit

Permalink
fixed defragmentation error
Browse files Browse the repository at this point in the history
added option for whether to fragment
  • Loading branch information
Destaq committed Apr 30, 2020
1 parent 052d81b commit 635275c
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions vivid_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import find_opening


def form_values(depth, fragmentation_percentage):
def form_values(depth, fragmentation_percentage, should_defragment):
"""Create parent, id, labels, and values """
firstx = [
lst[i][:depth] for i in range(len(lst))
Expand Down Expand Up @@ -108,27 +108,22 @@ def form_values(depth, fragmentation_percentage):
complete_value = round((values[i] / game_count) * 100, 2)
percentage_holder.append(complete_value)

num_games = 0
for i in range(len(parents)):
if parents[i] == '':
num_games+=values[i]

#del_list = []
#for i in range(len(percentage_holder)):
# if percentage_holder[i] <= fragmentation_percentage and parents[i] != '':
# del_list.append(i)
if should_defragment == True:
del_list = []
for i in range(len(values)):
if values[i]/num_games <= fragmentation_percentage:
del_list.append(i)

#for i in range(len(parents)): # loop through all parents
# if i in del_list: # if that parent is in the bin
# death = ids[i] # find that parent's ID so we can locate children
# for x in range(len(parents)): # loop through parents again to find children
# if parents[x] == death: # if child's parent is equal to death
# del_list.append(x) # mark child for death as well


#percentage_holder = [percentage_holder[i] for i in range(len(percentage_holder)) if i not in del_list]
#ids = [ids[i] for i in range(len(ids)) if i not in del_list]
#labels = [labels[i] for i in range(len(labels)) if i not in del_list]
#parents = [parents[i] for i in range(len(parents)) if i not in del_list]
v#alues = [values[i] for i in range(len(values)) if i not in del_list]

# print(f'\n\nIDS: {ids}\n\nLABELS: {labels}\n\nPARENTS: {parents}\n\nVALUES: {values}')
percentage_holder = [percentage_holder[i] for i in range(len(percentage_holder)) if i not in del_list]
ids = [ids[i] for i in range(len(ids)) if i not in del_list]
labels = [labels[i] for i in range(len(labels)) if i not in del_list]
parents = [parents[i] for i in range(len(parents)) if i not in del_list]
values = [values[i] for i in range(len(values)) if i not in del_list]

return ids, labels, parents, values, percentage_holder

Expand Down Expand Up @@ -168,7 +163,7 @@ def form(ids, labels, parents, values):
user_input_depth = int(input("To what ply depth should we visualize these games? "))

lst = game_parser.parse_individual_games(gammme, user_input_depth)
ids, labels, parents, values, percentage_everything = form_values(user_input_depth, 3)
ids, labels, parents, values, percentage_everything = form_values(user_input_depth, 0.0032, True) # a good value is about 10x the smallest value

eco_codes, eco_names, eco_positions = find_opening.create_openings()
hovertip_openings = []
Expand Down

0 comments on commit 635275c

Please sign in to comment.