-
Notifications
You must be signed in to change notification settings - Fork 0
/
globy.py
100 lines (83 loc) · 3.17 KB
/
globy.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# globy.py
# imports
import os
import sys
import json
import math
import pickle
import random
import pygame
class Options:
# resolution
res_factor = 700 # ie. height
res_ratio = 1.9 # length / width
resolution = (round(res_factor * res_ratio), res_factor) # width x height
# frame rate
frame_rate = 60
# execution preferenes
ui_only_mode = False
# ui_only_mode = True
show_fps = False
show_fps = True
# colours
background_colour = (11, 11, 11)
background_colour = (1, 1, 1)
line_colour = (163, 163, 163)
line_width = 2
white = pygame.Color(255, 255, 255)
red = pygame.Color(255, 0, 0)
green = pygame.Color(0, 255, 0)
blue = pygame.Color(0, 0, 255)
# menu ui
menu_ratio = 0.18
menu_width = menu_ratio * resolution[0]
menu_height = resolution[1]
menu_x_buffer = 0.05
menu_y_buffer = 0.5
ui_height = 0.06
slider_height = 0.9
# slider
slider_range = (5, 25)
slider_default = 15
# topic
topics = ["Sorting", "Graph Search", "Maze Solving"]
start_topic = 2
# visualization area
main_x = menu_width + line_width
main_width = resolution[0] - menu_width - line_width
main_height = resolution[1]
# higher the fps_delay_ratio the smaller the delay
# sorting
sorting_options = ["Merge Sort", "Heap Sort"]
sorting_c_map = {0: pygame.Color((255, 252, 252)), 1: pygame.Color((230, 37, 37)),
2: pygame.Color((41, 227, 146)), 3: pygame.Color((0, 174, 255))}
# sorting c_map => 0: regular | 1: being compared | 2: being copied into local sorted array | 3: fully sorted
default_sorting_size = 100
sorting_shuffle = True
bar_gap = 0.6
sorting_fps_delay_ratio = 2.4
heap_sort_colours = [pygame.Color((235, 183, 52)), pygame.Color((186, 235, 52)), pygame.Color((128, 166, 106)),
pygame.Color((92, 202, 242)), pygame.Color((14, 143, 230)), pygame.Color((93, 115, 240)),
pygame.Color((167, 92, 242)), pygame.Color((219, 121, 188))]
# graph search
graph_storage_file = "storage/stored_graphs.pickle"
graph_options = ["Depth First", "Breadth First"]
graph_buffer = math.floor(0.01 * main_height)
radius_height_ratio = 3/600
graph_fps_delay_ratio = 8
vertex_c_map = {0: pygame.Color(184, 191, 184), 1: pygame.Color(8, 237, 0), 2: pygame.Color(194, 2, 232),
3: pygame.Color(252, 186, 3), 4: pygame.Color(209, 54, 23), 5: pygame.Color(2, 134, 242)}
# vertex_c_map => 0: regular | 1: start | 2: end | 3: current | 4: discovered | 5: done | 6: path
edge_c_map = {0: pygame.Color(60, 60, 60), 1: pygame.Color(200, 200, 200)}
# edge_c_map => 0: undiscovered | 1: discovered
edge_c_map[2] = vertex_c_map[6] = pygame.Color(214, 209, 69)
edge_c_map[2] = vertex_c_map[6] = pygame.Color(199, 113, 56)
# maze solve
maze_options = ["Dijkstra", "A* Search"]
maze_buffer = math.floor(0.04 * main_height)
maze_colour = pygame.Color((200, 200, 200))
maze_thick = 1
maze_bg_colour = pygame.Color((30, 30, 30))
maze_fps_delay_ratio = 2.4
# algo topics
option_dict = {topics[0]: sorting_options, topics[1]: graph_options, topics[2]: maze_options}