classes module
This file contains the logic to run the __main__.py body of the program.
Name: classes.py
Authors:
- Jurre Brandsen
- Lennart Klein
- Thomas de Lange
LICENSE: MIT
-
class
classes.Board(width, height, depth)[source]
Bases: object
Create a numpy board filled with numpy zeros upon initialising.
-
draw_paths()[source]
Draw all the paths for this board (if possible).
-
get_coords(axes, label)[source]
Get the coordinate of a board with it’s label.
| Parameters: |
- axes (string) – Devided coord into Z, Y, X
- label (numpy(object)) – Get a coord in board the corresponding label
|
| Return type: | tuple
|
-
get_neighbors(coord)[source]
Get the neighbors of a given coordinate.
| Parameters: | coord (coord(tuple)) – A coordinate on the board |
| Return type: | interger |
-
get_result(type_)[source]
Look at the path and analyze if it is commplete.
| Parameters: | type (string) – Returned value of a drawn line. |
-
get_score()[source]
Accumulated length of all the paths.
-
plot()[source]
Graph configurations uses plt from the .
-
print_board()[source]
Show the numpyboard in ASCII.
-
redraw_broken_path()[source]
Get first broken path.
-
redraw_random_path()[source]
Pick three random paths.
-
reset_coordinate(z, y, x)[source]
Reset the coordinates of a board to 0.
-
set_gates(gates)[source]
Set the gates on the board.
| Parameters: | gates (Gate(object)) – Give the selected netlist in settings.py. |
-
set_paths(netlist)[source]
Set the value of the netlist and appends it to the numpyboard.
| Parameters: | netlist (Netlist(object)) – Get de netlist object and use it to set the paths |
-
shorten_every_path()[source]
Redraw every path with DIJKSTRA pathfinding.
-
class
classes.Gate(label, x, y, z, spaces_needed)[source]
Bases: object
Gate sets the gates in a board.
-
get_free_spaces(board, coord)[source]
Interger with the amount of free spaces.
| Parameters: |
- board (numpy(object)) – a threedimensional Numpy array
- coord (interger) –
|
-
class
classes.Gates(number, sign, netlist)[source]
Bases: object
Gates Class that makes a board with gates.
-
get_gates()[source]
Return the own gates data.
-
reset_spaces_needed(netlist)[source]
Reset the amount of spaces needed.
| Parameters: | number – the netlist object |
-
class
classes.Netlist(number)[source]
Bases: object
Netlist are tuples reperesenting the contecion between two gates.
-
first_to_back()[source]
Give back the first ellement with python pop.
-
sort_by_connection()[source]
Rearrange self.list to a new array based connectins needed.
-
swap_back_one(target)[source]
Switch the target item with item before it.
| Parameters: | number – the netlist combination that must be switched |
-
class
classes.Path(coordA, coordB, aLabel, aColor)[source]
Bases: object
Path from A to B.
-
add_coordinate(coord)[source]
Add a new coordinate to self.path.
| Parameters: | coord (tuple) – a list of [Z, Y, X] |
-
draw(algorithm, board)[source]
Calculate route between two points.
| Parameters: |
- board (Board(object)) – a threedimensional Numpy array
- algorithm (method) – algorithm to draw the path
|
-
draw_ASTAR(board)[source]
Calculate route between two points with the A* algorithm.
| Parameters: | board (Board(object)) – a threedimensional Numpy array |
-
draw_DIJKSTRA(board)[source]
Calculate route between two points with the Dijkstra algorithm.
| Parameters: | board (Board(object)) – a threedimensional Numpy array |
-
get_coords(axes)[source]
Get coordinates of point with axes as input.
| Parameters: | number – tuple with value of x, y and z |
-
undraw(board)[source]
Remove paths from the board.
| Parameters: | board (Board(object)) – a threedimensional Numpy array |
-
class
classes.Queue[source]
Bases: object
Dequeue, append and count elements in a simple queue.
-
empty()[source]
Empty the queue.
-
pop()[source]
Pop a queue item.
| Return type: | Collections(object) |
-
push(x)[source]
Push an element to the queue.
-
class
classes.QueuePriority[source]
Bases: object
Dequeue, append and count elements in a priority queue.
-
empty()[source]
Empty the array.
-
pop()[source]
Pop elements from the queue.
-
push(data, prior)[source]
Push an element on to the queue.
-
class
classes.Solution[source]
Bases: object
Is a wraper class for all functions.
-
get_scores()[source]
Get all scores in the scores list.
-
plot_best()[source]
Plot the best result.
-
plot_results()[source]
Plot a graph to show the results over the different iterations.
-
plot_scores()[source]
Plot a graph to show the scores over the different iterations.
-
run(gates, netlist)[source]
Run the file used in __main.py.