def greedy_action(q, state):
    """
    Computes the greedy action.

    :param q: action-value table.
    :type q: bidimensional numpy array.
    :param state: current state.
    :type state: int.
    :return: greedy action.
    :rtype: int.
    """
    greedy_act = 0
    q_max = q[state][greedy_act]
    for action in range(q.shape[1]):
        val = q[state][action]
        if val > q_max:
            greedy_act = action
            q_max = val

    return greedy_act