changed distance in Fitness to Manhattan
This commit is contained in:
parent
62cae15baa
commit
cf649ef031
@ -10,7 +10,7 @@ class DecisionTree:
|
||||
|
||||
|
||||
def __init__(self, doCreation):
|
||||
self.data = pd.read_csv("C:\\Users\\kratu\\PycharmProjects\\Projekt_AI-Automatyczny_saper\\out.csv")
|
||||
self.data = pd.read_csv("C:\\Users\\Konrad\\PycharmProjects\\Projekt_AI-Automatyczny_saper\\out.csv")
|
||||
if doCreation:
|
||||
self.mapData()
|
||||
features = ['bomb_type', 'detonation_duration', 'size', 'detonation_area', 'defusable']
|
||||
@ -21,7 +21,7 @@ class DecisionTree:
|
||||
decision_tree_model_pkl = open('tree.pkl', 'wb')
|
||||
pickle.dump(dtree, decision_tree_model_pkl)
|
||||
decision_tree_model_pkl.close()
|
||||
decision_tree_model_pkl = open('C:\\Users\\kratu\\PycharmProjects\\Projekt_AI-Automatyczny_saper\\Engine\\tree.pkl', 'rb')
|
||||
decision_tree_model_pkl = open('C:\\Users\\Konrad\\PycharmProjects\\Projekt_AI-Automatyczny_saper\\Engine\\tree.pkl', 'rb')
|
||||
self.dtree = pickle.load(decision_tree_model_pkl)
|
||||
|
||||
def getTree(self):
|
||||
|
@ -33,7 +33,5 @@ class Fitness:
|
||||
return self.fitness
|
||||
|
||||
def cdistance(self, fromP, toP):
|
||||
xDis = abs(fromP.getX() - toP.getX())
|
||||
yDis = abs(fromP.getY() - toP.getY())
|
||||
distance = np.sqrt((xDis ** 2) + (yDis ** 2))
|
||||
return distance
|
||||
distance = abs(fromP.getX() - toP.getX()) + abs(fromP.getY() - toP.getY())
|
||||
return distance
|
||||
|
@ -19,7 +19,7 @@ from torch.utils.data import DataLoader
|
||||
|
||||
class Neurons:
|
||||
def __init__(self):
|
||||
dataset = MNIST('C:\\Users\\kratu\\PycharmProjects\\Projekt_AI-Automatyczny_saper\\Engine', gz=True, return_type='numpy')
|
||||
dataset = MNIST('C:\\Users\\Konrad\\PycharmProjects\\Projekt_AI-Automatyczny_saper\\Engine', gz=True, return_type='numpy')
|
||||
images, labels = dataset.load_training()
|
||||
test_images, test_labels = dataset.load_testing()
|
||||
images = images / 255
|
||||
@ -41,7 +41,7 @@ class Neurons:
|
||||
torch.save(self.train(self.model, 100), 'model.pth')
|
||||
imsize = 28
|
||||
loader = transforms.Compose([transforms.Resize((imsize, imsize)), transforms.ToTensor()])
|
||||
image = Image.open("C:\\Users\\kratu\\PycharmProjects\\JPG-PNG-to-MNIST-NN-Format\\test-images\\1\\claymore (1).png")
|
||||
image = Image.open("C:\\Users\\Konrad\\PycharmProjects\\JPG-PNG-to-MNIST-NN-Format\\test-images\\1\\claymore (1).png")
|
||||
image = image.convert("1")
|
||||
image = loader(image).float()
|
||||
image = Variable(image, requires_grad=True)
|
||||
|
@ -69,7 +69,7 @@ class Population:
|
||||
|
||||
def mutate(self, individual, mutationRate):
|
||||
for swapped in range(len(individual)):
|
||||
if (random.random() < mutationRate):
|
||||
if random.random() < mutationRate:
|
||||
swapWith = int(random.random() * len(individual))
|
||||
|
||||
city1 = individual[swapped]
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user