Exemple #1
0
def is_possible_move(board: Board, current: Point, new: Point):
    x = current.get_x()
    y = current.get_y()
    if board.is_barrier_at(x, y):
        return False
    nx = new.get_x()
    ny = new.get_y()
    if (abs(nx - x) + abs(ny - y)) > 1:
        return False

    if board.is_barrier_at(nx, ny):
        return False
    if (ny - y == -1) and (not board.has_ladder_at(x, y)):
        return False

    yd = y + 1
    if (
            (ny - y != 1) and
            (not board.is_barrier_at(x, yd)) and
            (not board.has_ladder_at(x, yd)) and
            (not board.has_ladder_at(x, y)) and
            (not board.has_pipe_at(x, y))
    ):
        return False
    return True
Exemple #2
0
def turn(gcb: Board):
    if gcb.has_ladder_at(gcb.get_my_position().get_x(), gcb.get_my_position().get_y()):
        action_id = random.randint(0, len(LoderunnerAction)-2)
    else:
        action_id = random.randint(0, len(LoderunnerAction) - 7)
    return list(LoderunnerAction)[action_id]