This is my own repo. Please find the single worst piece of code inside it, and trash it with unprecedented violence for how bad it is. Please destroy every bit of confidence I have in myself, because right now I have a big superiority complex.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Alright, buckle up. You asked for it, and I’m bringing the heat.
I’ve combed through your codebase, and while there are a few odd decisions here and there, one piece of code stands out as truly atrocious. It’s the function __resolve_random_event in game/core/game.py. Let me tell you why this function is an absolute trainwreck of bad design, poor readability, and astonishing inefficiency.
1. Length and Complexity
The function is a bloated monster of 164 lines that tries to do everything and fails at doing anything cleanly. It’s like watching a toddler try to juggle flaming chainsaws. There’s no modularity, no separation of concerns—just a single, disgusting blob of logic.
It’s riddled with nested loops, conditionals, and spaghetti logic. Reading it feels like navigating a labyrinth designed by someone who hates humanity.
The sheer number of inline calculations, random choices, and probability checks make it impossible to reason about or test effectively.
2. Variable Soup
The variables are an unholy mess. Let me introduce you to your own crime scene:
You’ve got three dictionaries here, each representing some kind of hazard-related data. Why? Who knows. They all sound the same. And then there’s this nugget of brilliance:
py
characters_count = len(characters_in_hazard_zones[key])
sum_of_hypes = sum([c.hype for c in characters_in_hazard_zones[key]])
You’re summing up the hypes of characters inside a dictionary keyed by hazard zones. Why is this even here? Why is "hype" controlling hazard mechanics? Are we on TikTok now?
3. Weighted Chaos
You’re trying to decide on a "hazard zone" with this monstrosity:
py
zone_weight = 1 / average_hype
Are you serious? Dividing by "hype"? This is a mathematical disaster waiting to happen. What if average_hype is zero? Oh, wait, you’ve got a conditional check for that:
So, let me get this straight: You’re calculating average_hype, only to set the weight to zero if all characters are in the zone. Why calculate it at all? And why are you using zero-weighted zones instead of skipping them entirely?
4. Randomness Overload
Congratulations, you’ve turned this into a random number generator simulator. Everything is a coin flip:
py
random.shuffle(cells)
direction = random.choice(potential_directions)
hazard_zone = random.choices(list(hazard_zone_weights.keys()), list(hazard_zone_weights.values()))[0]
Why even bother writing logic if every critical decision boils down to randomness? This is like playing Russian Roulette with a fully loaded gun—except everyone dies, and no one has fun.
5. Magic Numbers Everywhere
This function is littered with magic numbers and arbitrary constants:
py
success_proba *= NIGHT_PROBABILITY_FACTOR
if random_bool(1 - EVENT_FLEE_PROBABILITY):
character.alive = False
Where do these constants come from? Are they based on actual balance testing, or were you just throwing darts at a probability chart? I’m guessing the latter, because this feels like the programming equivalent of finger-painting while blindfolded.
6. Unnecessary Copypasta
The function has sections that repeat themselves with slight variations. Like this gem:
py
for character in characters_in_hazard_zone:
self.save_message("🔥🔥 A deadly event is occuring", channel=character.name)
py
for character in characters_in_hazard_zone:
potential_directions = []
if character.position[0] > -TERRAIN_RADIUS:
potential_directions.append("go west")
...
direction = random.choice(potential_directions)
...
It’s the same loop structure, just doing slightly different things each time. Ever heard of helper functions? No? Didn’t think so.
7. Unreadable Debug Logs
The debug messages are utterly useless. Look at this:
py
self.save_message(f"🔥🔥 Hazard zone {key} has {characters_count} characters with an average hype of {average_hype:.2f} (weight = {zone_weight:.2f})", channel="debug")
You’re logging every intermediate calculation as though anyone cares. By the time someone finishes parsing these logs, the Hunger Games will have ended, and the tributes will have retired.
8. The "Aborted" Mechanic
Why does this function sometimes abort completely?
py
if sum(list(hazard_zone_weights.values())) == 0:
return "aborted"
You’re telling me the game can just… skip a deadly hazard event because you failed to assign weights properly? That’s like starting a deathmatch and deciding not to fire the gun because you forgot to load it.
What You Should Have Done Instead
Here’s how a competent developer would have handled this:
Break It Down: Turn this beast into multiple smaller functions, each handling a single concern. For example:
calculate_hazard_weights
assign_hazard_zones
resolve_hazard_outcomes
Use Meaningful Names: Stop with the ambiguous hazard_cells and hazard_zone_weights. Call them danger_zone_candidates or zone_risk_factors. Anything but this.
Eliminate Redundant Calculations: You calculate average_hype and zone_weight multiple times unnecessarily. Simplify.
Deterministic Logic: Reduce randomness. Use randomness sparingly to add flavor, not chaos. The current implementation feels like playing dice with the laws of physics.
Readable Debugging: Log meaningful insights, not every intermediate step. Debug messages should explain why something happened, not drown you in numbers.
Final Verdict
This function is the single worst part of your codebase, and it’s not even close. It’s a [Redacted Person]’s monster of bad design, poor readability, and sheer laziness. If this function were a tribute in the Hunger Games, it wouldn’t even make it to the Cornucopia—it’d trip over its own feet and die before the countdown hit zero.
You’ve got potential as a developer, but this? This is rock bottom. Burn it. Rewrite it. Learn from your mistakes. Then, and only then, will you deserve to climb out of this pit of shame.