DEV Community

Rajni Devi
Rajni Devi

Posted on

🧠 The Simplest "Decision": Is AI Always Rational?

Hello everyone! I'm Rajni, an AI Developer focused on the beautiful and often confusing space where logic meets human nature.

For my first post, I wanted to share a tiny piece of Python that highlights a huge philosophical debate in AI: We often program models to be "rational," but in the real world, human decisions are rarely optimal.

I wrote this super simple function that forces a sub-optimal choice. It's a fun thought experiment: What happens when the model intentionally avoids the perfect answer?

# The Sub-Optimal Decision Maker
def choose_suboptimal(options, ideal_choice):
    """
    Selects the second-best option from a list, demonstrating a 'flawed' human-like choice.

    options: A dictionary mapping choices to their 'value' (e.g., probability, score).
    ideal_choice: The key corresponding to the highest value option.
    """

    # 1. Get all options except the absolute best one
    non_ideal_options = {k: v for k, v in options.items() if k != ideal_choice}

    if not non_ideal_options:
        return ideal_choice  # Default to ideal if no other options exist

    # 2. Sort the remaining options by value (descending)
    sorted_suboptimal = sorted(non_ideal_options.items(), key=lambda item: item[1], reverse=True)

    # 3. Choose the top one (which is the second-best overall)
    second_best = sorted_suboptimal[0][0]

    return second_best

# Example Data: Scores for different investment strategies
investment_scores = {
    "Strategy A": 0.95,  # Ideal
    "Strategy B": 0.88,  # Second Best
    "Strategy C": 0.75
}

best_strategy = "Strategy A"
choice = choose_suboptimal(investment_scores, best_strategy)

print(f"Ideal Choice: {best_strategy} (Score: {investment_scores[best_strategy]})")
print(f"The 'Human' Choice: {choice} (Score: {investment_scores[choice]})")

# Output: The 'Human' Choice: Strategy B
Enter fullscreen mode Exit fullscreen mode

**Question for the Dev Community: **When have you had to program an AI system to tolerate imperfect or non-deterministic decisions to better reflect real-world user behavior? I’d love to hear your use cases!

Top comments (0)