示例#1
0
    def __init__(self, x, y):

        # call init of parent class
        pygame.sprite.Sprite.__init__(self)

        # init graphics with object's sprite - do not touch!
        init_graphics(self, x, y, "wall")

        # real coordinates of object
        self.x = x
        self.y = y
示例#2
0
    def __init__(self, x, y):

        # call init of parent class
        pygame.sprite.Sprite.__init__(self)

        # init graphics with object's sprite - do not touch!
        init_graphics(self, x, y, "dinner_table_active")

        # real coordinates of object
        self.x = x
        self.y = y

        # states of table
        self.state = 1
示例#3
0
    def __init__(self, x, y):

        # call init of parent class
        pygame.sprite.Sprite.__init__(self)

        # init graphics with object's sprite - do not touch!
        init_graphics(self, x, y, "furnace_active")

        # real coordinates of object
        self.x = x
        self.y = y

        # lists with data
        self.orderedDishes = {}
        self.readyDishes = {}

        # how long does this furnace cook?
        # for ai learning purpose - waiter has to minimize time in restaurant
        self.state = 1
示例#4
0
 def activated(self):
     # serve object:
     # init graphics with object's sprite - do not touch!
     init_graphics(self, self.x, self.y, "furnace")
     self.state = 0
示例#5
0
    def __init__(self, n, matrix_fields, num_tables, num_furnaces, num_walls, solving_method):
        print("Agent: initializing object...")

        # call init of parent class
        pygame.sprite.Sprite.__init__(self)

        # check if there is enough space for everyting in simulation
        if num_tables + num_furnaces + num_walls + 1 > n*n:
            print("Agent: Not enough space in restaurant for objects!")
            sys.exit("N-space overflow")

        self.n = n

        # init restaurant - matrix of objects
        self.restaurant = Matrix(n, n)

        # set random coordinates of agent
        self.x, self.y = matrix_fields[0][0], matrix_fields[0][1]

        # init graphics with object's sprite - do not touch!
        init_graphics(self, self.x, self.y, "waiter")

        # add objects to restaurant - creates tables and furnaces basing on random positions in the matrix
        # objects have coordinates like in matrix (0..n, 0..n):

        # add ghostwaiter to restaurant to mark waiters position
        self.restaurant.insert('W', self.x, self.y)

        # counter counts number of used coordinates, so no object will occupy the same space in simulation
        counter = 1

        # add tables
        for i in range(num_tables):
            self.restaurant.simple_insert(DinningTable(matrix_fields[i + counter][0], matrix_fields[i + counter][1]))

        # increase counter with number of used coordinates
        counter += num_tables

        # add furnaces
        for i in range(num_furnaces):
            self.restaurant.simple_insert(Furnace(matrix_fields[i + counter][0], matrix_fields[i + counter][1]))

        # increase counter with number of used coordinates
        counter += num_furnaces

        # add furnaces
        for i in range(num_walls):
            self.restaurant.simple_insert(Wall(matrix_fields[i + counter][0], matrix_fields[i + counter][1]))

        # calculate graph
        self.graph = self.restaurant.to_graph()
        self.graph2 = self.restaurant.to_graph_visited_or_not()
        # set list of objects
        self.objects_coordinates = matrix_fields[1:counter]
        # set list of goals
        self.goals = self.objects_coordinates[:]

        # set permutations of goals
        self.goalsPer = list(map(list, list(itertools.permutations(self.goals[:]))))

        # set list of solutions
        self.solutions = []

        # set path
        self.path = []

        # set all available solving methods names
        self.available_methods = ['depthfs', 'breadthfs', 'bestfs']
        self.unsupervised_learning = ['rabbit', 'svm', 'dtree', 'lreg']

        # set unsupervised learning safety switch
        self.moves_queue = [[0, 0], [0, 0], [0, 0], [0, 0]]

        # set neighbourhood
        self.neighbourhood = []
        self.neighbourhood_size = 5

        # set solving method
        self.solving_method = solving_method

        # svm model variable
        self.svm_data = []
        self.svm_target = []
        if self.solving_method == 'svm':
            self.init_svm()
        elif self.solving_method == "dtree":
            self.init_dtree()

        # run solution seeking
        self.solve(self.solving_method)
        self.control = True

        # add steps counter
        self.steps_count = 0

        print("Agent: initialization completed.")