Friday 31 October 2014

Scattered Thoughts About Jian Ghomeshi

Since I have no idea who reads this, but I'm sure someone I don't know does, I will briefly who Jian Ghomeshi is. Ghomeshi is a well known Canadian who gained early, though brief, fame with an a cappella band and later became involved with CBC, Canada's national broadcaster. He co-founded the radio show Q in 2007 which has become a very popular show for CBC and, as I understand it, has been syndicated to the US. So firing him was kind of a big deal for the CBC.

But that was what the CBC felt they had to do when allegations of sexual violence came to light. Ghomeshi tried to get out in front of the allegations by hiring a PR firm and writing a lengthy post on Facebook that said that he was going to be falsely accused of things. When the next day he was accused by three anonymous women, and then the next day it was eight, it strained credulity to believe this was really a conspiracy against him. Now women have started putting their names and faces to the stories and his PR firm has dropped him, so it's manifestly unreasonable to believe his version of events.

So Jian Ghomeshi likes to hit women. This is done, according to him, as part of some kind of consensual sexual activity, and I think it remains to be seen how much he believes that, but it certainly doesn't remain to be seen whether that is true - it is not true.

I have a few scattered thoughts about this:
  • When I read Ghomeshi's facebook post, I thought he'd have to be a real sociopath to write that if he had actually sexually assaulted women. I feel like I can probably stand by that.
  • This and other recent events are bringing a lot of attention to how hard it is to come forward when someone has been violent towards you. Lucy DeCoutere, one of the women Ghomeshi has assaulted, said "I thought I'd be destroyed." This is a great conversation to be having. It's staggering to me that people don't understand how difficult this can be, especially when the person you would be accusing is famous and well-liked.
  • People at the CBC knew about this before the last few weeks. People who knew Ghomeshi knew about this. The CBC did not fire Ghomeshi because he likes to beat up women, they fired him because the public was going to find out that he likes to beat up women. From their perspective this makes sense - his public image is a product that they sell. I also don't think the is a moral high ground in firing people for doing terrible things when they aren't at work because that's just sweeping the terrible under the rug. But what did they do? Who talked to Ghomeshi about this? Did any of his friends, family or co-workers who knew say anything?
  • It doesn't seem likely Ghomeshi picked this up at the age of 36. More stories are probably coming.
  • Don't lie to your PR firm. Why hire a PR firm and lie to them?
A lot of people jumped to Ghomeshi's defense immediately after he posted his facebook explainer only to retract and apologize later. None of these people should have doubted that Ghomeshi is capable of sexual assult.

About one in five men - and about one in seven women - are abusive to domestic or sexual partners. I would bet most of us know at least one person who we are really sure would never sexually assault anyone. You know, someone we really, actually know rather than a radio host we feel like we know. There are some people who just don't seem to have aggression in them in that way, or who just show too much empathy to believe that they would be so cruel to someone. I don't think it's impossible to judge other people's character.

But there is a very good chance you don't know which among your friends, classmates or colleagues makes up part of that approximately 17% of people. What you can know is that one-in-six is too many people for them not to be around you all the time. It's too many for you to not have that classmate or that co-worker or that friend. It's really too many for your to not have those classmates and those co-workers.

When we hear that someone has been accused of a sexual assault, we'll be tempted to think, "Oh, not them," but we should remember to think, "If not them, then who?" because we know this is going on all around us and a staggering proportion of the population is involved. If you think no one you know is an abuser, stop and remind yourself that that almost certainly isn't true.

If we lived in a society where only 1 in 1000 people committed domestic abuse then it would be plausible that you actually don't know an abuser, that you don't say hi to an abuser in the morning and that you never go get coffee or lunch with an abuser. But we're a long way off from that.

Thursday 30 October 2014

Combat System

I mentioned that I'm trying to bring World of Progress into reality, but living up to contemporary idle game standards - that is, you will actually play the game rather than simply letting it play itself. What you won't do is control any of kinds of actions you normally control in an RPG - attacking enemies, casting spells, and so on. Instead, you'll control strategic choices like what gear to equip and what area to adventure in and let the minutiae of dispatching endless hordes of monsters to your able avatar.

I've been trying to work out a combat system that I'm satisfied with. The goals are:
  • Many Stats with very different effects so that there are lots of different stats to use on gear
  • No Stat Too Obviously Powerful so that picking stats on gear isn't too boring
  • No Weapon Class Obviously Better so that you don't feel like you should always use a dagger
It's not really easy to come up with a formula that does all of this and I'm open to suggestions. I can really see how game designers struggle with this kind of stuff. Once someone has developed the world you are living in - we're rolling d20s to see if we hit, or 'block' pushing 'miss' off the hit roll table - you can start figuring out how to weight the different parameters.

But when you start with different parameters, it's not so easy to just jump in with a formula. I don't want to make everything multiply by x over x + y or having everything add x% because that's what makes different stats really boring - stats will always do the same thing an once you've determined the appropriate difference between x and y or the appropriate ratio between x and y you've solved the whole system.

I have the advantage of being able to make the damage roll system extremely quirky, but I want it to make some intuitive sense even if no one will really ever see it. The basic problem I have is that things that add damage make fast weapons better, so unless I subtract as much damage as I add, fast will be better than slow. The typical thing that makes slow better is attacks that use weapon damage but not weapon speed - usually ability that have cooldowns and I don't have those.

I suppose the solution is staring me right in the face - implement abilities with cooldowns. Maybe until then I just have to accept the use a dagger paradigm.

Tuesday 28 October 2014

Seven Habits

I'm reading The Seven Habits of Highly Effective People. I won't go into the backstory here, but I feel like I'm in a position where I ought to read it so I'm making an effort to do so. One of the things the author does early on is that he asks you, as a reader, to share what you've learned from the book within 48 hours of reading each part. He explains that you will pay a lot more attention and get a lot more out of the book if you know you are going to have to tell someone else about it later. You'll force yourself to avoid skipping and glossing over points that you know you might be asked about.

I'm sure he'd bristle at the suggestion that this is a devious promotional trick, since his entire philosophy is to eschew devious promotional tricks. For what it's worth I think he's probably sincere in his belief that this will help the reader learn. Of course I bristle at the suggestion that I can learn anything by reading his book, and I don't think I read things any differently when I plan on telling someone else about them anyway since when I read things I generally actually read them in the first place. All that aside, though, I've got a blog where I talk about things I'm thinking about so I'm basically doing what he told me to anyway.

Two basic things strike me about the book:
  1. Covey's central thesis - that in order to be happy and feel fulfilled you need to put your internal life and your character above your external presentation of yourself and your image - is pretty reasonable
  2. Covey is a sweltering idiot of the highest degree
In Covey's defense I will say that the odds that I was not going to think the author of a book titled "The Seven Habits of Highly Effective People" was a superlative moron were extremely slim. The deck was substantially stacked against him if it was his goal to have Humbabella think, "Yeah, that guy isn't stupid on an inhuman scale."

But in his not-at-all-defense, here is a quotation:
uniquely human... animals do not possess this ability... "self-awareness"... the reason why man has dominion over all things... separates us from the animal world... basic nature of mankind... man has the freedom to choose... uniquely human... imagination... conscience... independent will... even the most intelligent animals have none of these endowments... they are programmed by instinct and/or training... they can't take responsibility... can't change the programming... they're not even aware of it... unique human endowments... this is why an animal's capacity is relatively limited and man's is unlimited... if we live like animals... we too will be limited... our unique human endowments lift us above the animal world... our uniquely human potential... nature of man... as human beings we are responsible...
This odious mass of staggering idiocy spans pages 74 to 78 of the 25th anniversary edition I have my hands on. I'm not sure what would drive someone to average saying "unique(ly) human" once a page for five consecutive pages, but presumably it has something to do with that person's free will or their nature as an instance of "man."

Of course that's a side note. Covey may be personally mired in some kind of Christianity-based magicthink about human exceptionalism but though that makes the basis of his theories suspect, it doesn't change whether or not he's basically right.

So is he basically right? Well his basic idea is that if you want to be effective you should live by the "character ethic" rather than the "personality ethic." You should live by your values rather than live to give off a good impression. An easy example is that if you want to be trusted, you should be trustworthy rather than try to convince others they can trust you. The impression others get from you will flow from the truth of your actions.

Yeah, I think he is basically right but with some important caveats. First of all, his idea of "effective" seems to be some kind of monstrous hybrid of contentedness and material success that makes no sense. Second, he thinks that those values you should live by are the same for everyone and flow from "natural law." So he's right as long as we accept that he is a dictionary-perfect imbecile.

On the other hand, this book was released in 1989 and has since sold 15 million copies and was named one of the 25 most influential business management books by Time in 2011. I wouldn't exactly say that the intervening years have been good for "character ethic" or bad for "personality ethic." They haven't been good for valuing productive capacity as much as production. If this is such an influential business management book, why are businesses evaluated on metrics like quarterly percentage change in profits, which represent the very height of the personality ethic of looking good without any substance?

80-some pages into the book I would say that pretty much every good idea he is presenting has fallen further and further out of favour in the mainstream and every bad idea he contrasts those with has come into ascendency. Like most self-help books, the point of the book appears to be to make the reader feel good for a couple of weeks after which they can go back to the miserable life they were leading before. Maybe they can pick up another self-help book.

Of course nothing Covey could write could possibly be as sickeningly moronic as the foreward to the 25th Anniversary edition. Here's a snippet:
As I reflect upon some of the exceptional leaders I've studied in my research, I'm struck by how Covey's principles are manifested in many of their stories. Let me focus on one of my favourite cases, Bill Gates. It's become fashionable in recent years to attribute the outsize success of someone like Bill Gates to luck, to being in the right place at the right time. But if you think about it, this argument falls apart. When Popular Electronics put the Altair computer on its cover, announcing the avent of the first-ever personal computer, Bill Gates teamed up with Paul Allen to launch a software company and write the BASIC programming language for the Altair. Yes, Gates was at just the right moment with programming skills, but so were other people - students in computer science and electrical engineering at schools like Cal Tech, MIT and Stanford; seasoned engineers at technology companies like IBM, Xerox and HP; and scientists in government research laboratories. Thousands of people could've done what Bill Gates did at the moment, but they didn't.

You know, I went to a casino and put down five grand on 33 on the roulette table. I won. Now you may say that was just luck, but just think about all the people standing around that table who could have done what I did but didn't. If you want to read some real galactic idiocy, it's Jim Collins who delivers, rather than Stephen Covey.

Monday 27 October 2014

I Got Very Distracted There

This last week I've been spending all the free time I could find coding something I've meant to make for a long time - a reimagining of the classic MMO Progress Quest. Progress Quest is the original idle game, predating Candy Box and Cookie Clicker by more than a decade. But Progress Quest was truly an idle game. There was no way to interact with it once you selected your name, race and class and rolled your stats.

The choices you made didn't matter except for an oversight that made it ideal to have your strength be as high as possible and all other stats be as low as possible. Your character fought monsters, completed quests, progressed through the story, and got new equipment, all without you clicking a thing.

For a long time I thought about making a Progress-Quest like game, and now in the age of idle games, the time has finally come. I've started making a lot of idle games in the past, this is probably the farthest I've gotten on one. I'm hitting the wall now in that I'm really not sure what the mid-game should look like, so this one might be headed for the heap soon too, but maybe not because what I've got so far is actually pretty neat. All that practice coding javascript has really paid off.

What I really want to brag about is an incredibly dumb thing that will, I'm fair sure, cause most of the population to say, "What does that mean?" or "Why does that matter?" and will cause the vast majority of people who understand what I'm talking about to say, "Yes, of course that's how you do it." But I felt good that I thought it up anyway.

Something that always bothered me about the code for Cookie Clicker was a section where it checks whether you've gotten certain achievements. Essentially, it looks like this:

if (count>100) award_achievement(1);
if (count>10000) award_achievement(2);
if (count>1000000) award_achievement(3);

And so on. Every time I look at that I just don't like how even after you've got achievement one, every time it goes through that code it checks if you should get it, then if you should it calls the function which checks if you already have it and then returns nothing. Now evaluating if statements shouldn't be taxing the processor cycles of a contemporary computer, but I just don't like the fact that its doing it. It's more about aesthetics than about the actual wasted effort.

The solution to this problem was way too obvious for it to have taken me so long to think of. Each talent in my game has a lock function. All of those functions are added to an object. When it comes time to check if talents should be unlocked, it runs through all the properties of the object and executes each function. If the function returns true then it both unlocks the talent and removes that function from the object so it is never checked again.

Depending on how javascript works this might be a straight-up worse solution than the put-it-all-in-a-list way. After all, I have no idea how hard it is for javascript to go through the properties of an object in a for-in loop.

But of course my way has another advantage. The check to see whether to unlock each talent is with that talent in the code, so if I want to change it I know where to look and I don't have to go to more than one place to cover different cases.

So I'm happy I did it. And I'm happy to report to you, my readers, that I definitely have some code written and there is really a possibility I will not leave it to rot.

Tuesday 21 October 2014

Statistical Ties

This post is essentially just me being angry, though if you don't have a foundation in statistics, I might have inadvertently put some content in as well.

Not too many years ago the media got wind of something called "error" in polling. It turns out polls don't necessarily accurately reflect the population! But that's okay, the media got wise, and now they understand and responsibly report on margins of error in polls.

Something you will hear in the news often is the phrase "statistical tie." By that, the reporter will mean that two people are within the poll's margin of error of one another. So, if the poll gives an accurate result within 3%, 19 times out of 20, then a "statistical tie" might be 37 to 40 or 33 to 36, or something like that. If the poll is only accurate within 3%, then 3% apart is basically the same thing.

This doesn't have the properties we normally look for in an equivalence relation, though. If 33 is basically the same as 36 and 36 is basically the same as 39 then isn't 33 basically the same as 39? That's called transitivity, and it's a property we expect to find in any relationship that tells us when things are the same. Obviously it doesn't work here, so we might suspect something more is going on.

The idea that 36 is basically the same as 39 is fantastically dumb. Calling it a tie is nonsense. If the margin of error is plus or minus 3%, 19 times out of 20, that doesn't mean that within that range all bets are off. We could also calculate a 90% confidence interval, and a 50% one. The 50% one would be a lot tighter.

But even if everything within the range was equally probable, that would still mean that there was only a one-in-eight chance that the candidate that polled at 36 actually had more support than the candidate who polled at 39. That's hardly a tie.

Let's also remember that the numbers we are seeing are rounded. If "within three" makes two numbers the same, it's a bit problematic that one of them might actually be 35.9 and the other 39.1.
And if overlap of a margins of error meant equality then we should actually be doubling the margin. That 33 might be 36 and that 39 might be 36. That's a tie too!

Two numbers that are half of a 95% confidence interval apart from one another are actually pretty far apart. The one that polled lower is unlikely to be higher than the one that polled higher. There is no "statistical tie," statistics allows us to calculate the actual chances that each is higher and the answer is not anything like 50-50.

The media presentation of margins of error is one of those we-learned-something-and-know-we-are-worse-informed scenarios. For people who don't actually understand statistics and math, a far more useful understanding is to see the numbers in the polls, and assume that the difference between them is the actual difference, but keep in mind that polls get things wrong sometimes.

Monday 20 October 2014

Harvester

It's October, so supergreatfriend is playing spooky games on his Saturday night stream. One game he played is Harvester, a 90's point and click adventure set in a small town in the 50's. This game seemed really bizarre, so I dounloaded a playthrough of the game from longplays.org and gave it a watch.

There are a lot of "horror" games out there in that there are games that try to scare you. Harvester is a real horror game in that it is absolutely horrible to experience. The entire point of the game seems to be to make the player feel extremely uncomfortable. To do accomplish this it uses themes covering everything from incest to cannibalism to emotionally unstable people left in charge of nuclear weapons. Lots of gore, lots of deranged people in a 1950's small town.

While playing someone asked supergreatfriend what this game was rated. But, as he said in reply, this game was made in the 90's. You didn't get games rated then, you just made them and released them. I find this game a very interesting look into a time before game ratings. For all of the "adult" content you see making its way into games - sex and violence and whatnot - you don't see games like this. This is really over the top.

Let me be clear, I do not recommend you download and watch this game, and I certainly don't recommend you play it - it looks like it would be really dreadful to play. But even though I'm not recommending it, I thought I would relate the fact that I watched it. Harvester is now a thing that has happened to me.

One final note: I'll say nothing about how awesome or incredibly stupid the ending is. Who knows?

Thursday 16 October 2014

Clicker Heroes - Dora and Boots Mimzee

My hypothesis is that treasure chests appear 1% of the time. I ran an overnight test and figured a result as extreme as mine was 70% to occur by chance with a 1% hypothesis, so I feel pretty good about my guess. If you want to run your own test bear in mind that while the game is closed it farms up gold and monster kills for you but does not get chest kills, so you can't close and reopen the game if you want to get an accurate count.

Treasure chests give 10 times as much gold as normal monsters, this is a lot easier to test.

So 1% of the time you meet a monster who gives 10 times as much. That means that an average monsters gives 109% of the gold that an "average monster" gives.

Dora gives you 20% more treasure chests per level up to a maximum level of 50 while Mimzee gives 50% more gold per treasure chest. 20% more treasure chests would mean we get 1.11 normal monsters of gold per monster instead of 1.09, a 1.8% increase. 50% more gold from chests would mean we get 1.14 normal monsters of gold per monster gold instead of 1.09, a 4.6% increase.

But these two ancients combine better than other ancients. Each level of Dora you have makes each level of Mimzee better and vice versa. If I had one ancient that gave me 5% more gold per level and another that gave me 2% more gold per level, then with ten levels of each I would have 150% times 120% = 180% gold. With Dora and Mimzee 10 levels of each means getting treasure chests 3% of the time and getting 60 times the normal gold from those chests, which means getting 254% of the gold I would normally get.

This gets even wackier at higher ranks. If I invested 25 levels into Mammon and 25 levels in Dogcog I would have 125% extra gold from Mammon and effectively 100% extra gold from Dogcog for a total of 4.5 times as much gold. With 25 levels in both Dora and Mimzee I get 7.46 times as much gold. When you get both to 50 a 5% and a 2% ancient would give you 7 times as much gold. Dora and Mimzee gives 27 times as much.

Whats more, while Dora has a maximum level Mimzee does not. Suppose you had maxed out Dora but didn't have Mimzee. That would give you an 11% chance of treasure chests. That gives 199% of "average monster" gold per monster kill. Buying one level of Mimzee would increase that to 254%, at 27.6% increase. Once you have maxed out Dora, you can regard Mimzee as an ancient that gives 27.6% extra gold per. Since I advise buying Mammon at 5% per level, you can imagine what I think of Mimzee. Is it worth paying summoning cost plus 1275 souls to get a supercharged gold providing ancient? Of course it is.

But level 50 Dora may seem a long way off - I'm not particularly close to having level 50 ancients myself. What's the break even point where Mimzee becomes better than Mammon? When Dora's level two of course! Naturally you have to pay the price of the second ancient is a price to pay, but fortunately by the time Mimzee is level 8, Dora is also better than Mammon.

Mammon is a class above both Dogcog and Fortuna, and starting at ancient level 8 both Dora and Mimzee are a class above Mammon as long as you have both. I also think they are a class above all the other ancients as well. Honestly, Mammon is pretty good compared to his brethren.

I made a complicated three dimensional spreadsheet to determine how to level up Dora and Mimzee, but that was just to detect any anomalies. Basically you are increasing the amount of gold you get from treasure chests which is a (1 + x) × (1 + y) type function, so you know you know from my multiplication post that you want to keep x and y a fixed distance apart and in this case that's one. You also want to buy up Dora every time you buy up Mimzee and vice versa because buying one up makes the other one better and makes it worth buying up too.

So I replaced that spreadsheet with a really simple one that treats Dora and Mimzee's levels as a single dimension that goes up together. Here is the sheet. It works the same was as Mammon did. You can change the initial cost - remember to include the cost of summoning both - to figure out when you should buy in, and you can use it to determine when it's a good idea to buy up the next ranks.

Wednesday 15 October 2014

Clicker Heroes - Not Mammon

There are a variety of ancients that give you gold in different ways. Fortuna gives you a small chance of getting bonus gold for each enemy. Dogcog reduces the cost of heroes which is effectively getting more gold since once you get to endgame levels are the only thing to spend gold on. Dora gives more treasure chests, and Mimzee gives more gold from treasure chests.

Amazingly, all of these are far worse than Mammon.

Now that's not actually true. Dora and Mimzee together are better than Mammon because their effect multiplies. Thus it shouldn't be a surprise that their individual effects are worse than 5% gold per level. I'll get to them in the near future, but today Fortuna and Dogcog have some explaining to do.

Fortuna gives a 0.25% chance of getting ten times as much gold from each monster killed per level. It costs the same as Mammon and has a maximum level of 40. That means with 40 levels invested Fortuna gives a 10% chance of getting ten times as much gold. Since that monster would have given you one times its normal gold without Fortuna, that means the bonus is nine times the gold of a regular monster. That's 90% extra gold. For 40 levels. If that doesn't sound right, imagine you were able to continue to buy levels of Fortuna. At level 400 the chance would be 100%, so Fortuna would just give 10 times gold for all monsters. That's a 900% bonus. A level 400 Mammon would give a 2000% bonus. This is a specific instance of the general rule that crit is always bad. Fortuna is critical strike chance for gold earned.

Dogcog gives 2% off the cost of heroes each level for 25 levels. That's effectively 100% more gold for 25 levels.

Since each of these is worse than Mammon on a per-level basis, it should be obvious that Mammon is always better. Since Dogcog arrives at a better maximum effect in fewer levels, it should be obvious that Dogcog is better than Fortuna when you average everything out. But like I said in my discussion of Mammon, when you are multiplying, the question is not so much whether to get it as it is when to get it. Also, from my post about fixing your intuition about multipliers, we should guess that number of levels you put into Mammon and the number of levels you put into these lesser ancients should be fairly close - closer than the vast superiority of Mammon would suggest.

My next ancient costs 250 souls to purchase. At that price, I should buy into Fortuna for 19 levels at 1415 souls. With that number of souls, the correct number of Mammon levels to buy would be 31, almost 32. That's a 12 or 13 level difference between the two ancients. However, the final level of Fortuna - level 40 - should be bought at 4107 souls. With that many souls, you should be buying the 49th level of Mammon. After that point, if you were allowed to continue to buy levels of Fortuna, the difference between your Fortuna and Mammon levels would remain at about 9.

Dogcog works a little differently. Because it reduces the price of heroes by a fixed percentage that adds up, each level is actually more powerful than the previous one. The first level reduces costs from 100% to 98% which means you effectively have just over 2% more gold. The last level reduced costs from 52% to 50% which means you effectively have 4% more gold.

Because Dogcog gets more powerful with each level, it make sense to max him out much sooner. The first level of Mammon, with a summoning cost of 1, is worth purchasing at 15 souls. The first level of Dogcog is at 51 souls. By contrast, the 25th level of Dogcog is worth purchasing at 1081 souls, while the 25th level of Mammon isn't worth purchasing until 1360 souls.

That probably sounds insane. Why would you wait longer to get a total of 125% more gold than you would to get 100% gold for the same cost?

There are two facts that go into answering this question. First, remember that we are thinking on the margin. The 25th level of Mammon increases your total gold production from 2.2 to 2.25 which is only a 2.3% increase, while the 25th level of Dogcog is a 4% increase. Those numbers assume you already bought the ancient to 39. Second, remember that these numbers only tell you when your production increases by buying that ancient, they don't comment on how much it increases or whether that is the best way to spent your souls. Clearly it is better to spend your 325 souls to get 125% more gold than it is to spent them to get only 100% more gold.

This serves as a reminder of how to use the Mammon Spreadsheet. The spreadsheet doesn't tell you to buy Mammon, it tells you when to increase your levels of Mammon assuming that you've already decided that Mammon is the ancient for you.

And this is the real problem for Dogcog and Fortuna. Since each ancient costs more to summon than the last, these two are holding you back from buying other ancients while providing a capped benefit that is actually quite low. Right now I could summon Dogcog and buy it up to maximum level for 575 souls. Doubling my gold for 575 souls is a good idea.

But instead of doing that I could buy Argaiv and buy it to the level. Then, in the future I could continue to buy them even higher without dropping another 500 souls for my next summon.

Honestly I can see myself getting Dogcog about three ancients from now, but I have other priorities in the mean time. Probably getting Dora and Mimzee together is a far better way to increase my gold production.

Tuesday 14 October 2014

Always Simplify

When explaining the math behind Mammon in Clicker Heroes, I noted that we can convert extra gold into extra damage by raising four to the power of one over the logarithm of 1.07 to the power of 25 with a base of the increased gold.

In excel or google spreadsheets, if you are storing the number you want to convert in cell X, that is

= 4^(1/LOG(X,1.07^25))

But logarithms can be neatly simplified in a number of ways. If x is the value to converted and c = 1.07 to the power of 25, the formula in this case can be simplified as follows:



Now I can set cell Y as:

=LOG(4,1.07^25)

And my formula is, instead

=X^Y

It's pretty easy to not simplify things when you have a spreadsheet doing all the work for you anyway, but calculating one constant to raise things to the power of is much better than doing all that work each time. I could be shaving literal millionths or billionths of a second off the processor time.

Don't forget to comment and thumbs up if you read this blog to see examples of simplifying logarithms!

Friday 10 October 2014

Fixing Your Intuition - Multiplication

Yesterday I wrote about Mammon in Clicker Heroes and I made a spreadsheet to calculate how many levels of Mammon you should buy based on how many hero souls you have in the bank. I opened with a comment that because Mammon multiplied through your production, he would always be worth buying at some point regardless of how bad his cost-to-effect ratio was.

Thinking back, I'm not sure this is entirely intuitive to everyone but I feel like it should be. I'm not entirely sure this post is going to be helpful to anyone - maybe people already have the right intuition about this kind of thing - but I feel like it's worth talking about a few mental shortcuts that you can use when you are analyzing numbers because it seems to me that probably a lot of people don't have the right intuition about multiplying things together.

Anyone with a passing interest in numbers has probably observed at some point that if you have two numbers that add to a fixed sum and you want to maximize their product then you want to make the two numbers as close to equal as possible. Suppose you have ten points to divide between x and y and they are multiplied together to get some kind of result. The best you can do is 5 and 5 to multiply to 25. 4 and 6 gives 24, 3 and 7 gives 21. That's a fairly simple observation.

Suppose, though, that you have ten points to divide between x and y, and the are multiplied together to get the result, but y is only worth half as much as x? I think intuitively some people see this situation and think that in this case you would put more into x than y because it is worth more. But multiplication is commutative. If you multiply x by half of y that is the same as multiplying x by y and then taking half of that, and the same as mutiplying half of x by y. The answer is still to make them equal.

When we are multiplying things in video games, though, we are often not actually multiplying x and y, we are adding two percentage bonuses. Suppose you have 10 points to divide between x and y and each gives a percentage bonus to the same thing. Again, the best is to divide the points evenly. 1.05 times 1.05 is 1.1025, while 1.04 times 1.06 is only 1.1024. It's a tiny difference that would be bigger if the numbers weren't so small.

In this case, if y is half as effective as x, we aren't directly multiplying x by y anymore, so it isn't the same as if x was half as effective as y. If we add x% to our result and only half of y% to our result, then the best we can do is to put all ten points in x and get a 10% bonus. If we add split the points 9 and 1 then we get 1.09 plus half a percent which is only 1.09545.

But unlike the result above, this does not extend upwards to infinity. Suppose instead of 10 points to distribute we had 200 points to distribute. Now the best we can do is x is 150 and y is 50. This gives us a total of 3.125. Changing it in either direction lowers our result to 3.12495.

How about when we have a million points to divide? Now the correct distribution is to put 500050 points into x and 499950 points into y. No matter how many points we put in, the correct answer is to put 100 more points into x.

More generally speaking, if you adding points to x gives you a% more per point and adding points to y gives you b% more per point, then the optimal value for x is:

Notice that if a = 0.01 and b = 0.005 then this is y + 100 which is just the result we got above. You don't necessarily need to memorize this formula, but the important thing to realize is that no matter what the difference between the effect of x and y on the outcome, if they each give a percentage bonus, then the ideal way to divide points between them is to keep them at a fixed difference from one another depending on the effect they have. So if y is half as effective as x that doesn't mean you put half as many points in, it means you put a constant number fewer points in. If y is one one-millionth as effective as x then again, the answer is to keep them a constant value apart.


As long as the number of points you have to divide is below that constant, you should put all your points into the better option. Once it exceeds that constant, you then divide the remaining points evenly between the "better' and the "worse" option.

This should make sense intuitively if you think about it the right way. Basically by adding percentages we are multiplying 1 + x by 1 + y. If x and y are small then those 1s make a big difference. As they get large that starts to look a lot like just multiplying x by y at which point the commutativity of multiplication kicks in.

Mammon, as I discussed, was more complex, owing to the fact that his cost scales up as you buy more ranks and his effect doesn't provide a linear percentage increase.

So there are three takeaways to this post that you should use to adjust your intuition about numbers if your intuition doesn't already work this way:
  • When you are multiplying two things together, don't be fooled if one of them is only a fraction as good as the other - they should still be kept equal to maximize the result
  • When you are getting percentage bonuses from two different sources there is a threshold up to which you should invest in the better one and after that you should invest equally
  • While for things that have additive effects the question is usually "Is this good or not?", for things that have multiplicative effects the question is always "At what point is this good?

Thursday 9 October 2014

Clicker Heroes - Mammon

Summon ancients is a pretty enticing thing to do in Clicker Heroes. Odds are you should be saving up a huge bank of hero souls before you even get into summoning anything more than a couple of level ones, but hero souls are boring and ancients are fun.

Some of the ancients seems really bad, some seem really good, and then there are the ones that don't really seem that good but that you know must actually be good. Mammon is that last kind.

This post is drastically long for its subject matter, so I'm using a break. If you don't want to read a drastically long post about how I derived the results, you can scroll down to the header that says, "Results" and you'll find out how many hero souls you need to have in the bank before Mammon is worth buying.

Wednesday 8 October 2014

Wanting the Best for your Children

A story has been in the news about a couple who had a child through insemination with donor sperm. The company that provided the sperm had profiles on donors and allowed the couple to choose the donor. A mix up with a digit ended up meaning that they got sperm from donor 380 instead of 330. The couple is suing the company over the mistake.

That story makes a lot of sense and seems entirely uncontroversial. You wouldn't think it would even hit the news. If that company had a history of making such mistakes I could imagine it, especially if these mistakes were all-too-common in the industry. That's news. But one company making a mistake that results in one couple's child having different DNA than they had hoped and the resulting lawsuit seems pretty run-of-the-mill to be a story with international interest.

But the couple is white, and they live in a neighborhood that is entirely or almost entirely populated with white people, and the donor sperm they were mistakenly given was from a black man.

This is a pretty dramatic way to discover that you were impregnated with the wrong sperm, I'll admit. I'm sure this is not the first time that a delivery room has been shocked by the skin color of the baby, but in most cases the mother would at least have an inkling that it was possible. I can understand feeling extremely angry and even violated and a law suit is predictable.

But of course to have a lawsuit against a company, generally they have to have harmed you in some way. If a company made a mistake that broke your arm you could quantify the harm in a dollar figure - you might have missed work or incurred expenses as a result, you could even place a value on lost leisure. What is the harm in having a black child instead of a white one?

Well, in America I think those harms can be quantified to some degree. Trayvon Martin's family probably has something to say about the harm that comes from having your child be black in America, as could the families of the many other black men who've been killed because someone thought they looked dangerous or like "thugs." And that's just addressing the most obvious and shocking of the problems that visible minorities have. The harm of being discriminated against goes from being murdered to being less likely to be promoted all the way down to getting a dirty look from a stranger.

It's simultaneously offensive and undeniable. There is a tiny bit of irony in it as well. The couple in question is a same sex couple - how many parents have thought, "Being gay is fine, but I wouldn't want my kid to be gay because other people are prejudiced." Rarely has that phrase been uttered replacing "black" with "gay" but the logic is the same.

In a way I'll be very interested to see the outcome of this case. Imagine a court actually rules about how much money someone is owed for the harm of having a black child. Imagine someone analyzed in monetary terms the amount by which America undervalues the lives of its black citizens.

If that happens and we know exactly how many dollars a couple "loses" by having a black child instead of a white one, I wonder, who will America's black citizens sue?

Tuesday 7 October 2014

Glitch - Hidden Achievements

Back when Glitch was still a game, the Game of Thrones chat would, among other things, hunt for hidden achievements. I looked for some of these myself by doing some things that people normally wouldn't do a large number of times. Today I've looked through the code to find the hidden achievements and see if there were any we missed.

Unfortunately it looks like we didn't. I compared the list of hidden achievements to TomC's list of achievements and he had all of them except for the ones that were actually unobtainable, and for one called the "The Speedhermit." That was an achievement for getting the all time high score for longest "hi" avoidance run in a particular area. Basically if that achievement was working then people had it - someone had to have the high score. Given that neither TomC nor Sumi had it, I'm pretty sure it simply didn't work. Both of them had the achievements for dodging a "hi" sign for 311 seconds, and Sumi had the achievement for getting the daily record 547 times. The idea you could get the daily record in an area 547 times without once getting the all time record is pretty farfetched.

I was hoping to find something neat here, but there wasn't anything neat to find. I think TomC had already determined by using urls or IDs that another hidden achievement was highly unlikely for those achievements uploaded before the end of 2011, but there could have been more that were undiscovered at the end of the game.

Maybe I can work on the code for Eleven or Children of Ur and get some more interesting hidden achievements in there one day.

Thursday 2 October 2014

Clicker Heroes

I was alerted to another idle game recently and now I'm really into it. It's Clicker Heroes.

Unlike all the others I've played this one runs through flash rather than through HTML so it's not as hackable, modable or data-mineable as most of the others I've played. This also means that it isn't much use to me as a learning tool or a model to base my own code on the way Cookie Clicker was. It also facilitates the game being much more graphical than most idle games, and I think the graphics are quite well done.

I'm not going to bother describing the basic mechanics of the game because it's pretty easy to click the link above, click on things for about a minute, and get the idea.

This is a very well done idle game that finds a good place for the value of idle time vs. the value of active time. How much you can progress by not playing the game is a tricky subject for idle games. You should be able to make some progress, but you don't want it to feel as though time spent actively playing the game is worthless. You want to make people wait - since waiting is part of the game - but you don't want them to wait too much without anything happening.

Clicker Heroes deals with this very nicely by having you progress through areas gated by bosses. While normal monsters die without fighting back, bosses give you only 30 seconds to beat them before they reset. To beat bosses you often use special abilities that have cooldowns. You can set the game to automatically advance through zones but if it loses to a boss it goes back to the previous zone and goes on farm mode until you return. So if you go to work or to sleep you'll be farming up gold and will probably be able to easily clear the next boss and possibly rip through the one after that. But because zones increase in monster health and gold reward exponentially, you don't advance too far in your absence.

Some of the math behind the game seems pretty much perfect and some of it - particularly how the prestige system works - feels a little bit off, but overall I'm very impressed with this game and eager to play more and make more progress. Fortunately right now my Sandcastle Builder game is at a place where I have to idle for very long periods of time, so I have lots of time to click on little monsters.

Wednesday 1 October 2014

It's a Sport!

I've been watching League of Legends Worlds. I caught a bit live and I liked it enough that I started watching the past broadcasts. Past broadcasts actually appeal to me a little more than live because I can skip past the latter of half of uninteresting games and past some of the between game content like interviews with players, though I can't deny that there is something fun about watching things live too.

I certainly hear people mock eSports as a concept. They say, "eSports!" and other, similar things. But having watched a bunch of this, I am now 100% convinced that League of Legends is a sport. I will explain why:
  • The broadcast began 90 minutes before the first game so that people could sit at a desk and blather on about who really needs to win the game.
  • There is an analyst desk full of jocular men who predict the winner of each game before it goes live, then act like whoever got it right must have been smart rather than lucky.
  • The casters manage to say things that are both tautological and self-contradictory at the same time. "Despite the 3k lead this game is basically even except that [the team with the 3k lead] has a real advantage."
  • People quote bizarre, cherry picked statistics that sound like they have a lot more predictive power than they do. "[Team] has won three of their four games when [player] got [champion]."
  • There are player interviews that consist almost entirely of the interviewer asking, "What do you need to do to win this game? / How did you win that game?" and the player responding, "We need to play our best. / We played our best."
  • Another adult heard the commentary and thought I was watching Hockey.
These are the things that pro sports are all about. If I could make one suggestion as to how they could improve League of Legends as a sport it would be to compile even more absurd and meaningless statistics so they could say things like, "Team A really has to make up the gold difference here because statistically a team that is behind 2k gold at the 30 minute mark only wins the game 37% of the time."

This is really a sport for me too. I'm actually consistently impressed with League of Legends as a game. It feels like making good plays and getting incremental advantages matters, and playing well in late game team fights matters, but that neither of those things completely eclipses the other in importance. That's a very hard space to exist in. The picks and bans phase also manages to be very important without overdetermining the game.

The picks and bans phase also leads to a very strategically deep game. It is really cool to watch a team known for their aggression play a more passive game because of the champions they got, or to watch a team with an apparently incredible array of champions fall because their opponents realized a weakness in their pool of abilities.


I suppose all I really need now is some LoL buddies to get together with to watching big games. Beer and pizza, and all that. Now that is a sport.