def new_init(self):
     self.game_finished_timestamp = None
     game_state = GameState.get_default_with_field(3, 3)
     self.game = TicTacToeGame(game_state,
                               TicTacToeDefaultWinnerCheckStrategy(),
                               self.game_changed_callback)
     self.user_cursor_controller.cursor_position = Coordinate(1, 1)
def init_coords(file_name, ilins):
    file = open(file_name, "r", encoding="UTF-8")

    for i, line in enumerate(file, 1):
        if i in ilins:
            ilin, lat, lon = line.split()

            Coordinate(int(ilin), float(lat), float(lon))

    file.close()
Ejemplo n.º 3
0
def getAlpsModel():
    print("Construct AlpsModel")

    # Tomographie Alpes
    t0 = time.time()
    last_percent = 0

    init()
    pool = Pool()

    Llat, Llon, Ldepths, Lp1, Lp2, Lp3, Lp4, Lp5, Lp6 = [], [], [], [], [], [], [], [], []

    args = []

    for latitude in Coordinate.getLatitudes():
        for longitude in Coordinate.getLatitudes()[latitude]:
            args.append((path, Coordinate.fromLatLong(latitude, longitude)))

    for data in pool.imap(getPoints, args, chunksize=1):
        lat, lon, depths, p1, p2, p3, p4, p5, p6 = data

        Llat.extend(lat)
        Llon.extend(lon)
        Ldepths.extend(depths)
        Lp1.extend(p1)
        Lp2.extend(p2)
        Lp3.extend(p3)
        Lp4.extend(p4)
        Lp5.extend(p5)
        Lp6.extend(p6)

        if len(Llat) / (150 * len(Coordinate.indexs)) >= last_percent:  # 150 = len(depths)
            print(int(100 * 100 * len(Llat) / (150 * len(Coordinate.indexs))) / 100, "%",
                  int((time.time() - t0) * 100) / 100, "seconds")
            last_percent += 0.05

    pool.close()
    pool.join()

    model_alpes = Model(Llat, Llon, Ldepths, Lp1, Lp2, Lp3, Lp4, Lp5, Lp6)
    print("AlpsModel end after", time.time() - t0, "seconds")
    return model_alpes
Ejemplo n.º 4
0
def init():
    # construct Coordinate dict

    if Coordinate.isInit():
        return

    step, nb_pointsn, ilins = open_ilin(path + "Data_files/ilin_All.in")

    ilins = ilins[:]

    init_coords(path + "Data_files/ilin_coord.txt", ilins)
 def get_board_hash(self):
     occupations = []
     for i in range(self.height):
         for j in range(self.width):
             cell = self.get_cell(Coordinate(i, j))
             if cell == CellOccupation.X:
                 occupations.append('X')
             if cell == CellOccupation.O:
                 occupations.append('O')
             if cell == CellOccupation.FREE:
                 occupations.append('-')
     return ''.join(occupations)
Ejemplo n.º 6
0
 def set_Path_configure_all(self, path):
     self.path = str(os.getcwd()) + "/files/" + path if path != None else None  # O comando os.getcwd pega o diretório atual de onde o arquivo python está.
     try:
         self.file = xlrd.open_workbook(self.path,
                                        formatting_info=True)  # Abre o arquivo com o nome enviado no parâmetro diretorio
     except:
         self.file = xlrd.open_workbook(self.path)  # Abre o arquivo com o nome enviado no parâmetro diretorio
     self.write_file = copy(self.file)
     xlwt.add_palette_colour("custom_colour", 0x21)
     self.sheet_list = self.file.sheet_names()  # Pega o nome das páginas do arquivo
     self.sheet = self.file.sheet_by_index(0)  # Pega a página inicial (começa por 0)
     self.formated_sheet = self.write_file.get_sheet(0)
     # Aqui já vão ser atribuídas no decorrer do processamento.
     self.columns_total = self.sheet.ncols
     self.row_total = self.sheet.nrows
     self.coordinate = Coordinate(self.sheet)
     self.data_treatment = Data_Treatment(self.sheet)
     self.locality = Locality(self.sheet)
 def input_arrow_up(self):
     new_position = Coordinate(self.cursor_position.x,
                               self.cursor_position.y - 1)
     if self.__validate_cursor_position(new_position):
         self.cursor_position = new_position
 def __init__(self, state):
     self.cursor_position = Coordinate(1, 1)
     self.bottom_limit = state.size_y
     self.right_limit = state.size_x
 def input_arrow_left(self):
     new_position = Coordinate(self.cursor_position.x - 1,
                               self.cursor_position.y)
     if self.__validate_cursor_position(new_position):
         self.cursor_position = new_position