diff --git a/Algorithms/bfs.py b/Algorithms/bfs.py deleted file mode 100644 index 5ab2808..0000000 --- a/Algorithms/bfs.py +++ /dev/null @@ -1,26 +0,0 @@ -import pygame -from queue import PriorityQueue - -def reconstruct(came, end, draw): - while end in came: - end = came[end] - end.make_path() - draw() - - -def astar(draw, grid, start, end, mode): - pygame.init() - run = True - - while run: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - return False - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_BACKSPACE: - if mode == 0: - mode = 1 - else: - mode = 0 - - return True diff --git a/Sorts/__init__.py b/Sorts/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Visualiser.py b/Visualiser.py index 4a9707b..9457ef3 100644 --- a/Visualiser.py +++ b/Visualiser.py @@ -1,33 +1,7 @@ import pygame import os -import sys - -from Algorithms.nodes.nodes import * -from Algorithms.nodes.button import * -from Algorithms.prims import prims -from Algorithms.astar import astar -from Algorithms.dijkstra import dijkstra -from Algorithms.kruskal import kruskal -from Algorithms.sidewinder import sidewinder -from Algorithms.recursive_backtracking import backtrack -from Algorithms.ellers import ellers -from Algorithms.aldous_broder import aldous -from Algorithms.wilson import wilson -from Algorithms.hunt_and_kill import hunt -from Algorithms.growing_tree import tree -from Algorithms.binary_tree import binary -from Algorithms.recursive_division import division - -FILEPATH = os.getcwd() - -WIDTH = 1584 -COLUMNS = 99 - -HEIGHT = 784 -ROWS = 49 - -GREY = (128,128,128) -WHITE = (255,255,255) + +from Visualiser import * stage = 3 rainbow = [(255, 0, 0), (255, 255, 0), (0, 255, 0), (0, 0, 255), (75, 0, 130), (150, 0, 255)] @@ -38,7 +12,7 @@ WIN = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Visualiser") -pygame.display.set_icon(pygame.image.load(os.path.join(FILEPATH, 'Fonts', 'icon.png'))) +pygame.display.set_icon(pygame.image.load(ICON)) def make_grid(): grid = [] @@ -245,7 +219,7 @@ def helppage(k=False): Quit = False inv = False - background1 = pygame.image.load(os.path.join(FILEPATH, 'Fonts', 'Help1.png')) + background1 = pygame.image.load(HELP1) nextpage = button((0, 0, 0), 1440, 350, 75, 100, FILEPATH, (0, 0, 0), text='>') while not Quit: @@ -281,7 +255,7 @@ def helppage2(): inv1 = False page = 1 - background2 = pygame.image.load(os.path.join(FILEPATH, 'Fonts', 'Help2.png')) + background2 = pygame.image.load(HELP2) prevpage = button((0, 0, 0), 1440, 350, 75, 100, FILEPATH, (0, 0, 0), text='<') while not Quit: diff --git a/Algorithms/__init__.py b/Visualiser/Algorithms/Maze/__init__.py similarity index 71% rename from Algorithms/__init__.py rename to Visualiser/Algorithms/Maze/__init__.py index 278849f..55f7aab 100644 --- a/Algorithms/__init__.py +++ b/Visualiser/Algorithms/Maze/__init__.py @@ -1,11 +1,11 @@ -from .aldous_broder import aldous -from .astar import astar -from .binary_tree import binary -from .dijkstra import dijkstra -from .ellers import ellers -from .growing_tree import tree -from .hunt_and_kill import hunt -from .kruskal import kruskal from .prims import prims +from .kruskal import kruskal +from .sidewinder import sidewinder from .recursive_backtracking import backtrack -from .nodes import * \ No newline at end of file +from .ellers import ellers +from .aldous_broder import aldous +from .wilson import wilson +from .hunt_and_kill import hunt +from .growing_tree import tree +from .binary_tree import binary +from .recursive_division import division \ No newline at end of file diff --git a/Algorithms/aldous_broder.py b/Visualiser/Algorithms/Maze/aldous_broder.py similarity index 94% rename from Algorithms/aldous_broder.py rename to Visualiser/Algorithms/Maze/aldous_broder.py index 1f03982..6901b96 100644 --- a/Algorithms/aldous_broder.py +++ b/Visualiser/Algorithms/Maze/aldous_broder.py @@ -1,11 +1,9 @@ import pygame + from random import randint, choice +from ...constants import MAZE_ABSOLUTE_ROWS, MAZE_ABSOLUTE_COLUMNS extra_vis = False - -row = 24 -col = 49 - clk = pygame.time.Clock() def drawedge(draw, edge, grid, mode): @@ -81,11 +79,11 @@ def getnextnode(node): """ x, y = node neighbours = [] - if x < row: + if x < MAZE_ABSOLUTE_ROWS: neighbours.append((x+1, y)) if x > 0: neighbours.append((x-1, y)) - if y < col: + if y < MAZE_ABSOLUTE_COLUMNS: neighbours.append((x, y+1)) if y > 0: neighbours.append((x, y-1)) @@ -107,13 +105,13 @@ def getrandom(node, visited): except: return [] neighbours = [] - if x < row: + if x < MAZE_ABSOLUTE_ROWS: if (x+1, y) not in visited: neighbours.append((x+1, y)) if x > 0: if (x-1, y) not in visited: neighbours.append((x-1, y)) - if y < col: + if y < MAZE_ABSOLUTE_COLUMNS: if (x, y+1) not in visited: neighbours.append((x, y+1)) if y > 0: @@ -144,8 +142,8 @@ def aldous(draw, grid, mode): c = len(grid[0]) run = True global extra_vis - for row in grid: - for node in row: + for rows in grid: + for node in rows: node.reset() node.invert() diff --git a/Algorithms/algorithms.md b/Visualiser/Algorithms/Maze/algorithms.md similarity index 100% rename from Algorithms/algorithms.md rename to Visualiser/Algorithms/Maze/algorithms.md diff --git a/Visualiser/Algorithms/Maze/bfs.py b/Visualiser/Algorithms/Maze/bfs.py new file mode 100644 index 0000000..0756caf --- /dev/null +++ b/Visualiser/Algorithms/Maze/bfs.py @@ -0,0 +1,26 @@ +# import pygame +# from queue import PriorityQueue + +# def reconstruct(came, end, draw): +# while end in came: +# end = came[end] +# end.make_path() +# draw() + + +# def astar(draw, grid, start, end, mode): +# pygame.init() +# run = True + +# while run: +# for event in pygame.event.get(): +# if event.type == pygame.QUIT: +# return False +# if event.type == pygame.KEYDOWN: +# if event.key == pygame.K_BACKSPACE: +# if mode == 0: +# mode = 1 +# else: +# mode = 0 + +# return True diff --git a/Algorithms/binary_tree.py b/Visualiser/Algorithms/Maze/binary_tree.py similarity index 83% rename from Algorithms/binary_tree.py rename to Visualiser/Algorithms/Maze/binary_tree.py index 50d5d84..546d571 100644 --- a/Algorithms/binary_tree.py +++ b/Visualiser/Algorithms/Maze/binary_tree.py @@ -1,9 +1,7 @@ import pygame -from random import randint -# clk = pygame.time.Clock() -row = 24 -col = 49 +from random import randint +from ...constants import MAZE_ABSOLUTE_ROWS, MAZE_ABSOLUTE_COLUMNS def rand(): return randint(0,1) @@ -24,7 +22,7 @@ def binary(draw, grid, mode): draw() i = 1 - while run and i != row + 1: + while run and i != MAZE_ABSOLUTE_ROWS + 1: # clk.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: @@ -37,7 +35,7 @@ def binary(draw, grid, mode): mode = 1 else: mode = 0 - for j in range(col+ 1): + for j in range(MAZE_ABSOLUTE_COLUMNS+ 1): current = (i, j) if rand() == 1: @@ -56,16 +54,16 @@ def binary(draw, grid, mode): def movewest(node): x, y = node - if y < col: + if y < MAZE_ABSOLUTE_COLUMNS: return True return False -def drawedge(draw, grid, current, mode, direc): +def drawedge(draw, grid, current, mode, direction): x, y = current grid[x*2][y*2].remove_barrier() - if direc == 'north': + if direction == 'north': grid[x*2-1][y*2].remove_barrier() - elif direc == 'west': + elif direction == 'west': grid[x*2][y*2+1].remove_barrier() if mode == 0: draw() \ No newline at end of file diff --git a/Algorithms/ellers.py b/Visualiser/Algorithms/Maze/ellers.py similarity index 95% rename from Algorithms/ellers.py rename to Visualiser/Algorithms/Maze/ellers.py index a705cad..c74c167 100644 --- a/Algorithms/ellers.py +++ b/Visualiser/Algorithms/Maze/ellers.py @@ -1,10 +1,9 @@ import pygame + from random import randint, choice +from ...constants import MAZE_ABSOLUTE_ROWS, MAZE_ABSOLUTE_COLUMNS clk = pygame.time.Clock() -row = 24 -col = 49 - def getboolean(): if randint(0, 1) == 0: @@ -111,15 +110,15 @@ def ellers(draw, grid, mode): s = 1 celllist = [] - for b in range(row+1): + for b in range(MAZE_ABSOLUTE_ROWS+1): celllist.append([]) - for j in range(col+1): + for j in range(MAZE_ABSOLUTE_COLUMNS+1): celllist[b].append(Cell(b, j, s)) s += 1 i = 0 currrow = celllist[i] - while i < row: + while i < MAZE_ABSOLUTE_ROWS: clk.tick(30) # i += 1 for event in pygame.event.get(): diff --git a/Algorithms/growing_tree.py b/Visualiser/Algorithms/Maze/growing_tree.py similarity index 97% rename from Algorithms/growing_tree.py rename to Visualiser/Algorithms/Maze/growing_tree.py index 91b7b4a..24a6e78 100644 --- a/Algorithms/growing_tree.py +++ b/Visualiser/Algorithms/Maze/growing_tree.py @@ -1,12 +1,10 @@ import pygame + from random import randint, choice +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col -# clk = pygame.time.Clock() -row = 24 -col = 49 def noneb(stack, visited): - # x, y = node neighbours = [] for node in stack: count = 0 diff --git a/Algorithms/hunt_and_kill.py b/Visualiser/Algorithms/Maze/hunt_and_kill.py similarity index 98% rename from Algorithms/hunt_and_kill.py rename to Visualiser/Algorithms/Maze/hunt_and_kill.py index 5b129ab..e057eb3 100644 --- a/Algorithms/hunt_and_kill.py +++ b/Visualiser/Algorithms/Maze/hunt_and_kill.py @@ -1,8 +1,8 @@ import pygame + from random import randint, choice, shuffle +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col -row = 24 -col = 49 clk = pygame.time.Clock() def update(node, visited): diff --git a/Algorithms/kruskal.py b/Visualiser/Algorithms/Maze/kruskal.py similarity index 97% rename from Algorithms/kruskal.py rename to Visualiser/Algorithms/Maze/kruskal.py index fa1405c..bcf3ae8 100644 --- a/Algorithms/kruskal.py +++ b/Visualiser/Algorithms/Maze/kruskal.py @@ -1,9 +1,7 @@ import pygame from random import randint, choice, shuffle +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col -row = 24 -col = 49 -GREEN = (0,255,0) # clk = pygame.time.Clock() def findparent(v, parent): diff --git a/Algorithms/prims.py b/Visualiser/Algorithms/Maze/prims.py similarity index 96% rename from Algorithms/prims.py rename to Visualiser/Algorithms/Maze/prims.py index 5100ac4..75604f1 100644 --- a/Algorithms/prims.py +++ b/Visualiser/Algorithms/Maze/prims.py @@ -1,8 +1,7 @@ import pygame -from random import choice, shuffle, randint -row = 24 -col = 49 +from random import choice, shuffle, randint +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col def getneighbour(node, visited): x, y = node diff --git a/Algorithms/recursive_backtracking.py b/Visualiser/Algorithms/Maze/recursive_backtracking.py similarity index 97% rename from Algorithms/recursive_backtracking.py rename to Visualiser/Algorithms/Maze/recursive_backtracking.py index d3121f7..ebdfd72 100644 --- a/Algorithms/recursive_backtracking.py +++ b/Visualiser/Algorithms/Maze/recursive_backtracking.py @@ -1,8 +1,9 @@ import pygame + from random import randint, choice -row = 24 -col = 49 +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col + clk = pygame.time.Clock() def update(node, visited): diff --git a/Algorithms/recursive_division.py b/Visualiser/Algorithms/Maze/recursive_division.py similarity index 100% rename from Algorithms/recursive_division.py rename to Visualiser/Algorithms/Maze/recursive_division.py diff --git a/Algorithms/sidewinder.py b/Visualiser/Algorithms/Maze/sidewinder.py similarity index 95% rename from Algorithms/sidewinder.py rename to Visualiser/Algorithms/Maze/sidewinder.py index 9fb3ae0..8d03a91 100644 --- a/Algorithms/sidewinder.py +++ b/Visualiser/Algorithms/Maze/sidewinder.py @@ -1,8 +1,8 @@ import pygame + from random import shuffle, randint, choice +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col -row = 24 -col = 49 def rand(): return randint(0,1) diff --git a/Algorithms/wilson.py b/Visualiser/Algorithms/Maze/wilson.py similarity index 97% rename from Algorithms/wilson.py rename to Visualiser/Algorithms/Maze/wilson.py index ea57d8f..f48877e 100644 --- a/Algorithms/wilson.py +++ b/Visualiser/Algorithms/Maze/wilson.py @@ -1,10 +1,8 @@ import pygame + from random import randint, shuffle, choice -row = 24 -col = 49 -LIGHTGREEN = (55,205,55) -LIGHTRED = (255, 130, 130) +from ...constants import MAZE_ABSOLUTE_ROWS as row, MAZE_ABSOLUTE_COLUMNS as col, LIGHTGREEN, LIGHTRED d = ['n', 's', 'e', 'w'] clk = pygame.time.Clock() diff --git a/Visualiser/Algorithms/Path/__init__.py b/Visualiser/Algorithms/Path/__init__.py new file mode 100644 index 0000000..3b571cf --- /dev/null +++ b/Visualiser/Algorithms/Path/__init__.py @@ -0,0 +1,2 @@ +from .astar import astar +from .dijkstra import dijkstra \ No newline at end of file diff --git a/Algorithms/astar.py b/Visualiser/Algorithms/Path/astar.py similarity index 100% rename from Algorithms/astar.py rename to Visualiser/Algorithms/Path/astar.py diff --git a/Algorithms/dijkstra.py b/Visualiser/Algorithms/Path/dijkstra.py similarity index 100% rename from Algorithms/dijkstra.py rename to Visualiser/Algorithms/Path/dijkstra.py diff --git a/Visualiser/Algorithms/Sort/__init__.py b/Visualiser/Algorithms/Sort/__init__.py new file mode 100644 index 0000000..11ffde1 --- /dev/null +++ b/Visualiser/Algorithms/Sort/__init__.py @@ -0,0 +1,24 @@ +from .bead import bead +from .bitonic import bitonic +from .bogo import bogo +from .bubble import bubble +from .bucket import bucket +from .cocktail import cocktail +from .comb import comb +from .counting import counting +from .cycle import cycle +from .double import double +from .gnome import gnome +from .heap import heap +from .insertion import insertion +from .merge import iterativemerge +from .oddeven import oddeven +from .pancake import pancake +from .pigeon import pigeon +from .quick import quick +from .radix import radix +from .shell import shell +from .selection import selection +from .sleep import sleepsort +from .stooge import stooge +from .wiggle import wiggle \ No newline at end of file diff --git a/Sorts/algorithms.md b/Visualiser/Algorithms/Sort/algorithms.md similarity index 100% rename from Sorts/algorithms.md rename to Visualiser/Algorithms/Sort/algorithms.md diff --git a/Sorts/bead.py b/Visualiser/Algorithms/Sort/bead.py similarity index 100% rename from Sorts/bead.py rename to Visualiser/Algorithms/Sort/bead.py diff --git a/Sorts/bitonic.py b/Visualiser/Algorithms/Sort/bitonic.py similarity index 100% rename from Sorts/bitonic.py rename to Visualiser/Algorithms/Sort/bitonic.py diff --git a/Sorts/bogo.py b/Visualiser/Algorithms/Sort/bogo.py similarity index 100% rename from Sorts/bogo.py rename to Visualiser/Algorithms/Sort/bogo.py diff --git a/Sorts/bubble.py b/Visualiser/Algorithms/Sort/bubble.py similarity index 100% rename from Sorts/bubble.py rename to Visualiser/Algorithms/Sort/bubble.py diff --git a/Sorts/bucket.py b/Visualiser/Algorithms/Sort/bucket.py similarity index 100% rename from Sorts/bucket.py rename to Visualiser/Algorithms/Sort/bucket.py diff --git a/Sorts/cocktail.py b/Visualiser/Algorithms/Sort/cocktail.py similarity index 100% rename from Sorts/cocktail.py rename to Visualiser/Algorithms/Sort/cocktail.py diff --git a/Sorts/comb.py b/Visualiser/Algorithms/Sort/comb.py similarity index 100% rename from Sorts/comb.py rename to Visualiser/Algorithms/Sort/comb.py diff --git a/Sorts/counting.py b/Visualiser/Algorithms/Sort/counting.py similarity index 100% rename from Sorts/counting.py rename to Visualiser/Algorithms/Sort/counting.py diff --git a/Sorts/cycle.py b/Visualiser/Algorithms/Sort/cycle.py similarity index 100% rename from Sorts/cycle.py rename to Visualiser/Algorithms/Sort/cycle.py diff --git a/Sorts/double.py b/Visualiser/Algorithms/Sort/double.py similarity index 100% rename from Sorts/double.py rename to Visualiser/Algorithms/Sort/double.py diff --git a/Sorts/gnome.py b/Visualiser/Algorithms/Sort/gnome.py similarity index 100% rename from Sorts/gnome.py rename to Visualiser/Algorithms/Sort/gnome.py diff --git a/Sorts/heap.py b/Visualiser/Algorithms/Sort/heap.py similarity index 100% rename from Sorts/heap.py rename to Visualiser/Algorithms/Sort/heap.py diff --git a/Sorts/insertion.py b/Visualiser/Algorithms/Sort/insertion.py similarity index 100% rename from Sorts/insertion.py rename to Visualiser/Algorithms/Sort/insertion.py diff --git a/Sorts/merge.py b/Visualiser/Algorithms/Sort/merge.py similarity index 100% rename from Sorts/merge.py rename to Visualiser/Algorithms/Sort/merge.py diff --git a/Sorts/oddeven.py b/Visualiser/Algorithms/Sort/oddeven.py similarity index 100% rename from Sorts/oddeven.py rename to Visualiser/Algorithms/Sort/oddeven.py diff --git a/Sorts/pancake.py b/Visualiser/Algorithms/Sort/pancake.py similarity index 100% rename from Sorts/pancake.py rename to Visualiser/Algorithms/Sort/pancake.py diff --git a/Sorts/pigeon.py b/Visualiser/Algorithms/Sort/pigeon.py similarity index 100% rename from Sorts/pigeon.py rename to Visualiser/Algorithms/Sort/pigeon.py diff --git a/Sorts/quick.py b/Visualiser/Algorithms/Sort/quick.py similarity index 100% rename from Sorts/quick.py rename to Visualiser/Algorithms/Sort/quick.py diff --git a/Sorts/radix.py b/Visualiser/Algorithms/Sort/radix.py similarity index 100% rename from Sorts/radix.py rename to Visualiser/Algorithms/Sort/radix.py diff --git a/Sorts/selection.py b/Visualiser/Algorithms/Sort/selection.py similarity index 100% rename from Sorts/selection.py rename to Visualiser/Algorithms/Sort/selection.py diff --git a/Sorts/shell.py b/Visualiser/Algorithms/Sort/shell.py similarity index 100% rename from Sorts/shell.py rename to Visualiser/Algorithms/Sort/shell.py diff --git a/Sorts/sleep.py b/Visualiser/Algorithms/Sort/sleep.py similarity index 100% rename from Sorts/sleep.py rename to Visualiser/Algorithms/Sort/sleep.py diff --git a/Sorts/stooge.py b/Visualiser/Algorithms/Sort/stooge.py similarity index 100% rename from Sorts/stooge.py rename to Visualiser/Algorithms/Sort/stooge.py diff --git a/Sorts/wiggle.py b/Visualiser/Algorithms/Sort/wiggle.py similarity index 100% rename from Sorts/wiggle.py rename to Visualiser/Algorithms/Sort/wiggle.py diff --git a/Visualiser/Algorithms/__init__.py b/Visualiser/Algorithms/__init__.py new file mode 100644 index 0000000..f51dfc5 --- /dev/null +++ b/Visualiser/Algorithms/__init__.py @@ -0,0 +1,3 @@ +from .Maze import * +from .Sort import * +from .Path import * \ No newline at end of file diff --git a/Algorithms/nodes/__init__.py b/Visualiser/Utils/__init__.py similarity index 100% rename from Algorithms/nodes/__init__.py rename to Visualiser/Utils/__init__.py diff --git a/Algorithms/nodes/button.py b/Visualiser/Utils/button.py similarity index 100% rename from Algorithms/nodes/button.py rename to Visualiser/Utils/button.py diff --git a/Algorithms/nodes/lines.py b/Visualiser/Utils/lines.py similarity index 83% rename from Algorithms/nodes/lines.py rename to Visualiser/Utils/lines.py index 1d7c175..0c7d7e3 100644 --- a/Algorithms/nodes/lines.py +++ b/Visualiser/Utils/lines.py @@ -1,17 +1,6 @@ import pygame -RED = (255,0,0) -GREEN = (0,255,0) -BLACK = (0,0,0) -# BLACK = (128,128,128) - - -W = 1584 -H = 784 - -WIDTH = 1584/256 - -HEIGHT = 784/256 +from ..constants import * class Line(): def __init__(self, x, no): @@ -25,7 +14,7 @@ def __init__(self, x, no): self.color = BLACK self.flash = 0 self.no = no - self.x = (no)*WIDTH + self.x = (no)*LINE_WIDTH def make_red(self): """Change line color to red @@ -52,12 +41,12 @@ def change(self, val): val (int): Position Value """ self.no = val - self.x = (val)*WIDTH + self.x = (val)*LINE_WIDTH def move(self, val): k = self.no+1 self.no = val-1 - self.x = (val-1)*WIDTH + self.x = (val-1)*LINE_WIDTH return k def evalu(self, val): @@ -86,4 +75,4 @@ def draw(self, win): self.flash -= 1 elif self.flash == 0: self.color = BLACK - pygame.draw.rect(win, self.color, (self.x, H-HEIGHT*self.value, WIDTH, HEIGHT*self.value)) + pygame.draw.rect(win, self.color, (self.x, HEIGHT-LINE_HEIGHT*self.value, WIDTH, LINE_HEIGHT*self.value)) diff --git a/Algorithms/nodes/nodes.py b/Visualiser/Utils/nodes.py similarity index 97% rename from Algorithms/nodes/nodes.py rename to Visualiser/Utils/nodes.py index 54c26f8..57abe25 100644 --- a/Algorithms/nodes/nodes.py +++ b/Visualiser/Utils/nodes.py @@ -1,20 +1,7 @@ import pygame -from pygame import gfxdraw -RED = (255,0,0) -GREEN = (0,255,0) -BLUE = (0,0,255) -YELLOW = (255,255,0) -WHITE = (255,255,255) -BLACK = (0,0,0) -PURPLE = (128,0,128) -ORANGE = (255,165,0) -GREY = (128,128,128) -TURQUOISE = (64,224,208) -LIGHTGREEN = (50,205,50) -LIGHTRED = (255, 127, 127) -LIGHTGREEN2 = (55,205,55) -LIGHTRED2 = (255, 130, 130) +from pygame import gfxdraw +from ..constants import * class Nodes: diff --git a/Visualiser/__init__.py b/Visualiser/__init__.py new file mode 100644 index 0000000..f0de37e --- /dev/null +++ b/Visualiser/__init__.py @@ -0,0 +1,3 @@ +from .Algorithms import * +from .Utils import * +from .constants import * \ No newline at end of file diff --git a/Visualiser/constants.py b/Visualiser/constants.py new file mode 100644 index 0000000..887dd39 --- /dev/null +++ b/Visualiser/constants.py @@ -0,0 +1,43 @@ +# -------------------------------------------------- +# Colours +# -------------------------------------------------- + +RED = (255,0,0) +GREEN = (0,255,0) +BLUE = (0,0,255) +YELLOW = (255,255,0) +WHITE = (255,255,255) +BLACK = (0,0,0) +PURPLE = (128,0,128) +ORANGE = (255,165,0) +GREY = (128,128,128) +TURQUOISE = (64,224,208) +LIGHTGREEN = (50,205,50) +LIGHTRED = (255, 127, 127) +LIGHTGREEN2 = (55,205,55) +LIGHTRED2 = (255, 130, 130) + +# -------------------------------------------------- +# DIMENTIONS +# -------------------------------------------------- + +WIDTH = 1584 +COLUMNS = 99 + +HEIGHT = 784 +ROWS = 49 + +MAZE_ABSOLUTE_ROWS, MAZE_ABSOLUTE_COLUMNS = 24, 49 + +# -------------------------------------------------- +# SORTING LINE DIMENTIONS +# -------------------------------------------------- + +LINE_WIDTH = 1584/256 +LINE_HEIGHT = 784/256 + +import os +FILEPATH = os.getcwd() +ICON = os.path.join(FILEPATH, 'Fonts', 'icon.png') +HELP1 = os.path.join(FILEPATH, 'Fonts', 'Help1.png') +HELP2 = os.path.join(FILEPATH, 'Fonts', 'Help2.png') \ No newline at end of file diff --git a/app.py b/app.py index 449cdce..06d8d76 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ import os import sort -from Algorithms.nodes.button import * +from Visualiser import button import Visualiser os.environ['SDL_VIDEO_CENTERED'] = '1' diff --git a/sort.py b/sort.py index 24f31d1..6c4cf38 100644 --- a/sort.py +++ b/sort.py @@ -1,51 +1,13 @@ import pygame import os -from Algorithms.nodes.lines import Line -from Algorithms.nodes.button import button - -from Sorts.bead import bead -from Sorts.bitonic import bitonic -from Sorts.bogo import bogo -from Sorts.bubble import bubble -from Sorts.bucket import bucket -from Sorts.cocktail import cocktail -from Sorts.comb import comb -from Sorts.counting import counting -from Sorts.cycle import cycle -from Sorts.double import double -from Sorts.gnome import gnome -from Sorts.heap import heap -from Sorts.insertion import insertion -from Sorts.merge import iterativemerge -from Sorts.oddeven import oddeven -from Sorts.pancake import pancake -from Sorts.pigeon import pigeon -from Sorts.quick import quick -from Sorts.radix import radix -from Sorts.shell import shell -from Sorts.selection import selection -from Sorts.sleep import sleepsort -from Sorts.stooge import stooge -from Sorts.wiggle import wiggle - +from Visualiser import * from random import shuffle, randint, choice - pygame.init() -FILEPATH = os.getcwd() - # infoObject = pygame.display.Info() -WIDTH = 1584 -COLUMNS = 256 - -HEIGHT = 784 - -WHITE = (255,255,255) -BLACK = (0,0,0) - WIN = pygame.display.set_mode((1584, 784)) pygame.display.set_caption("Visualiser: Edit")