Exemplo n.º 1
0
    def __init__(self, id, points, color=None, full=False, alpha=1, p=None):
        self.n = []
        self.id = id
        self.points = points
        self.color = color
        if (p != None):
            realid = id % p
        else:
            realid = id
        if (full):
            self.pid = make_shape(points, color, 1)
        elif (color == None):
            # self.pid = make_shape(points, (int((id - realid) / len(order))) ,0.7)
            self.pid = make_shape(points, (0, 0, 0), 0)
        else:
            self.pid = make_shape(points, color, 0)
        # print(points)

        #number(realid, sum(points, Point(0, 0)) / len(points))
        center = centerpoint(points)
        angle = 180.0 * atan2(points[1].y - points[0].y,
                              points[1].x - points[0].x) / pi
        Draw.text_rotated(str(realid),
                          center[0],
                          center[1], (0, 0, 0),
                          textsize,
                          angle,
                          underline=str(realid) in "0,6,8,9")
Exemplo n.º 2
0
    def add(self, screen, block_size, line_width, tile_list, color, start_tile, end_tile, last):
        for tile in tile_list:
            # Ignore the start tile as we don't want to treat it like a normal one
            if tile.x == start_tile.x and tile.y == start_tile.y:
                continue
            # If the end tile was added to the queue don't change its color and other values
            if tile.x == end_tile.x and tile.y == end_tile.y:
                tile.last = last
                self.queue.put(tile)
                continue

            # Don't add blocked tiles as they cannot be traversed
            if tile.blocked:
                continue

            if tile not in self.duplicate_checker:
                # Changing the last value of the tile
                tile.last = last

                # Changing the tile's color
                tile.color = color

                # Updating the f cost of our tile so it can be ordered accordingly in the queue
                tile.update_cost(start_tile, end_tile)

                # Redrawing our added tiles
                DrawingFunctions.draw_tile(screen, block_size, line_width, tile)

                self.queue.put(tile)
                self.duplicate_checker.add(tile)
def draw_blocked_tiles():
    finished = False  # Loop control variable
    mouse_down = False  # Variable for mouse hold
    right_mouse_down = False

    while not finished:

        for event in pygame.event.get():
            if event == pygame.QUIT:  # On quit button clicked
                finished = True
                continue

            if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT_CLICK:  # On left mouse click
                mouse_down = True

            if event.type == pygame.MOUSEBUTTONDOWN and event.button == RIGHT_CLICK:
                right_mouse_down = True

            if event.type == pygame.MOUSEBUTTONUP and event.button == LEFT_CLICK:
                mouse_down = False

            if event.type == pygame.MOUSEBUTTONUP and event.button == RIGHT_CLICK:
                right_mouse_down = False

            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:  # If enter button is clicked
                finished = True

            if mouse_down or right_mouse_down:
                # Getting the click position and adjusting it to our grid
                position = pygame.mouse.get_pos()
                x, y = position
                x, y = x // BLOCK_SIZE, y // BLOCK_SIZE

                # Getting the clicked tile and changing it to be blocked and have the appropriate color
                tile = grid.get_tile(x, y)

                # Making sure the end and start tiles aren't blocked
                if tile.x == start_tile.x and tile.y == start_tile.y:
                    continue
                if tile.x == end_tile.x and tile.y == end_tile.y:
                    continue

                if mouse_down:
                    tile.blocked = True
                    tile.color = BLACK

                    # Drawing the tile
                    DrawingFunctions.draw_tile(screen, BLOCK_SIZE, LINE_WIDTH,
                                               tile)

                else:
                    tile.blocked = False
                    tile.color = WHITE

                    DrawingFunctions.draw_tile(screen, BLOCK_SIZE, LINE_WIDTH,
                                               tile)

            pygame.display.update()
def extend_tile(p1, p2, currentcase, oldcase, tile):
    # Copy of visualize
    visitedcases = [currentcase % len(tile)]
    tilepoints = list()
    to_visit = [(p1, p2, currentcase, oldcase)]
    while to_visit:
        p1, p2, currentcase, oldcase = to_visit.pop()
        realcurrent = currentcase % len(tile)
        # visitedcases.append(realcurrent) #too late! if two cases go to the same case that doesn't get explored until after
        points = get_face_points(p1, p2, len(tile[realcurrent]))
        if DEBUG1: Draw.polygon_shape(points, (255, 0, 0), alpha=0.1, outline=1)
        if DEBUG4: print("Extend", currentcase)
        if DEBUG4: print(visitedcases)
        if DEBUG1: Draw.text_center(str(realcurrent), *centerpoint(points), (0, 0, 0), 12)
        if DEBUG1: Draw.refresh()
        # sleep(0.01)
        tilepoints.append(points)
        currentborder = tile[realcurrent]  # print(currentborder, 'of shape', realcurrent, ', coming from', oldcase)
        base, match = find_matching(oldcase, currentcase, tile)
        # if(DEBUG1):print(match)
        shift = currentborder.index(match)  # index = current.index(-oldcase + 2 * (oldcase % len(order)))
        # if(DEBUG1):print("Aligned on %d index %d"%(oldcase,shift))
        # print(index)
        currentborder = currentborder[shift:] + currentborder[:shift + 1]
        for index, nextcase in enumerate(currentborder):
            p1 = points[index % len(points)]
            p2 = points[(index + 1) % len(points)]
            if (nextcase not in visitedcases) and (nextcase % len(tile) == nextcase):
                to_visit.append([p2, p1, nextcase, currentcase])
                visitedcases.append(nextcase)
                # if(DEBUG1):print("De %d, index %d next %d"%(realcurrent, index,nextcase))
        if DEBUG1: Draw.wait_for_input()
    return tilepoints
Exemplo n.º 5
0
def on_left_click(pos):
    global x_turn, count
    x = pos[0] // BLOCK_SIZE
    y = pos[1] // BLOCK_SIZE

    if board[y][x] != board.EMPTY_CELL:    # If cell already clicked on do nothing
        return

    count += 1      # Incrementing the turn counter

    if x_turn:
        board[y][x] = X_SIGN
        DrawingFunctions.draw_image(screen, 'media/cross.png', (x * BLOCK_SIZE, y * BLOCK_SIZE))
    else:
        board[y][x] = O_SIGN
        DrawingFunctions.draw_image(screen, 'media/circle.png', (x * BLOCK_SIZE, y * BLOCK_SIZE))
def explore_rotations(tile, poly,polyname):
    if DEBUG1 or DEBUG2 or DEBUG3 or 1: Draw.initialise_drawing(WIDTH, HEIGHT)
    if DEBUG1 or DEBUG2 or DEBUG3: Draw.empty_shapes()
    # Draw.polygon_shape((Point(0,0),Point(150,0),Point(150,150)), (255,0,0), alpha=1, outline=1)
    startcase = 0
    startface = 0
    face_ori = 0
    case_ori = 0
    # extend_tile(Point(300,300),Point(300,310),0,tile[0][0],tile)
    neighbour_coord = create_neighbour_coordinates(tile)
    dim = len(tuple(neighbour_coord.values())[0][0])
    if DEBUG2: print("-" * 20)
    if DEBUG2: print("Coordinate infos:", neighbour_coord)
    if DEBUG2: print("Number of axes:", dim)
    for coord in sorted(neighbour_coord):
        if DEBUG2:
            print(coord, ":", neighbour_coord[coord])
    # print("Dimensions:",dim)
    # print(flush=True)
    positions = dict()
    symmetry_axis = list()
    for case in tile:
        for face in poly:
            for orientation in range(len(poly[face])):
                positions[(case, face, orientation)] = list()
    if DEBUG3: print("Possible combinations: %d" % len(positions))

    pos = (P1, P2, 0, 0, 0, [0 for x in range(dim)], 1)
    to_explore = [pos]
    while to_explore:
        p1, p2, case, face, orientation, tilecoord, tilecoordsign = to_explore.pop()
        # if(case%len(tile)!=case):
        #    continue
        # print("exploring",p1,p2,"case",case,"face",face,orientation,tilecoord, tilecoordsign )
        if len(tile[case % len(tile)]) != len(poly[face]):
            continue
        # caseorientation = 0
        # orientation is tileorientation
        # print("Known positions for",case%len(tile),face,orientation)
        # print(positions[(case%len(tile),face,orientation)])
        if tilecoord in positions[(case % len(tile), face, orientation)]:
            continue
Exemplo n.º 7
0
def display_win():
    win_surface = DrawingFunctions.get_transparent_surface(GAME_WIDTH, GAME_HEIGHT, TRANSPARENT_ALPHA, WHITE)

    if x_turn:
        won_sign = X_SIGN
    else:
        won_sign = O_SIGN
    text = create_text(f'Player {won_sign.upper()} Won!', DEFAULT_TEXT_FONT, DEFAULT_TEXT_SIZE, BLACK)

    win_surface.blit(text, (GAME_WIDTH // 2 - text.get_width() // 2, GAME_HEIGHT // 2 - text.get_height() // 2))
    screen.blit(win_surface, (0, 0))
def visualise(p1, p2, newshape, oldshape, color=0, drawnshapes=None, shapespoly=None, fill=True, ord=None,
              prints=False, refresh = False):
    realshape = newshape % len(order)
    if (drawnshapes == None):
        drawnshapes = list()
    if (prints): print("Visualise---------", newshape, oldshape, "(%s)" % realshape, shape[realshape])
    if (shapespoly == None):
        shapespoly = list()
    points = get_face_points(p1, p2, newshape, False)
    shapespoly.append(RollyPoly(newshape, points, color, fill))
    current = shape[realshape]
    if (prints): print(current, 'of shape', realshape, ', coming from', oldshape)
    try:
        index = current.index(oldshape)
    except:
        # Maybe the -P +P formula is not respected
        index = current.index(-oldshape + 2 * (oldshape % len(order)))
        #print("Exception matching", oldshape % len(order), "+%dP" % (oldshape // len(order)))

    current = current[index:] + current[:index]
    shapespoly[-1].fill(current)
    drawnshapes.append(realshape)
    if(refresh):
        Draw.refresh()
    # sleep(0.1)
    # print("I have",len(points),"points")
    # if(newshape==realshape):
    # print("Next ones:",current)
    for index, p in enumerate(current):
        # print("Looking",p)
        # print(index)
        p1 = points[index % len(points)]
        p2 = points[(index + 1) % len(points)]
        if (p not in drawnshapes) and (p % len(order) == p):
            visualise(p2, p1, p, newshape, color, drawnshapes, shapespoly, fill)
        """else:
			if(p in drawnshapes):
				print("P in drawn:",p,drawnshapes,p not in drawnshapes)
			if(p%len(order)!=p):
				print("P not to draw",p,p%len(order))"""
    return shapespoly
def number(id, point):
    # graph.create_text((point.x, point.y), text=str(id))
    Draw.text_center(str(id), point.x, point.y, (0, 0, 0), textsize)
Exemplo n.º 10
0
def display_draw():
    draw_surface = DrawingFunctions.get_transparent_surface(GAME_WIDTH, GAME_HEIGHT, TRANSPARENT_ALPHA, WHITE)
    text = create_text('Draw', DEFAULT_TEXT_FONT, DEFAULT_TEXT_SIZE, BLACK)

    draw_surface.blit(text, (GAME_WIDTH // 2 - text.get_width() // 2, GAME_HEIGHT // 2 - text.get_height() // 2))
    screen.blit(draw_surface, (0, 0))
def get_neighbours_positions(tile, p1=P1, p2=P2, startcase=0, recurse=0):
    neighbours_coords = dict()
    if recurse:
        neighbours_neighbours = dict()
        if DEBUG4:
            nn_debug = dict()
    explored = list()
    ####PART 1 : explore and list all neighbouring tiles
    to_explore = [list((p1, p2, startcase))]
    while to_explore:
        initial_p1, initial_p2, case = to_explore.pop()  # the initial shape from which the exploration starts
        if recurse:
            c = centeroftilestarting(initial_p1, initial_p2, tile[case % len(tile)][0], case, tile, 1)
            if DEBUG4:
                print("Center received", c)
                Draw.text_center("_0_", *c, (128, 0, 0), 30)
        initial_points = get_face_points(initial_p1, initial_p2, len(tile[case]))
        if DEBUG1: Draw.polygon_shape(initial_points, (0, 255 * recurse, 0), alpha=.5, outline=1)
        initial_points = initial_points + initial_points
        if DEBUG1: Draw.text_center(str(case), *centerpoint(initial_points), (0, 0, 255), 12)
        if DEBUG1: Draw.refresh()
        explored.append(case)
        if DEBUG1: Draw.wait_for_input()
        for index, next in enumerate(tile[case]):
            branch_p1 = initial_points[index]
            branch_p2 = initial_points[index + 1]
            branch_points = 2 * get_face_points(branch_p2, branch_p1, len(
                tile[next % len(tile)]))  # the direction of the segment has to be reversed
            # branch_points triangle starts at [case] as its origin
            # but next triangle loop considers starts at 0 (forgets previous)
            # rotate the triangle so that the origin side is 0
            if next % len(tile) == next and next != case:
                side_offset = len(tile[next]) - tile[next].index(case)
                next_p1, next_p2 = branch_points[side_offset:side_offset + 2]
                # inside the net (excluding self-ref which are outside)
                if next not in explored:
                    # Branch out inside
                    to_explore.append([next_p1, next_p2, next])
            else:
                # outside the net= neighbour data
                branch_p1 = initial_points[index]
                branch_p2 = initial_points[index + 1]
                # branch_points = 2*get_face_points(branch_p2, branch_p1, len(tile[case])) #the direction of the segment has to be reversed
                # side_offset = len(tile[next%len(tile)])-index#len(tile[next%len(tile)])-find_matching_offset(case,next,tile)
                # next_p1, next_p2 = branch_points[side_offset:side_offset+2]
                if DEBUG1: print("Going outside: %d to %d index %d" % (case, next % len(tile), index))
                neighbour = centeroftilestarting(branch_p2, branch_p1, case, next,
                                                 tile)  # this takes prev tile so no shift
                neighbours_coords.setdefault(neighbour, [])
                neighbours_coords[neighbour].append((case, next))

                if recurse:
                    # current, sym = find_matching(case,next,tile)
                    side_offset = len(tile[next % len(tile)]) - find_matching_offset(case, next, tile)
                    next_p1, next_p2 = branch_points[side_offset:side_offset + 2]
                    nn = get_neighbours_positions(tile, next_p1, next_p2, next % len(tile), recurse=False)
                    for n in nn:
                        nn[n].sort()
                    if DEBUG4:
                        debug_data = (next_p1, next_p2, next % len(tile))
                        if neighbour in neighbours_neighbours:
                            if neighbours_neighbours[neighbour] != nn:
                                print("Not matching when reading neighbour", neighbour,
                                      "'s neighbours from two different sides:\nOriginal:")
                                print(nn_debug[neighbour])
                                pp.pprint(neighbours_neighbours[neighbour])
                                print("New: (coming from %d to %d)" % (case, next))
                                print(debug_data)
                                pp.pprint(nn)
                        nn_debug.setdefault(neighbour, debug_data)
                    neighbours_neighbours.setdefault(neighbour, nn)
def make_shape(points, color, filling=0):
    color = (180, 180, 180)
    Draw.polygon_shape(points, color, filling)
    Draw.polygon_shape(points, (0, 0, 0), 0, outline=2)
    return points
 p1, p2, case, face, orientation, tilecoord, tilecoordsign = to_explore.pop()
 # if(case%len(tile)!=case):
 #    continue
 # print("exploring",p1,p2,"case",case,"face",face,orientation,tilecoord, tilecoordsign )
 if len(tile[case % len(tile)]) != len(poly[face]):
     continue
 # caseorientation = 0
 # orientation is tileorientation
 # print("Known positions for",case%len(tile),face,orientation)
 # print(positions[(case%len(tile),face,orientation)])
 if tilecoord in positions[(case % len(tile), face, orientation)]:
     continue
 # if(not is_known((case,face,orientation),tilecoord,positions,symmetry_axis)):
 startpoints = get_face_points(p1, p2, len(poly[face]))
 color = Draw.colors[sum([abs(x * (n + 1)) for n, x in enumerate(tilecoord)]) % len(Draw.colors)]
 Draw.polygon_shape(startpoints, color, 0.75, 1)
 # Draw.text_center("%d/%d+%d"%(face,case%len(tile),(case-(case%len(tile)))//len(tile)),*centerpoint(startpoints),(255,255,255),int(ext/2))
 Draw.text_center(str(tilecoord) + str(tilecoordsign), *centerpoint(startpoints), (255, 255, 255), int(ext / 4))
 # Draw.text_center("%d(%d)"%(case,(case-(case%len(tile)))//len(tile)),*centerpoint(startpoints),(255,255,255),int(ext/2))
 Draw.refresh()
 # Draw.wait_for_input()
 if len(positions[(case % len(tile), face, orientation)]) == 0:
     # add_new_symmetry((case,face,orientation),tilecoord,positions,symmetry_axis)
     # Draw.wait_for_input()
     newcases = tile[case % len(tile)]
     newfaces = poly[face][orientation:] + poly[face][:orientation]
     if DEBUG3: print(case % len(tile), newcases)
     if DEBUG3: print(face % len(poly), newfaces)
     for i in range(len(newcases)):
         newface = newfaces[i]
         newcase = newcases[i]
Exemplo n.º 14
0
def make_shape(points, color, filling=0):
    Draw.polygon_shape(points, color, filling)
    Draw.polygon_shape(points, (0, 0, 0), 0, outline=1)
    return points
Exemplo n.º 15
0
def make_cursor(points, color=5, filling=0.1):
    Draw.polygon_cursor(points, color, filling)
    Draw.polygon_cursor(points, color, 0, outline=1)
    return points
Exemplo n.º 16
0
def visualise(polydict,
              p1,
              p2,
              newshape,
              oldshape,
              color=(255, 0, 0),
              drawnshapes=None,
              shapespoly=None,
              fill=True,
              prints=False,
              surf=None,
              screen=None,
              shapes=None):
    global s
    try:
        print(s)
    except:
        if (surf != None):
            Draw.set_s(surf, screen, shapes)
    # Copy of extend, but fills the whole space
    realshape = newshape % len(polydict)
    if (drawnshapes == None):
        drawnshapes = list()
    if (prints):
        print("Visualise---------", newshape, oldshape, "(%s)" % realshape,
              polydict[realshape])
    if (shapespoly == None):
        shapespoly = list()
    points = get_face_points(polydict, p1, p2, newshape, noisy=False)
    shapespoly.append(RollyPoly(newshape, points, color, fill,
                                p=len(polydict)))
    current = polydict[realshape]
    if (prints):
        print(current, 'of shape', realshape, ', coming from', oldshape)
    try:
        #match with -k
        index = current.index(oldshape)
    except:
        #match with --k
        index = current.index(-oldshape + 2 * (oldshape % len(polydict)))
        if (prints):
            print("Matching", "%i[%i]" % (newshape, oldshape), "=",
                  oldshape % len(polydict),
                  "+%d(%i)" % (oldshape // len(polydict), len(polydict)))

    current = current[index:] + current[:index]
    shapespoly[-1].fill(current)
    drawnshapes.append(realshape)

    #Draw.refresh()
    # sleep(0.1)
    # print("I have",len(points),"points")
    # if(newshape==realshape):
    # print("Next ones:",current)
    for index, p in enumerate(current):
        # print("Looking",p)
        # print(index)
        p1 = points[index % len(points)]
        p2 = points[(index + 1) % len(points)]
        if (p not in drawnshapes) and (p % len(polydict) == p):
            visualise(polydict,
                      p2,
                      p1,
                      p,
                      newshape,
                      color,
                      drawnshapes,
                      shapespoly,
                      fill,
                      prints=prints)
        """else:
			if(p in drawnshapes):
				print("P in drawn:",p,drawnshapes,p not in drawnshapes)
			if(p%len(order)!=p):
				print("P not to draw",p,p%len(order))"""
    return shapespoly
Exemplo n.º 17
0
        pygame.display.update()


# Initializing the game
os.environ['SDL_VIDEO_WINDOW_POS'] = f'{WINDOW_STARTING_X_POS},{WINDOW_STARTING_Y_POS}'  # Setting the initial starting position of the window in the middle of the screen
pygame.init()

# Creating the game and setting it up
screen = pygame.display.set_mode(DIMENSIONS)
pygame.display.set_caption('Tic Tac Toe')
clock = pygame.time.Clock()     # FPS clock

# Displaying icon
icon_surface = pygame.image.load('media/icon.ico')
pygame.display.set_icon(icon_surface)


# Drawing and creating the board
board = Board()
DrawingFunctions.draw_board(screen, WHITE, SCREEN_WIDTH, SCREEN_HEIGHT, BLOCK_SIZE, 3)


# Setting up the global game variables and loop
running = True
x_turn = True
game_over = False
count = 0

main()
Exemplo n.º 18
0
 def _display_time(self):
     text = DrawingFunctions.create_text(str(self.seconds), 'comic sans',
                                         48, (250, 250, 250))
     self.screen.blit(text, (950, 950))
Exemplo n.º 19
0
def display_shortest_path(last_tile):
    while last_tile.last is not None:
        last_tile.color = BLUE
        DrawingFunctions.draw_tile(screen, BLOCK_SIZE, LINE_WIDTH, last_tile)
        pygame.display.update()
        last_tile = last_tile.last
Exemplo n.º 20
0
def main():

    # Drawing our screen
    DrawingFunctions.draw_grid(screen, WHITE, BLACK, SCREEN_WIDTH,
                               SCREEN_HEIGHT, BLOCK_SIZE, LINE_WIDTH)
    pygame.display.update()

    # Getting coordinates for the start and end tiles
    tkinter_input()

    # If the start tile equals the end tile just quit
    if start_tile.x == end_tile.x and start_tile.y == end_tile.y:
        return

    # Drawing start and end tiles
    DrawingFunctions.draw_first_tiles(screen, BLOCK_SIZE, LINE_WIDTH,
                                      start_tile, end_tile, BLUE)

    # Drawing our blocked tiles
    draw_blocked_tiles()

    # Setting up regular variables
    tile_queue = TileQueue()

    # Initializing our queue
    start_tile_neighbours = grid.get_neighbour_tiles(start_tile.x,
                                                     start_tile.y)
    tile_queue.add(screen, BLOCK_SIZE, LINE_WIDTH, start_tile_neighbours,
                   GREEN, start_tile, end_tile, start_tile)

    # Setting up loop variables
    running = True

    while running:

        # Pulling out the best tile
        best_tile = tile_queue.get()

        # If the algorithm reached the end tile break
        if best_tile.x == end_tile.x and best_tile.y == end_tile.y:
            display_shortest_path(best_tile)
            time.sleep(5)
            break

        best_tile.color = RED
        DrawingFunctions.draw_tile(screen, BLOCK_SIZE, LINE_WIDTH, best_tile)

        # Adding the best tile's neighbours to the queue
        neighbours = grid.get_neighbour_tiles(best_tile.x, best_tile.y)
        tile_queue.add(screen, BLOCK_SIZE, LINE_WIDTH, neighbours, GREEN,
                       start_tile, end_tile, best_tile)

        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        if tile_queue.empty():
            running = False

        pygame.display.update()
Exemplo n.º 21
0
    def save_stats(self):
        self.text_chrome = os.path.dirname(
            os.path.abspath(__file__)) + '/chromedriver'
        bAll = 0
        bTeam = 0
        bProj = False

        iBenIn = 2
        iEndIn = -3

        if iEndIn != 0:
            season = str(
                unicodedata.normalize('NFKD',
                                      self.text_season.get("1.0", END)).encode(
                                          'ascii',
                                          'ignore')).replace('\n',
                                                             '')[iBenIn:iEndIn]
            division = str(
                unicodedata.normalize('NFKD', self.text_division.get(
                    "1.0",
                    END)).encode('ascii',
                                 'ignore')).replace('\n',
                                                    '').upper()[iBenIn:iEndIn]
        else:
            season = str(
                unicodedata.normalize('NFKD', self.text_season.get(
                    "1.0", END)).encode('ascii', 'ignore')).replace('\n', '')
            division = str(
                unicodedata.normalize('NFKD', self.text_division.get(
                    "1.0", END)).encode('ascii',
                                        'ignore')).replace('\n', '').upper()

        bUnaFase = False
        divSplit = division.split(',')[0]
        try:
            groupSplit = division.split(',')[1]
        except:
            pass
        if division == 'ORO':
            groupFeb = '1'
        elif division == 'DIA' or division == 'LF':
            groupFeb = '4'
        elif divSplit == 'PLATA':
            bUnaFase = False
            if len(division.split(',')) == 3:
                if int(season) > 2017:
                    if division.split(',')[2] == 'A1':
                        groupFeb = '2'
                    else:
                        groupFeb = '18'
                else:
                    groupFeb = '2'
            else:
                bUnaFase = True
                if int(season) > 2017:
                    if division.split(',')[1] == 'ESTE':
                        groupFeb = '2'
                    else:
                        groupFeb = '18'
                else:
                    groupFeb = '2'
        elif divSplit == 'EBA':
            if groupSplit[0] == 'A':
                groupFeb = '3'
            elif groupSplit[0] == 'B':
                groupFeb = '5'
            elif groupSplit[0] == 'C':
                if int(season) > 2018:
                    if groupSplit[1] == 'A':
                        groupFeb = '6'
                    elif groupSplit[1] == 'B':
                        groupFeb = '46'
                else:
                    groupFeb = '6'
            elif groupSplit[0] == 'D':
                groupFeb = '7'
            elif groupSplit[0] == 'E':
                groupFeb = '8'
        elif divSplit == 'LF2':
            groupFeb = '9'

        sLang = 'Castellano'

        html_doc = "http://competiciones.feb.es/Estadisticas/Calendario.aspx?g=" + groupFeb + "&t=" + season + "&"
        targetTeam = 'Liga'
        sPlayers = ''
        sMinGames = ''

        if iEndIn != 0:
            jorFirst = int(
                str(
                    unicodedata.normalize(
                        'NFKD', self.text_jFirst.get("1.0", END)).encode(
                            'ascii', 'ignore')).replace('\n',
                                                        '')[iBenIn:iEndIn])
            jorLast = int(
                str(
                    unicodedata.normalize(
                        'NFKD', self.text_jLast.get("1.0", END)).encode(
                            'ascii', 'ignore')).replace('\n',
                                                        '')[iBenIn:iEndIn])
            sDir = str(
                unicodedata.normalize('NFKD',
                                      self.text_folder.get("1.0", END)).encode(
                                          'ascii',
                                          'ignore')).replace('\n',
                                                             '')[iBenIn:iEndIn]
        else:
            jorFirst = int(
                str(
                    unicodedata.normalize(
                        'NFKD', self.text_jFirst.get("1.0", END)).encode(
                            'ascii', 'ignore')).replace('\n', ''))
            jorLast = int(
                str(
                    unicodedata.normalize(
                        'NFKD', self.text_jLast.get("1.0", END)).encode(
                            'ascii', 'ignore')).replace('\n', ''))
            sDir = str(
                unicodedata.normalize('NFKD', self.text_folder.get(
                    "1.0", END)).encode('ascii', 'ignore')).replace('\n', '')

        if division == 'ORO' or division == 'DIA' or division == 'ENDESA':
            fileLoad = sDir + '/' + division + str(season) + 'J' + str(
                jorFirst) + 'J' + str(jorLast) + '.npy'
        elif divSplit == 'PLATA':
            if bUnaFase:
                fileLoad = sDir + '/' + division.replace(',', '-') + str(
                    season) + 'J' + str(jorFirst) + 'J' + str(jorLast) + '.npy'
            else:
                fileLoad = sDir + '/' + division.replace(
                    ',', '-') + str(season) + 'J' + str(jorFirst) + 'J' + str(
                        jorLast * 2) + '.npy'
        else:
            fileLoad = sDir + '/' + division.replace(',', '-') + str(
                season) + 'J' + str(jorFirst) + 'J' + str(jorLast) + '.npy'

        bExisting = os.path.exists(fileLoad)

        if bExisting == False:
            if targetTeam == 'Liga' or targetTeam == 'LIGA':
                if division == 'ORO' or division == 'DIA' or division == 'ENDESA':
                    GetAllLeagueCommon.extractStatisticsAllLeague(
                        html_doc, 'Liga' + division.replace(',', '-'), season,
                        jorFirst, jorLast, division, sDir, self.text_chrome,
                        bTeam, sPlayers, bProj, division, '', sMinGames, sLang,
                        True)
                elif divSplit == 'PLATA':
                    if bUnaFase == False:
                        GetAllLeagueBothPlata.extractStatisticsPlataAll(
                            html_doc, targetTeam, season, jorFirst, jorLast,
                            division.split(',')[1],
                            division.split(',')[2], sDir, self.text_chrome,
                            bTeam, sPlayers, bProj, division, '', sMinGames,
                            sLang, True)
                        reload(GetAllLeagueBothPlata)
                    else:
                        GetAllLeagueCommon.extractStatisticsAllLeague(
                            html_doc, 'Liga' + division.replace(',', '-'),
                            season, jorFirst, jorLast,
                            division.split(',')[1], sDir, self.text_chrome,
                            bTeam, sPlayers, bProj, '', 'Fase1', sMinGames,
                            sLang, True)
                elif divSplit == 'EBA':
                    GetAllLeagueCommon.extractStatisticsAllLeague(
                        html_doc, 'Liga' + division.replace(',', '-'), season,
                        jorFirst, jorLast,
                        division.split(',')[1], sDir, self.text_chrome, bTeam,
                        sPlayers, bProj, division, '', sMinGames, sLang, True)
                elif divSplit == 'LF2':
                    GetAllLeagueCommon.extractStatisticsAllLeague(
                        html_doc, 'Liga' + division.replace(',', '-'), season,
                        jorFirst, jorLast,
                        division.split(',')[1], sDir, self.text_chrome, bTeam,
                        sPlayers, bProj, division, '', sMinGames, sLang, True)
                reload(GetAllLeagueCommon)

        xAxisF = self.xAxis.get()
        yAxisF = self.yAxis.get()

        teamStats = np.load(fileLoad, allow_pickle=True)
        teamStatsAg = np.load(fileLoad[:-4] + 'Against.npy', allow_pickle=True)
        libDraw.draw2Features(teamStats, teamStatsAg, sDir, xAxisF, yAxisF,
                              season, division, jorFirst, jorLast)
        a = 1
            f.close()
            exec(data)

isogonals = all_tilings
print(isogonals)



setrecursionlimit(10 ** 4)
WIDTH = 800
HEIGHT = 800
EDGESIZE = 50
p1 = RollyPoint(300, 300)
p2 = RollyPoint(300 + EDGESIZE, 300)  # 350 300
textsize = int(round((EDGESIZE) / 2))
Draw.initialise_drawing(WIDTH, HEIGHT)
def make_shape(points, color, filling=0):
    color = (180, 180, 180)
    Draw.polygon_shape(points, color, filling)
    Draw.polygon_shape(points, (0, 0, 0), 0, outline=2)
    return points
def make_cursor(points, color=5, filling=0.1):
    Draw.polygon_cursor(points, color, filling)
    Draw.polygon_cursor(points, color, 0, outline=2)
    return points
def number(id, point):
    # graph.create_text((point.x, point.y), text=str(id))
    Draw.text_center(str(id), point.x, point.y, (0, 0, 0), textsize)
def numcenter(id, points):
    number(id, sum(points, RollyPoint(0, 0)) / len(points))
def numbours(id, neighbours, points):