tsp v2
This commit is contained in:
parent
316615dec6
commit
005255ee9b
@ -1,10 +1,13 @@
|
|||||||
import numpy as np, random, operator, pandas as pd, matplotlib.pyplot as plt
|
import numpy as np, random, operator, pandas as pd, matplotlib.pyplot as plt
|
||||||
|
from path_search_algorthms import a_star
|
||||||
|
from decision_tree import decisionTree
|
||||||
|
|
||||||
# klasa tworząca miasta czy też śmietniki
|
# klasa tworząca miasta czy też śmietniki
|
||||||
class City:
|
class City:
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y, dist):
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
|
# self.dist = distance
|
||||||
|
|
||||||
def distance(self, city):
|
def distance(self, city):
|
||||||
xDis = abs(self.x - city.x)
|
xDis = abs(self.x - city.x)
|
||||||
|
9
main.py
9
main.py
@ -17,7 +17,7 @@ from path_search_algorthms import a_star, a_star_utils
|
|||||||
from decision_tree import decisionTree
|
from decision_tree import decisionTree
|
||||||
from NeuralNetwork import prediction
|
from NeuralNetwork import prediction
|
||||||
from game_objects.trash import Trash
|
from game_objects.trash import Trash
|
||||||
|
from genetic_algorithm import TSP
|
||||||
from game_objects import aiPlayer
|
from game_objects import aiPlayer
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
@ -155,7 +155,14 @@ class Game():
|
|||||||
# print(self.positive_actions[0])
|
# print(self.positive_actions[0])
|
||||||
|
|
||||||
# self.t.startAiController(self.positive_actions[0])
|
# self.t.startAiController(self.positive_actions[0])
|
||||||
|
def init_TSP(self):
|
||||||
|
city_list = self.positive_decision
|
||||||
|
dist = a_star.path_dist
|
||||||
|
|
||||||
|
for i in range(0,25):
|
||||||
|
city_list.append(TSP.City(x=int(random.random() * 200), y=int(random.random() * 200)))
|
||||||
|
|
||||||
|
tsp_list = TSP.geneticAlgorithm(population=city_list, popSize=100, eliteSize=20, mutationRate=0.01, generations=1000)
|
||||||
|
|
||||||
def load_data(self):
|
def load_data(self):
|
||||||
game_folder = path.dirname(__file__)
|
game_folder = path.dirname(__file__)
|
||||||
|
Loading…
Reference in New Issue
Block a user