DPS Theory

May 31, 2008

Book Review: Kluge by Gary Marcus

Filed under: Biology, Books, Science — Peter @ 7:38 pm

Natural selection can only* work in small steps, and without foresight. So evolutionary progress is constrained to small improvements on what we’ve already got in place. Now, those small steps can accumulate to some pretty wonderful and complicated organs and organisms, such as the human brain, but the evolved design is strongly constrained by its evolutionary history. We wouldn’t expect those organs to be as nifty as they might have been if they’d been designed from scratch for a specific purpose. In Kluge, Gary Marcus details the mental errors we make all the time, and suggests that we are prone to making them because of the peculiar history of the evolution of our brains.

Pet peeve: in the first chapter, Marcus describes natural selection as a “satisficing” process, that doesn’t achieve optimal results, but good enough results. That always rubs me the wrong way–natural selection is a local optimizing process, with the caveat that what it’s optimizing is reproductive fitness, not, well, whatever we think a particular interesting organ is supposed to be doing. For example, we look at a liver, think, “Hey, it’s for filtering out poisons!” But no, a liver is meant to increase reproductive fitness, by a) filtering out toxins while b) not wasting too many resources on keeping blood clean as opposed to other vital functions. And as a local process, it suffers from the same failing of any local optimizing process, such as Newton’s Method: it tends to get stuck at the top of whatever local maximum it reaches first.

Anyway, we don’t expect evolution to achieve the best of all possible solution to a problem, but we can often expect that it’s doing as well as it can. The distinction is important, because any sloppiness or sub-optimality we see in an organism can tell us something about how it got to it’s present form, or about how costly a process would be to improve. And Marcus agrees with me about that, so no complaint there, I just don’t like his word choice.

Throughout the book, Marcus does a fine job cataloging our mental mistakes–reasoning error; faulty, fuzzy memories; our clumsy and illogical languages; our miscalibrated pleasure system that we’re eager to cheat. He refers to plenty of cute psychology experiments that explore the holes in our minds that we usually manage to overlook.

For each of our faults, he presents his imaginings of how our brain would work if it were built by a good engineer. To demonstrate how sub-optimal our brains actually are, he tries to tell us how much better they could be. These are often not very convincing–he proposes that we could have “postal code” memories that keep perfect, computer like track of where every datum is in our memories. But…how would we keep track of which code goes with each datum? Postal codes on postal codes? Sure, computers do it, but not really. All a computer does is run a set of arithmetical instructions that someone programmed into it. Interpretation of a computer’s output has always been done by clumsy human brains. When AI researchers try to build software that has contextual/interpretive abilities, that software always makes plenty of mistakes. And it doesn’t come with the ability to introspect it’s own software guts. Anyway, I will concede that our brains could have been built with a relatively small hard-memory module, for example; but expecting all of our memory to be perfect by working on a “postal code” scheme seems pretty far fetched.

I’ll counter-argue with Gary Marcus that our subconscious brain could be more optimal in some of those ways than he realizes, and that some of the mistakes and limitations of our conscious minds will be shared by the most sophisticated AI running on the best computers. I’ll of course concede, again, that we could have, in principle, been built with an integrated 16-bit calculator to help us with arithmetic, and that evolutionary history kept that from happening.

Similarly with language–he discusses logical languages that we could have evolved to understand. These languages would use words with phonic structures (for example) that give clues to their meanings, i.e. similar sounding words could mean similar things. A logical language would also result in a clear, distinct meaning for each statement it’s allowed to make. But–imagine a language that has no ambiguities. How would you (or evolution) know it has no ambiguities? If you only have a few simple concepts to express, such as a language that describes just arithmetic, it can’t be done. Gödel’s theorem. Simple arithmetic contains statements that can’t be proven true. I don’t know what they are. I’m not sure you can know that a particular statement can’t be proven. Now, in English and other human languages, there are plenty of obvious ambiguities, and we could probably do better if we put our minds to it. But how much effort would it take, and would it make evolutionary sense to invest it? Maybe evolution has built our language systems exactly as well as it needed to.

Another thing about language to illustrate the point–we are good at inferring meaning from partial information. At least, better than a computer is when it misses a little bit of information, which can result in a fatal program error. It may well be that the same system that allows us to infer meaning from partial information means we can’t tell so well when we’re saying exactly what we mean to say.

My other main gripe about the book is that Marcus never really discusses what these mental limitations tell us about our evolutionary history. It says right inside the front flap: “How the accidents of evolution created our quirky, imperfect minds.” But if we’re lucky, he’ll tell us that he can easily imagine that there’s a just-so story explaining the mental fault. Without even telling us his story! Great! I’d much prefer examples from other creatures minds, and what they tell us about how our minds work, or don’t work, as the case may be. Not a just-so story, and definitely not a hint that just-so stories are easy to imagine.

The penultimate chapter of the book is almost the most interesting. He discusses mental disorders, and suggests that the particular mental disorders that people suffer can tell us about how our brains are assembled. Great stuff, except that after he makes a persuasive and satisfying argument that it’s possible, he fails to do it. He offers some interesting guesses about what some common disorders might tell us about our brains, though.

Overall, I thought the book was somewhat interesting, and pretty fun and quick to read, but I already knew most of this information from other places that discussed them in more detail, with better context. And since it failed to live up to it’s purported unique, evolutionary history perspective, I was mostly disappointed:/

* “only” in practice; in principle evolution can take very large steps, it’s just that large steps are vastly more likely to break things more than they improve things, while I’ve heard that infinitesimally small steps are about as likely to improve things as they are to break things, so that half of those will be worth keeping, if they can bubble up above the noise

Obscure details in d20

Filed under: D&D, Games, Math, d20 — Peter @ 6:09 pm

I was wondering, what’s the probability that you’ll land AT LEAST some number of hits in d20. Turns out, it’s a lot easier to ask the question than to answer it. Start with at least 1 hit…easy enough:

P(at least 1 hit) = 1- P(all misses) = 1 – ∏i(1 – Pi(hit))

That was so easy! Plus, it makes it super duper easy to calculate P(at least 2 hits):

P(at least 2 hits) = P(1 hit) × (1 – P(all the rest misses)) = ∑iP(hit)×[1 - ∏j≠i(1-Pj(hit))]

And so on, until you exhaust all of your BAB-(5 per swing), at which point you get

P(all hit) = ∏iPi(hit)

Which is again easy. So, computing that stuff is very time consuming, but straightforward. It’s not as bad as it could be, though, because your max hit chance is P(hit) = .95, and min is P(hit) = .05, and at -0.25 per swing, you’ll only have at most 6 distinct Pi(hit), including several easy swings at P(hit) = .95 and hard swings at P(hit) = .05, at one each of the other 4. So if you get many many attacks per round, many of the terms in those sums will be identical. Maybe I’ll write a program to compute these things, maybe I’ll work out a rough approximation that’ll be easier to compute. /shrug

May 28, 2008

Mass Effect on PC…

Filed under: Games — Peter @ 6:36 pm

But will it work on my PC, I wonder. I’ve been quite a fan of Bioware’s games in the past, so I’ll give it a shot one of these days.

May 26, 2008

DPS in d20

Filed under: DPS, Games, Math, d20 — Peter @ 3:39 pm

Damage per combat round in d20 almost looks simple, until you know the rules. Which I don’t, thankfully. However, I know some of the rules of the Neverwinter Nights games, which while simpler than the pen and paper version of D&D, are still pretty arcane. But in a nutshell, what we need to know to calculate DPR(ound) is that you get one attack per round, plus one for every 5 points of BAB above 1. So you get 2 attacks for BAB on [6,10], 3 if BABε[11,15], and so on. Each additional attack has an additional -5 penalty to the to-hit roll, i.e. -5 on the second hit, -10 on third hit, -15 on 4th hit and so on. So if you like, you get to keep attacking at -5 more per attack until your remaining BAB is 0, at which point you can’t attack any more. You may also get off-hand weapon attacks, which are penalized in a complicated way depending on various feats you’ve earned and the size of the weapon you’re wielding in the off-hand. It can go from -6 main hand, -10 off hand to -2 each hand in; getting from the worst case to the best takes one more feat in NWN than in NWN2. Additional off-hand attacks will cost more feats.

Once we know all that, we can describe the chance to hit a target as:

P(hit|on the sth swing) = min[19/20, max(1/20, 20 + (∑ to hit bonuses and penalties) - AC - 5s)]

for main hand attacks. Then add those up over the S = int[BAB-1/5]+1 swings, and you’re set! Putting that together with the expected damage calculation from last post, it looks like:

DPR = d ∑BAB-5s>0 {min[19/20, max(1/20, 20 + (bonuses and penalties) - AC - 5s)]×[1 + (n-1)×min(w/20, P(hit|sth swing)]}

not accounting for feats like power critical (+4 to confirm critical) and so on. Adding in additional damage from extra attacks is straightforward.

Of course, we probably don’t care in particular how we’ll do against opponents with a specific value of armor class, and would like a measure of our effectiveness overall. Well, if you want, you can average that beast above over all armor classes, 1-∞…or up to some reasonable number, say 1-your character level, or character level +20, or something, depending on your environment. Of course, that’s overkill…there is a built in cut-off point, any AC > 19 more than your BAB+bonuses you’ll only hit on on a roll of 20, so you don’t need to give extra consideration to AC > 20 more than BAB+bonuses. Similarly, but more complicatedly, any AC < BAB – 5S will be hit on all but a roll of 20 (on every attack in a round), although you might allow some slack for those awful occasions when you’re debuffed by an enemy spell. Ideally, if you can assign a reasonable estimate, you could weight each AC by the likelihood of encountering that AC, like so:

<DPR> = ∑AC P(AC) DPRAC

and even better, would be to weight it not just by probability of encountering that particular AC but also by the threat that an opponent with that AC represents. That is, an opponent with an AC of 8 is likely a level 1 pauper who can’t afford any armor, and probably can’t afford anything deadlier than a stout cudgel (i. e. broken table leg), and will barely be able to touch your level 18 weapon master in enchanted plate armor let, so do you really need to worry about taking him out as fast as mathematically possible? So the best calculation we can do is probably something like:

<ΘDPR> = ∑AC <Θ>ACP(AC) DPRAC

where Θ is the measure of the threat that the target represents, which I will talk about in a future post.

Anyway, short of being able to put all that information together, I recommend plotting your expected damage out in a spreadsheet. Maybe I just suck with spreadsheets, but the use of the min and max functions seems to me to make it a pretty cumbersome thing to enter into the spreadsheet…the contents of the cells won’t vary in an orderly way.

May 21, 2008

Critical Hits in d20

Filed under: DPS, Games, Math, d20 — Peter @ 8:36 pm

Since of course there’s nothing more important to write about, such as states full of people who’d refuse to nominate a black HARVARD LAW GRADUATE for President of the United States just because he’s black (and therefore inferior to all the white people who’ve GRADUATED FROM HARVARD LAW SCHOOL magna cum laude–oh, well there ya go, a white person would’a graduated suma…)

Anyway, since there’s nothing like that to blog about this week, I’ll move on to how to weigh critical hit properties of weapons in d20. Is a broader threat range better or a higher multiplier? I’ll denote critical hit properties in d20 like so:

{w|×n}

where w is the width of the threat range, such as 18-20, 19-20, or just 20, and n is the threat multiplier. The threat chance is the width of the threat range divide by 20, or the chance to hit–whichever is smaller. Once you roll a critical threat, you roll d20 again to “confirm” the critical, with the goal to simply roll a hit this time. If you fail this roll, you hit the target, but don’t get the critical multiplier to your damage. Therefore, the expected damage on an attack looks like:

<D> = ∑ P(D) × D = d×P(regular hit) + nd×P(crit) = d[P(hit) - P(threat) + P(threat)P(miss) + nP(threat)P(hit)]

= d×P(hit)[ 1 + (n - 1) P(threat) ]

where d is the expected value of the damage roll, d = (min damage + max damage)/2, and P(threat) = w/20 (or hit probability if it’s lower) is the probability of rolling a critical threat. Note that for typical threat ranges (19-20 for sword, 20 for axe) and multipliers (2 for sword, 3 for axe), you get about 10% of your damage from critical hits; while with some feats, keen weapons, weapon master perks, it might get up to 20% or more (unless you fight a lot of undead, etc. with critical hit immunity).

So, we have

(1/d×P(hit))<D+> = w(n-1)/20

(1/d×P(hit))Δ<D> = [w/20] × Δn

(1/d×P(hit))Δ<D> = [(n-1)/20] × Δw

with <D+> the extra damage that comes from critical hits, which depends on 1 less than n because you were going to do some damage anyway. When weighing critical hit properties, you are mostly concerned about the product (width of threat range)×(crit multiplier – 1). A sword with {19-20|×2} is worth 2×1=2, an axe with {20|3} is worth 1×2=2, and a falchion with {18-20|×2} is the same as a scythe with {20|×4}, both equal 1.5. Keen weapon or improved critical both double the threat range, which doubles the value of critical hits. Adding one the the critical damage multiplier doubles the value of a sword, but only increases the value of a scythe by 1/3.

The exception is if you expect to be fighting enemies with ACs so high you’ll only hit them on rolls of 20, or if you are acquiring feats or magic weapons that give extra damage on critical hits. Extra critical threat range is just wasted in that situation. Also, since you’ll rarely hit such a beast, you’ll want to get the most out of every hit. Therefore, the scythe, if available, is the way to go…except that really, you’ll only be hitting one in every 20 swings, and critical hitting one in every 400 swings, so maybe you should just run in that situation. Except that, of course, advancing the plot probably depends on winning the fight, and the designers have probably locked you in a room with him. /sigh

Anyway, there are some annoying discrepancies in my notation, which I’ll straighten out in a future edit.

May 18, 2008

Tar Baby?

Filed under: Minutiae — Peter @ 6:24 pm

Some rethuglican uses the term tar-baby within a few breaths of mentioning Barack Obama.  Crooks and Liars, one of my otherwise favorite blogs, calls this racist…why, exactly?

Oh, I know, it must be that making allusions to African/African-American folktales reminds us all that black people are just a few generations removed from being primitive, backwards jungle monkeys.  And for the sake of all that is liberal, we have to, HAVE TO pretend that they aren’t.  Let’s all close our eyes and pretend that those niggers can be as sophisticated and cosmopolitan as white people.  Not doing that is racist!

Really, he may have wanted it to be racist, but shouldn’t it be a triumph of liberal multiculturalism/ integration/ diversity that even rethugs can make references to African folklore?  It’s often been noted before that liberals have already won the argument (on most things), and so conservatives try to shoehorn their corrupt values into liberal sounding rhetoric so they don’t come off sounding evil.  On the other hand, they try, but they’re usually really bad at it, and yet they get plenty of support anyway.  /shrug

Anyway, casually tossing off tar-baby (in the correct context) is not racist, even if the rethug uttering it really, really wanted it to be.

May 17, 2008

Hitting a Target in d20

Filed under: DPS, Games, Math, d20 — Peter @ 6:46 pm

In the current (version 3.5, anyway, I think ver. 4 is out now) edition of Dungeons & Dragons, hitting (or missing) a target is pretty easy. It is, after all, meant to be done by people playing on a tabletop with dice, a pencil, and paper…not necessarily on a 3GHz microprocessor pushing a few billion floating point operations per second. So all you do is roll a 20 sided die, you always miss on a 1, always hit on a 20*, and otherwise, if your hit roll plus “base attack bonus(BAB)” ± other modifiers is greater than your target’s Armor Class (AC), you hit your target! The BAB depends on your character’s class and level, you’ll look it up in a table. Other modifiers are any applicable strength or dexterity bonuses, weapon enchantment bonuses, buffs or debuffs, and about a hundred other details in the D&D rules. Armor class depends on the type of armor, be it plate armor, chain mail, leather, whatever, and dexterity (for dodging), and some other things. Thus, the basic probability of a hit is

P(scoring a hit) = {MIN[19/20, MAX(1/20, (20 + BAB + to-hit modifiers - AC)/20)]}

All very linear and easy, no squaring, no roots, no exponentials. Yawn.

However, just to spice things up, Wizards of the Coast have also allowed you to roll a “critical hit (or crit, for short).” On a crit, your damage is multiplied by two, three, or more depending on the type of weapon you’re weilding and your proficiency with that weapon, as described by “feats” you have acquired. To roll a crit under the v. 3.5 rules, you must roll high enough to hit (including modifiers), and the number on the face of the d20 must be within the “critical threat range” of the weapon you’re swinging: 20 for a battle ax, 19-20 for most swords, and 18-20 for weapons such as scimitars. However, after rolling (a hit) within the critical threat range, you must then roll the d20 again, with the same modifiers (you may have a feat that gives an extra bonus to this roll), and score a hit. Failing this second roll still results in a hit, but not a critical hit. So, the probability of a critical hit given that you’ve rolled a critical threat is:

P(crit hit|crit threat) = P(scoring a hit)

or, with the aforementioned feat (Power Critical, gives +4 bonus to hit on this roll with a specific weapon)

P(crit hit|crit threat with power critical feat) = P(scoring a hit) + 4/20 (for 2/20 < P(scoring a hit) < 16/20)

The probability at the ends is still capped at 1/20 to miss and 1/20 to hit.

Thus,

P(crit) = .05×MIN(threat range, hit chance) × P(scoring a hit)

without Power Critical and

P(crit with power critical) = .05×MIN[threat range, hit chance] × [P(scoring a hit) + .2] .2 < P(scoring a hit) < .8

Now, what’s the chance of scoring a regular hit, but not a crit?

P(regular hit) = P(scoring a hit) – P(crit) = 1 – P(crit) – P(miss)

That’s straightforward enough.

Now that we can hit a target, which is worth more? A more damaging crit (higher crit multiplier) or a more accurate crit (broader threat range/power critical)? I’ll look at that next time.

*If for some reason you can’t see your target, say cuz your character is blinded or the target is invisible, there will be another d100 roll against a concealment percentage.

I know I should be offended…

Filed under: Minutiae — Peter @ 12:24 pm

Who knew that the bioethics of stem cell research and abortion were this complicated?

Worst of all from this point of view are those more uncivilized forms of eating, like licking an ice cream cone–a catlike activity that has been made acceptable in informal America but that still offends those who know eating in public is offensive. … Eating on the street–even when undertaken, say, because one is between appointments and has no other time to eat–displays [a] lack of self-control: It beckons enslavement to the belly. … Lacking utensils for cutting and lifting to mouth, he will often be seen using his teeth for tearing off chewable portions, just like any animal. … This doglike feeding, if one must engage in it, ought to be kept from public view, where, even if we feel no shame, others are compelled to witness our shameful behavior.

-Leon Kass

We tolerate (against all good sense) licking ice cream in public, so of course it’s just a matter of time before we devalue human life so much that we want to try to extend it and protect it against degenerative diseases by studying therapies derived from stem cells.

Let me make sure I understand.  Someone is offended about the idea of women having control over their sex lives.  So they make up excuses about how precious every blastocyst is.  In order to keep up the charade, they must also condemn embryonic stem cell research.  Cuz it violates human dignity.  To want to treat diseases and such.  But the violation of dignity is specious, so to strengthen that argument, Kass makes up some shit about how awful it is to eat in public.

K, got it.

And just so we’re clear, Kass leads Prez Bush’s council on bioethics.  He has our 2 term prez’s ear.  Yay, America.  We’re no. 1!

Am I Fit?

Filed under: Minutiae — Peter @ 12:09 pm

According to the new Presidential Fitness Test for adults, I am doing ok:

  • Sit and Reach: 22″ (95%) (although I may get another inch or so if I warm up…)
  • Push-ups: 60 (95%)
  • Half Sit-ups: 79 in 1 minute (95%)
  • BMI: 24.4 (5′11″, 175 lbs, 32″ waist, ergo normal, but on the overweight side, despite my approx 9% body fat)

I didn’t do the walk or run test…

May 15, 2008

Why do I click on these things?

Filed under: Minutiae — Peter @ 7:58 pm

5 dates no guy wants to go on…

No hiking?  No opera?  WTF?  I will freaking drag the girl at the fast-food restaurant to Cincinnati if the Cincy Opera is putting on Carmen…

Ok, no, I wouldn’t.  But I’d regret not having done it in the morning.

Older Posts »

Blog at WordPress.com.