GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (98)

chess/movement.py (1 issue)

1
# pylint: disable=W0613
2
# allow unused variables so all movement functions can have same parameter definition
3 1
import operator
4
5
6 1
def get_all_potential_end_locations(start, directions, board):
7 1
    ends = []
8 1
    for direction in directions:
9 1
        new_start = start
10 1
        location = tuple(map(operator.add, new_start, direction))
11 1
        while location in board:
12 1
            ends.append(location)
13 1
            new_start = location
14 1
            location = tuple(map(operator.add, new_start, direction))
15 1
    return ends
16
17
18 1
def distance_of_one(board, start, directions, potential_end_locations, player_direction):
19 1
    return [x for x in get_one_move_away(start, directions) if x in potential_end_locations]
20
21
22 1
def get_one_move_away(start, directions):
23 1
    ret_val = [tuple(map(operator.add, move, start)) for move in directions]
24 1
    return ret_val
25
26
27 1
def cant_jump_pieces(board, start, directions, potential_end_locations, player_directionv):
28 1
    end_locations = potential_end_locations
29 1
    for location in potential_end_locations:
30
        # get a direction from start
31
        # remove all locations beyond location
32 1
        direction = tuple(map(operator.sub, location, start))
33 1
        dividor = max(map(abs, direction))
34 1
        direction = tuple(map(operator.floordiv, direction, (dividor, dividor)))
35 1
        location_to_remove = start
36 1
        found_piece = False
37 1
        print("start: {}".format(start))
38 1
        print("direction: {}".format(direction))
39
        print("location: {}".format(location))
40 1
        while True:
41 1
            location_to_remove = tuple(map(operator.add, location_to_remove, direction))
42
            if not found_piece and board[location_to_remove]:
43
                found_piece = True
44 1
                print("{} has a piece".format(location_to_remove))
45 1
            elif location_to_remove in end_locations and found_piece:
46 1
                print("removing {} from board".format(location_to_remove))
47 1
                end_locations.remove(location_to_remove)
48 1
            elif location_to_remove not in board:
49 1
                # import pdb
50
                # pdb.set_trace()
51 1
                print("{} not in board".format(location_to_remove))
52 1
                break
53
            else:
54
                print("floating somehwere {}".format(location_to_remove))
55 1
                print("had found piece: {}".format(found_piece))
56 1
                print("in potential_end_locations: {}".format(location_to_remove in potential_end_locations))
57
                print("in else: {}".format(potential_end_locations))
58
    return end_locations
59 1
60 1
61 1
def doesnt_land_on_own_piece(board, start, directions, potential_end_locations, player_direction):
62 1
    ends = []
63 1
    for end in potential_end_locations:
64 1
        if board[end]:
65
            if board[start].color != board[end].color:
66
                ends.append(end)
67 1
        else:
68 1
            ends.append(end)
69
    return ends
70
71 1
72 1
def doesnt_land_on_piece(board, start, directions, potential_end_locations, player_direction):
73 1
    return [end for end in potential_end_locations if not board[end]]
74 1
75 1
76
def can_end_on_enemy(board, start, directions, potential_end_locations, player_direction):
77
    ends = []
78 1
    for end in potential_end_locations:
79 1
        if board[end] is not None and board[end].color != board[start].color:
80 1
            ends.append(end)
81 1
    return ends
82 1
83 1
84 1
def directional(board, start, directions, potential_end_locations, player_direction):
85 1
    return [end for end in potential_end_locations if is_directional(start, end, player_direction)]
86
87
    new_list = []
0 ignored issues
show
This code does not seem to be reachable.
Loading history...
88 1
    for end in potential_end_locations:
89 1
        if is_directional(start, end, player_direction):
90
            new_list.append(end)
91
    return new_list
92
93
def is_directional(start, end, direction):
94
    direct = True
95
    direct = direct and _directional_helper(start[0], end[0], direction[0])
96
    direct = direct and _directional_helper(start[1], end[1], direction[1])
97
    return direct
98
99
100
def _directional_helper(start, end, direct):
101
    if direct > 0:
102
        if end < start:
103
            return False
104
    elif direct < 0:
105
        if end > start:
106
            return False
107
    return True
108
109
110
def first_move(board, start, directions, potential_end_locations, player_direction):
111
    return potential_end_locations if board[start].move_count == 0 else []
112