-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgorithm_handler.py
36 lines (29 loc) · 1.49 KB
/
algorithm_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame
class AlgorithmHandler:
def __init__(self):
self.algorithms = { "none": "No algorithm",
"bubble": "Current algorithm: Bubble Sort",
"quick_right" : "Current algorithm: Quick Sort (right-pivot)",
"quick_random" : "Current algorithm: Quick Sort (random-pivot)",
"radix" : "Current algorithm: Radix Sort",
"merge" : "Current algorithm: Merge Sort",
"insertion" : "Current algorithm: Insertion Sort",
"selection" : "Current algorithm: Selection Sort",
"shell": "Current algorithm: Shell Sort",
"cocktail": "Current algorithm: Cocktail Sort"
}
self.algo = "none"
self.algorithm_keys = {pygame.K_1: "bubble",
pygame.K_2: "quick_right",
pygame.K_3: "quick_random",
pygame.K_4: "radix",
pygame.K_5: "merge",
pygame.K_6: "insertion",
pygame.K_7: "selection",
pygame.K_8: "shell",
pygame.K_9: "cocktail"
}
def handle_key(self, key):
if key in self.algorithm_keys:
self.algo = self.algorithm_keys[key]
return True