Beispiel #1
0
def selectProcess(command, authkeys):
    commandList = command.lower().split()
    command = command.lower()

    google_authkeys = authkeys["google"]
    yelp_authkeys = authkeys["yelp"]

    if (directionCommand(commandList)):
        return (Directions(command, google_authkeys))

    elif (dictionaryCommand(commandList)):
        return (dictionary(command))

    elif (yelpCommand(commandList)):
        return (Yelp(command, yelp_authkeys))

    elif (wikiCommand(commandList)):
        return (SearchWiki(command))

    elif (placesCommand(commandList)):
        return (GooglePlace(command, google_authkeys))

    elif (helpCommand(commandList)):
        return (printHelp())

    else:
        return ("We didn't understand your search, see if this helps:\n" +
                printHelp())
    def __init__(self, N, height, width, exponent, steps):
        self.number_of_agents = N
        self.height = height
        self.width = width
        self.exponent = exponent

        #self.x_locs = np.zeros((N, steps))
        #self.y_locs = np.zeros((N))

        self.direction_range=3
        self.directions = Directions(self.direction_range)
        self.current_step_contacts=[]
        self.adjacency_matrix = np.zeros((N, N))
        self.grid = MultiGrid(self.width, self.height, torus=False)
        self.schedule = BaseScheduler(self)

        self.current_step = 0

         # Add N pedestrians to model (schedule, grid)
        for i in range(self.number_of_agents):
            x = self.random.randrange(1, self.grid.width-1)
            y = self.random.randrange(1, self.grid.height-1)

            pos = (x, y)
            new_human = Pedestrian(i, self, pos, self.exponent, self.directions)

            self.schedule.add(new_human)
            self.grid.place_agent(new_human, pos)

        self.data_collector=DataCollector()

        self.running=True
        self.data_collector.collect(self)
Beispiel #3
0
 def __init__(self, screen_size, earth, events):
     self.screen_size = screen_size
     self.earth_origin = earth.origin
     self.earth_radius = earth.earth_radius
     self.weapons = []
     # Gun parts
     self.gun_cooldown = Cooldown(GameData.WEAPON_GUN_COOLDOWN)
     self.multigun_cooldown = Cooldown(GameData.WEAPON_MULTIGUN_COOLDOWN)
     self.gun_factory = GunFactory(Directions(1.0))
     self.missile_cooldown = Cooldown(GameData.WEAPON_MISSILE_COOLDOWN)
     self.missile_factory = MissileFactory(Directions(1.0))
     self.multimissile_cooldown = Cooldown(
         GameData.WEAPON_MULTIMISSILE_COOLDOWN)
     self.multimissile_factory = MultiMissileFactory(Directions(1.0))
     #Events
     self.events = events
     self.watch_game_events()
    def __init__(self, unique_id, model, pos, exp, directions):
        self.unique_id = unique_id
        self.model = model
        self.pos = pos
        self.traversable = True
        self.trip_lengths = powerlaw.Power_Law(
            xmin=7, parameters=[exp])  #1.5-2.0 #xmin 17?
        self.direction_range = 3
        self.directions = Directions(self.direction_range)

        self.current_direction = 0
        self.remaining_steps = 0

        self.start = None
        self.end_point = None
Beispiel #5
0
    def __init__(self, unique_id, model, pos, exp, x_min, seed=None):
        self.unique_id = unique_id
        self.model = model
        self.pos = pos

        self.area_traversed = np.zeros((model.width, model.height))
        self.traversable = True
        self.trip_lengths = powerlaw.Power_Law(
            xmin=x_min, parameters=[exp])  #1.5-2.0 #xmin 17?
        self.direction_range = 3
        self.directions = Directions(self.direction_range)
        self.trip_lengths_covered = []
        self.steps_covered = []

        self.area_traversed[self.pos[0], self.pos[1]] = 1
        self.on_trip = False
        self.current_direction = 0
        self.remaining_steps = 0
Beispiel #6
0
    def solve(self, seq_a, seq_b):

        score_mat = self._get_score_matrix((len(seq_a) + 1, len(seq_b) + 1))

        directions = Directions(score_mat.shape)

        for i in range(1, score_mat.shape[0]):
            for j in range(1, score_mat.shape[1]):
                from_up = score_mat[i - 1][j] + self.gap_penalty
                from_left = score_mat[i][j - 1] + self.gap_penalty
                if seq_a[i - 1] == seq_b[j - 1]:
                    from_diag = score_mat[i - 1][j - 1] + self.same
                else:
                    from_diag = score_mat[i - 1][j - 1] + self.diff

                best_score = max(from_up, from_left, from_diag)
                score_mat[i][j] = best_score
                is_left = from_left == best_score
                is_up = from_up == best_score
                is_diag = from_diag == best_score
                directions.set_directions(i, j, is_left, is_up, is_diag)

        return score_mat, directions, self._get_final_score_from_score_mat(
            score_mat)
Beispiel #7
0
 def __init__(self, board):
     '''object creation'''
     self.directions = Directions()
     self.direction = self.directions.get_random_direction()
     self.board = board
     self.body = [(self.board.rows // 2, self.board.cols // 2)]
Beispiel #8
0
from directions import Directions

if __name__ == '__main__':

    # Calculate values from input
    results = Directions('input.txt')
    at_least_one_present = str(results.houses_at_least_one_present)

    # Print out results
    print "The amount of houses that received at least one present: " + at_least_one_present