Game Like a Statistician: The Sometimes-Filthy Opportunity Cost of Zing

Dragon Quest is a interesting franchise of games for a number of reasons: it’s got a very nationalized fandom (large in Japan, tiny worldwide), the cutest mascot, and it’s really damn good.* Of particular interest here is that the Dragon Quest franchise has, from very early on, incorporated a good deal of random chance. Owing to the creator’s personal interest in gambling, opportunities to press one’s luck are found throughout the franchise, both overtly advertised in casinos and more subtly worked in the battle system. Unlike in real life, the casinos in Dragon Quest are eminently beatable – save at church, play highest-stakes game available, reloading if necessary, until a win happens, and repeat until you have the Metal King Sword at level 8. The finer points of DQ’s battle system are less obviously solvable – information beyond one’s control can determine whether a risk one is about to take is smart or stupid, and a lot of fictional parties ended up dead thanks to their players inadequate assessment of said risks.

One of the most fun choices in the series originates from a spell introduced in the series’ third installment. Zing is a spell which, half of the time it is cast, does nothing, an annoying feature balanced out by what it does the other half of the time – resurrect an unconscious party member. Thus, for much of the game, a player with a KO’ed ally faces a nonsimple dilemma – is zing generally worth it? Does the upside of having that ally back outweigh the opportunity cost? I’m going to examine some of the fundamentals of that question using a fairly basic battle simulator I built from scratch.

So what I have here is a simple Monte Carlo-ish simulator that plugs party of 2 Heroes with 100HP each against a boss with an amount of HP that can be varied. Each of these guys (boss included) have attacks that do somewhere between 20-30HP worth of damage each turn. The party members both attack the boss, naturally, and the boss randomly chooses a living party member to attack. Both become incapacitated when their HP hits zero, standard RPG rules. Player 1 has 20MP and access to the spell Zing, meaning he can spend a turn and 10 MP for a 50% chance of bringing P2 back at 50HP if P2’s health is below 0.

An important assumption this model makes is that the players never know how close the boss’ HP is to zero, so they are playing to maximize total damage done, rather than to ensure a victory. More on this in just a second. Also important – the model assumes the players always get the first move on any given turn (meaning the boss can target either P1 or P2 if Zing succeeds in resurrecting the latter).

Before we run some actual simulations here, it’s useful to point out that there are at least one distinct perfect-information case where both casting zing and not casting zing are the “correct” option (where the other choice either discards a guaranteed victory or guarantees an uncertain defeat):

Obvious Scenario A: The boss and P1 are both only one strike away from death (HP<20), P2 is down.

-P1 can end the battle immediately with an attack, and while casting Zing doesn’t guarantee a loss (P2 could come back with enough HP to tank some more hits), but the party wins 100% of the battles where P1 attacks from this situation.

Obvious Scenario B: P1 has less than 20 HP remaining, the boss has over 30 HP, and P2 is dead.

-The next hit will kill P1, but P2 would survive in the event he was targeted. The party trades one attack this turn (which is followed by guaranteed death) for a 25% chance of 2 attacks a turn from now, and a 25% chance of 1 attack a turn from now. The two-attack upside makes zing the clearly superior choice (given knowledge of the boss’ HP).

The point here is that there are reasons to argue why one approach might be generally better, and thus reasons why players would struggle to make these decisions in more-murky imperfect information situations. And that’s where numerical approaches start to get real useful.

The code used here is designed to simulate simple battles of the type described above, using pseudorandom numbers to compute damages, targets, and odds of zing success as described above, a large number of times for a given set of inputs (boss HP, party strategy, and boss strategy can be adjusted). After the conditions are set, it then runs those battles a total of 10,000 times to determine what fraction of the time the 2-man party ends up winning to within 1% accuracy. Results for 3 scenarios (comparing cases where zing is and is not used) are plotted and discussed below.

Scenario 1 – Boss simply attacks every turn

Zing-normal

-As one might expect, the odds of party victory decline the more robust the boss is. Against a weak boss, zing brings down the odds of victory, while it raises them against a strong boss. The area between the curves suggests that one might be better off, on average, just purely attacking; it’s a big advantage at low boss HP and a small disadvantage at high boss HP. Not too complicated here.

Scenario 2 – Same as #1, except the boss now has a 1/3 chance of using “coldbreath” and dealing 40-60 damage to each party member

Zing-cold

-The most obvious difference between this plot and the first one is that the party is much less likely to come out alive. Devastating attacks will do that. And, relevant to the discussion of zing, its ability to “extend” the party’s chances of victory out to tougher bosses has basically disappeared. When it’s not significantly worse than the first-order optimal blind attack strategy past 350 HP, it’s functionally indistinguishable. The largest difference between the two probabilities in favor of the zing strategy is five hundredths of a percent. Granted, that difference comes for a 500HP boss where the odds of blind attack winning the battle are an absolute zero, but if you’re fighting a boss you’re going to beat one time in 2000, you really need to grind a level or three.

What kills zing’s usefulness here? Many things, but a lot of them can be illustrated through what I like to call the “re-death” scenario.*** Here’s how it works: choosing to cast zing carries, by design, the 50% risk of utterly and unequivocally wasting a turn. In the first scenario, that ended up being ok because the upside kept the party alive against tougher bosses. In the second scenario, though, the odds are no longer just 50%. If the dice come up sour and the boss uses a coldbreath attack which does 50 HP or more damage, it leads to exactly the same as if zing never worked in the first place – P1 has fewer HP (if he’s alive at all) and MP, and P2 is still dead. Even if P2 survives the assault, he’s going to be 1 hit away from death, limiting the amount of upside via additional turns of offense he can bring to the table (you’re likely to get 1 to 2 additional attacks, one of which could’ve just been gotten via leaving him for dead). It’s not a happy prognosis, and it kicks zing users in the nuts 16.7% of the time.

But this is all assuming that P2 can do nothing but swing a sword at things. Let’s make him a little more useful, and see what happens in…

Scenario 3 – Same as #2, but P2 now has 20MP and can spend 4 to heal either player by 30-40 HP****

Zing-cold+heal

-Now that P2 has some jackknife utility, flipping the coin to get him back seems like a much more reasonable proposition – zing is a marginally better strategy for bosses with more than 250HP. The two strategies have somewhat similar odds, but you could create a wider gap simply by giving P2 more MP or effective spells.

Astute observers will note that this is, in fact, a gross oversimplification of the situations in which players typically find themselves in. In real DQ games you have items, offensive spells, chances of each side evading a hit, and many other factors coming into play. I’d like to go into more detail at some later point, probably starting with the comparatively simple first game, whose inner workings have been fully bared for some time. This is just some surface-scratching fun I had on a Saturday afternoon.

*V is on my top ten all-time game list, and is one of the few games I’ve played, cover-to-cover, more than three times. All of those times were kinda just super-great. The characters are amazing, unique individuals, the fairy tale aesthetic bleeds heart, and I felt like Liam Neeson in Taken for what amounted to the entire second half of the game.

**I’ve never been a huge fan of Final Fantasy’s core battle system (which is NOT the same thing as saying I dislike the games – there’s very excellent storytelling there that goes a long way). There’s an emphasis on real-time decision making emphasizes quick decisions over optimal ones, and boss fights sometimes ended up geared towards “guess the pattern/weakpoint” gimmicks rather than fine-point mastery of the mechanics.

***This shows up early in FFIV (to name one game) a lot because of the nature of the “Raise” spell, which always works but restores minimal health, leaving “re-death” due to normally nonfatal all-party attacks as a much more likely outcome.

****Which he will choose to do if either’s HP drops below 50, prioritizing P1 if both are in dire straits.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s