/
Utility.py
47 lines (40 loc) · 1.15 KB
/
Utility.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
import random
import numpy as np
from DFS import *
from BFS import *
from AStar import *
class Utility:
@staticmethod
def shuffle(matrix):
n=len(matrix)
np.random.shuffle(matrix)
matrix[0][0]=1
matrix[n-1][n-1]=1
return matrix
@staticmethod
def performMutation(self):
print("gautam")
@staticmethod
def performCrossOver(self):
print("yes")
@staticmethod
def matrixGenerator(n,p):
Matrix = [[0 for x in range(n)] for y in range(n)]
for i in range(0, n, 1):
for j in range(0, n, 1):
prob = random.random()
if prob > p:
Matrix[i][j] = 1
Matrix[n-1][n-1] = 1
Matrix[0][0]=1
return Matrix
@staticmethod
def getAlgo(type,Matrix,startX,startY,n,grid,size):
if type=="DFS":
print("DFS")
result=DFS(Matrix, startX, startY, n - 1, n - 1, grid, n, size)
return result
if type=="BFS":
return BFS(Matrix,startX,startY,n-1,n-1,grid,n,size)
if type == "AStar":
return AStar(Matrix,startX,startY,n-1,n-1,grid,n,size,"Manhattan")