Void & Ender_Dragon
Ender_Dragon Ender_Dragon
I was just tweaking a party build in D&D 5e that relies on perfect timing and stealth—like a rogue combo. How would you approach optimizing that from a coding perspective?
Void Void
First model each move as a small function that returns a new state: initiative position, stealth level, attack bonus, and any cooldowns. Then build a state machine that tracks the party’s turn order, keeping a record of who’s acting and what resources they have left. Use a breadth‑first search or A* to explore all possible sequences, pruning states that are dominated (same or worse on every metric). Cache results with memoization to avoid recomputing identical sub‑states. Finally, profile the simulation; if it slows down, switch from lists to packed arrays or use bit‑masking for flags to shave milliseconds off each step.
Ender_Dragon Ender_Dragon
Nice, that's exactly how I would script a turn‑based optimizer. A tiny state function, a clean state machine, then run a BFS or A*—and cache to keep the simulation from blowing up. The bit‑mask trick at the end is the sweet spot between speed and readability. Have you thought about how to handle random critical hits in the state graph?
Void Void
You treat a crit as another branch in the graph. For each attack step, split the state into two: normal hit and critical hit, weighted by the crit chance. Propagate each branch forward, then when you evaluate a node combine the outcomes by expectation—sum (value * probability). That keeps the graph manageable while accounting for randomness. If the crit chance is low, you can even prune very unlikely branches after a few turns.
Ender_Dragon Ender_Dragon
That’s the precise way to model luck—branch and weight, then collapse with expectation. I’ll keep an eye on branch explosion; if the crit rate stays below a percent, I can prune aggressively after a couple of turns. It keeps the search from ballooning while still reflecting probability.
Void Void
Sounds solid. Keep the pruning thresholds tight, and you’ll get a lean tree that still captures the rare but impactful crits. Just remember to validate the probabilities against the actual table to avoid skew.
Ender_Dragon Ender_Dragon
Got it, will keep the thresholds strict and double‑check the crit tables to make sure the probabilities line up. That should keep the tree tight but still let those high‑impact hits slip through.
Void Void
Just keep a log of the branch counts; if you notice any unexpected spikes, backtrack and adjust the pruning logic. That should keep the model reliable without over‑complicating the simulation.