RiedleroD/BASAV

add per-algorithm settings

RiedleroD opened this issue · 1 comments

planned would be a dict where algorithms can choose up to 20 settings by defining a member like so:

opts={
    "base":(int,4,2,None,"Base"),
    "oop":(bool,False,"Out-of-Place","In-Place"),
    "version":(list,2,("This","That","Ananas"),"Version: %s"),
    …
}

, where the option "base" is an integer from 2 to infinity, and a default value of 4, "oop" is a bool with the default value False, where "Out-of-place" is displayed for True and "In-Place" for False, and "version" is a list (a flip-through button in the UI) with the item on index 2 in "vals" being the default. If an option is defined with illegal values, e.g. the default value being out of range in an int, or the possible values in a list being less than 2. If there are more than 20 settings, the additional ones should be hidden and set to their default values. (maybe the maximum amount of settings will increase in the future if demand arises)

The options can be set by the user and on algorithm start, the selected values will be accessible to the algorithm like so:

def gen(self):
    b=self.vals["base"]
    oop=self.vals["oop"]
    v=self.vals["version"]
    …

Then the algorithm can modify itself with the specified values as it pleases.

This feature is aimed to reduce the amount of unique algorithms to select in the algorithm selector drastically and increase the amount of different options a user can choose from. E.g. the Radix LSD algorithm alone used up 6 spaces, but only base 2,4, and 10 can be selected, with an additional OOP option.

Planned is the setup:

  • Bubble Sort (unchanged)
  • Cocktail Shaker (unchanged)
  • Odd-Even Sort (unchanged)
  • InsertionSort (OOP/IP)
  • SelectionSort (OOP/IP,Single/Double)
  • QuickSort (Lomuto/Hoare,Singular/Concurrent)
  • Radix (LSD/MSD,base 2-inf,OOP/IP)
  • Merge Sort (IP/OOP)
  • Bogo Sort (unchanged)
    This would mean a reduction from 25 to 9 unique Algorithms.

Sorting algorithms have to make sure all possible configurations are functional. E.g. if there's a base 4 OOP version, but not a base 7 OOP version, then the algorithm should either limit the possible bases, scrap the OOP versions alltogether, or make the combination work. Note that there can be set boundaries which integer values are possible, but no single value can be excluded. If its a finite list, consider using a list instead.

implemented