Loading
I was asking 4o to review my code and I was surprised to see that it couldn’t reason correctly about basic coding logic: whether a simple conditional matched the user’s intentions. 3o-mini-high did just fine and even identified a better way to write it using De Morgan’s Law.
Here is my prompt:
I want to make sure the the user either completes 2 premium games or 3 ad games before being asked for a review, does this code logic accomplish that? It’s confusing with the AND and the negation of less or greater:
// if the player hasn't completed 2 premium games and hasn't completed 3 ad games, don't ask for review if (PlayerPrefs.GetInt(PremiumGamesCompletedKey, 0) < 2 && PlayerPrefs.GetInt(AdGamesCompletedKey, 0) < 3) { Debug.Log("r1 Not enough games completed. Not asking for review."); return; }
3o-mini-high Answer (I’ll give this first for clarity):
The logic is correct. It ensures that if neither condition is met (i.e., the player has completed fewer than 2 premium games and fewer than 3 ad games), then the review prompt will not appear.
In other words, by using:
if (PlayerPrefs.GetInt(PremiumGamesCompletedKey, 0) < 2 && PlayerPrefs.GetInt(AdGamesCompletedKey, 0) < 3) { Debug.Log("r1 Not enough games completed. Not asking for review."); return; }
you’re effectively saying: “Only ask for a review if the player has completed at least 2 premium games or at least 3 ad games.” This is equivalent to checking if not (premium games completed is at least 2 or ad games completed is at least 3).
For clarity, you might consider rewriting it using De Morgan’s Law:
Both versions accomplish the same thing.
if (!(PlayerPrefs.GetInt(PremiumGamesCompletedKey, 0) >= 2 || PlayerPrefs.GetInt(AdGamesCompletedKey, 0) >= 3)) { Debug.Log("r1 Not enough games completed. Not asking for review."); return; }
Here is the 4o response:
Your logic is actually incorrect because the condition will always return early if either condition is true. The issue is with the AND (&&
) operator. Let’s break it down:
if (PlayerPrefs.GetInt(PremiumGamesCompletedKey, 0) < 2 && PlayerPrefs.GetInt(AdGamesCompletedKey, 0) < 3) { Debug.Log("r1 Not enough games completed. Not asking for review."); return; }
if
check fails, and the review request proceeds.You should use OR (||
) instead of AND (&&
), so that the check prevents the review request if either condition is still unmet:
if (PlayerPrefs.GetInt(PremiumGamesCompletedKey, 0) < 2 || PlayerPrefs.GetInt(AdGamesCompletedKey, 0) < 3) { Debug.Log("r1 Not enough games completed. Not asking for review."); return; }
This ensures that at least 2 premium games OR at least 3 ad games must be completed before the user is asked for a review.
submitted by /u/Mr-Canine-Whiskers
[link] [comments]