-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsortingUtils.py
More file actions
61 lines (43 loc) · 1.05 KB
/
Copy pathsortingUtils.py
File metadata and controls
61 lines (43 loc) · 1.05 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import time
import pygame
import random
pygame.init()
def isSorted(array):
for x in range(len(array) - 1):
if array[x] > array[x + 1]:
return False
return True
def wait(delayMS):
if delayMS <= 0:
return None
end_time = time.perf_counter() + (delayMS / 1000.0)
while time.perf_counter() < end_time:
pass
def colorDataSet(array, length):
selectedIndices.clear()
comparedIndices.clear()
for i in range(length):
selectedIndices.append(array[i] - 1)
finishDataSound.play()
yield
yield
def createTestData(length):
for x in range(length):
data.append(x + 1)
random.shuffle(data)
sorting = False
data = []
swaps = 0
comparisons = 0
colorAnim = None
selectedIndices = []
comparedIndices = []
sortTime = 0
sortTimeVisual = 0
swapDataSound = pygame.mixer.Sound('audio/dataSort.wav')
swapDataSound.set_volume(0.1)
finishDataSound = pygame.mixer.Sound('audio/dataFinish.wav')
finishDataSound.set_volume(0.1)
algorithmName = ""
currentSort = 1
delay = 0