The best kittens, technology, and video games blog in the world.

Tuesday, December 22, 2015

Review of The Manga Guide To Statistics by Shin Takahashi

It's been a long time since I last did any book reviews on this blog, or for that matter any other reviews. I usually just use Twitter or G+ for this as it's faster.

Here's a book I bought for the lulz - The Manga Guide to Statistics by Shin Takahashi and it turned out to be better than novelty value I expected.


The book follows a story: dad invites a cute coworker for dinner, who does some statistics at work for marketing reasons or something like that. The high schooler daughter wants to meet him again because he's cute, so she gets the idea in her head to ask her dad to get someone from work to tutor her in statistics (because she's totally interested in what dad is doing at work, honest) - and the dad obliges except getting some completely different dude as tutor. Basically it would be not out of place in any high school manga, but then again the last one I seriously followed was Aa! Megami-sama back when I was in actual high school million years ago, so what do I know.

The story is not breaking any grounds, but it's way more amusing that in any statistics textbook.

Also I'm reasonably sure that's already more plot than Mad Max: Fury Road had, and that was a really good movie.

Educational Value

The level of statistics in the book is fairly introductory, and unfortunately the book has some annoying mistakes, such as:
  • completely incorrect explanation of what it means to reject a null hypothesis (also knows as the most common error in statistics textbooks)
  • assuming normal distribution for data which is definitely not normally distributed such as normalized school test scores (also extremely common error)
Most concepts like histograms, distributions, correlations, etc. are explained relatively cleanly, but book's attempt at explaining what chi squared distribution is used for and what's the meaning of independence testing feels like a total miss, and I doubt anybody would have more than just a vague idea what the hell they are just read after that.

There's a bunch of math formulas, and I was not impressed by typography - with parentheses not being correct size to match enclosed content. Of course one could make a valid objection that this is a manga not a math textbook, and it was probably not typeset in TeX, which is fair enough I guess.

Am I the only one annoyed by bad typography here?

Of course this leads to obvious followup issue - is it even possible to teach non-Bayesian concepts like null hypothesis testing at this level beyond just "run this calculations, don't worry what they mean"?

Another problem with the book is that it probably focuses too much on the kind of silly content that predates spreadsheet software like formulas and looking up stuff in distribution tables.

Oh the books also has exercises for the reader and appendix on Excel, which are both potentially useful too.


Overall I'd say the book is probably not the most amazing textbook, but it'd be a pretty sweet novelty gift. Now non-Bayesian statistics is a particularly messy subject to teach, so I guess other books from the series might do better.

tl;dr 4/5 stars

Monday, December 07, 2015

Sublime Text plugin for highlighting Paradox file formats

Pet by !efatima from flickr (CC-NC)

Sublime Text is the best editor ever made #truefact, and as I edit a lot of text files from different Paradox games, I wanted to add syntax highlighting for that.

The package is now also available via Sublime's package manager, under name Paradox.

As Paradox files don't come with any unique file extensions (they're mostly .txt), you need to select it manually from menu at bottom right of the screen (or by choosing "Set Syntax: Paradox" from command palette).

Sunday, December 06, 2015

Fun and Balance mod for EU4 1.14.2 and Extended Timeline 1.14.1

Bow down to your king by travel oriented from flickr (CC-SA)

So who doesn't just love Paradox QA system, where instead of hiring people to QA the game before release they just release open beta without even labelling it as such, and players literally pay money to be their QA team. And then somehow many of the players are even grateful for how fast hotfixes come out.

Of course it would be totally unfair to single out Paradox here, as this seems to be more and more industry practice for most game companies.

Anyway, here's another updated version:

  • Fun and Balance for EU4 1.14.2 - Download. Steam Workshop
  • Fun and Balance for EU4 1.14.2 and Extended Timeline (0.14.1 version) - Download | Steam Workshop

  • The biggest change is that I moved to directory-based defines.lua overrides, so new version is much less likely to conflict with hotfix changes.

    I'd definitely recommend all mods to start taking advantage of this feature both Crusader Kings 2 and Europa Universalis 4 got recently - it not only reduces the need to make new mod release every hotfix, it greatly improves compatibility between different mods. Not long ago almost every mod (except for graphics-only stuff) had to modify defines.lua in one way or another, and it was biggest single source of conflicts.

    It's not even close to level of support for playing multiple unrelated mods together that games like Civilization 5 or Skyrim have, but Paradox games have made a huge progress over last few years.

    Here's Full feature list and links to older versions.

    Modern Times mod for Crusader Kings 2 - Dick Cheney release

    Go Canada Go...? by Little Cat Photography from flickr (CC-NC-ND)

    Here's new release of Modern Times mod for Crusader Kings 2 (Steam WorkshopDirect download).

    New Cultures

    There are 4 new cultures in this release:
    • Ukrainian - East Slavic group, has standard East Slavic mechanics. I'm still undecided what to do culturally with Belarus and Tartars, and for that matter all of Central Asia, so right now it's one of messier areas on the map. Adding Ukrainian culture is a step in right direction, but it's not even close to looking good.
    • American - West Germanic group, has Marines retinues and buildings, pure offensive heavy infantry
    • Canadian - West Germanic group, has Mounties retinues and buildings, with light cavalry / horse archers
    • Brazilian - Iberian group, has standard Iberian mechanics.
    They all got own list of given and family names as much as I could find them online. It's not a bug that a lot of Canadian names sound Chinese or Korean, that's actual Canadian demographics during Modern Times.

    If you have Sunset Invasion DLC disabled, that's it. You can use Ruler Designer to play as American king of Czechoslovakia, or Canadian Soviet Tsar, or Brazilian duke of Latvia.

    Sunset Invasion

    On the other hand, if you're ready for a bit more silliness, and you play with Sunset Invasion enabled, fun things could happen.

    You can of course still get vanilla Aztec / Mexican invasion. But are Aztecs the only people living on the other side of the Atlantic? I can think of at least 3 other major countries...

    To avoid spoilers I won't say anything else here. I think I've given you enough hints to figure it out. And don't think that just because you're not on Western edge of the map you're safe (check post title for some suggestions).

    Why no China?

    The most obvious followup question is why I didn't add China, or Japan, or someone new coming from the East. I'm mostly just waiting for next DLC announcement, there's good chance map will expand to East Asia, so we'll get that in Modern Times for free.

    If it turns out next DLC or two are about something else, I might add some kind of China / Japan Sunrise Invasion in the future.

    The mod is currently a one-person effort, so there's only so much I can do. If you're interested in joining development, contact my by email, or whichever other way is most convenient.

    Friday, December 04, 2015

    Fun and Balance mod for EU4 1.14.1

    Red Fox by AcrylicArtist from flickr (CC-BY)

    Fun and Balance is available updated for 1.14.1:
    Extended Timeline version is still not updated for the hotfix, but using pre-hotfix should work fine except for a small number of issues (especially compared with number of issues Extended Timeline generally has anyway):

    Wednesday, December 02, 2015

    Fun and Balance mod for EU4 1.14.0

    cat #1063 by K-nekoTR from flickr (CC-NC-ND)

    Fun and Balance is available updated for 1.14.0:
    It's just compatibility update, mod does just what it did before. Full feature list and links to older versions in case you want them are all here.

    Vanilla changed two settings to somewhere between old vanilla and old mod (custom nations max province distance and power projection from eclipsing rivals), but I'm keeping mod values as they were pretty good.

    One aspect of the game I found to be basically broken and unfixable by mods was how zones of control worked - that supposedly got a major rework in current patch. It would need a bit of testing to figure out if it's working well enough, unfortunately regardless of the result mods can't do anything to change this.

    Another aspect that demands more testing is new alliance/trust system. Fun and Balance has much higher diplomatic relations limit, and in my experience that did more to improve gameplay than any other change mod does. Higher relations limit probably interacts in complex ways with new alliance system, but only extensive testing can tell if anything there needs modding, and I wanted to have release as soon as possible.

    Oh by the way, if anybody has an idea for some mod picture for Steam Workshop, just send it over. Mod was originally zip-only so even after I set it up on Steam Workshop as well I never did the logo.


    Abby's String Theory by DirtBikeDBA (Mike) from flickr (CC-NC-ND)
    Have you ever heard a name of a card and wondered WTF is that? Or wondered WTF you're going to put into your new Commander deck? Worry no more, is there to answer all such questions you might have.

    It has more useful syntax than any other Magic search engine, cleaned up output unpolluted by foreign cards and reminder text accidentally matching the results, supports time travel to the past, can sort things by most recent Standard printing, and generally does everything I ever wanted Magic search engine to do.

    Except I didn't decide if I want to put pictures there yet, but hosting solution I decided to use makes it fairly simple, so I'll probably find some card pictures and put them there quite soon.

    As a bonus, here's some really nicely formatted and hyperlinked Comprehensive Rules.

    For some previous posts about this: one, two, three.

    The website should integrate with multiple search engines support in all major web browsers. If you ever visited it, your browser should let you search for cards by just typing "" or something similar.

    As for the name, I originally planned a more conventional one, but everything was either taken or way too long. Then I discovered newly opened .wtf TLD, and that was strangely appropriate for this project.

    Contact me any way you want with bug reports and feature requests - I'm pretty sure I'm available on all social networks ever invented. I have a few ideas for cool new things to add to the site, but let's start with what's there. I tend to respond to such very quickly.

    I'm not sure how well servers will handle the load. They should be just fine, but if it turns out they can't deal with it, I'll take a look at making things faster or getting bigger option from my hosting provider.

    Tuesday, December 01, 2015

    CK2 Modern Times: Greater Punjabistan AAR

    Post 1 - Originally published on Google+ on 2015-11-16 10:11:34 UTC

    Greater Punjabistan: Part 01: 1815-1827: Family is Hell

    Somehow I haven't played any Indians yet, and Modern Times has some interesting scenarios. Let's start with 1815 maharaja Ranjit Singh of Punjab (I even turned on local names for it). India starts about 1/2 British, 1/4 Maratha, 1/8 Mughals, 1/8 everybody else (Punjab, Sindh, and Portuguese Goa). The goal is to unite absolutely all of India and possibly a good chuck of lands West of it.

    We start as 34 year old ruler with 3 underage kinds. 10/16/5/9/4 isn't awful, but ambitious craven brilliant strategist is a weird combination.

    So time to arrange some marriages:

    • maharaja Ranjit - Mogubai Bhonsle, 27 year old sister of samrat pratap Singh of the Marathas
    • 14 year old son Kharak - princess Dandimahadevi, daughter of maharaja of Orissa (under British)
    • 13 year old daughter Ramo - prince Anavota, heir to Telingana (under British)
    • 7 year old son Sher - we'll figure something out

    I'm guessing there's decent chance British part of India will fall apart soon enough.

    Other than that build observatory, choose patron deity Ganga (+1 stewardship -1 martial), and tiger hunt time to maybe lose craven.

    That didn't work, so let's prove we're not craven some other way - like holy warring Afghanistan, Sindh, and Mughals at the same time.

    Troop numbers are pretty good:
    • Punjab - 8.4k
    • my ally Marathas - 10.7k
    • Afghanistan - 8.4k (and wrecked by Persian 11k)
    • Sindh - 6.9k
    • Mughals - 11.7k

    Counting every 1 Hindu as 2 Muslims we have an slight numerical advantage.

    And then I discovered the first problem - apparently all those 20+ martial mayors in my realm - I can't appoint any of them as commanders as they're vaishya caste not kshatriya. OK, so apparently the nerfs for everyone non-Muslim continues. Fine, I'll spend my initial gold stash on some mercs, especially since Mughals did the same.

    Afghans invaded, ignoring Persia completely, so I took them out, while Marathas crushded Sindh. Mughals just happily stood there with 15k stack.

    Anyway, Afghanistan got crushed, so I got two counties of Punjab they had. And then I noticed my oldest son is of Brahmin caste, because my script was not very smart about any kind of family caste consistency... So I can give him a temple, nothing more.

    And unfortunately Marathas had rebellion, so they abandoned almost finished siege of Sindh, and I was really low on money, so I had to disband mercs.

    There was also a problem with one butthurt duke who had almost as much power in the realm as me - I might be craven but fortunately I'm not content, so he had to go. And his son. Unfortunately his daughter was no more accommodating, but let's leave her for now.

    A much bigger crisis emerged - samrat pratap of Marathas died, and his 0 year old son does not think our alliance is valid even though I'm married to his aunt...

    Mughals figured out that's good time to strike, and without merc or allies, I really couldn't do shit, so I gave them 700 gold plus some prestige and karma as war reparations. Bad times.

    I somehow got myself out of debt, and managed to trim Marathas ruling family to just my wife, her brother, and second brother who was a brahmin and out of line of succession. Oh here's some fun - I made a baby with my wife who's heir to Marathas and an imbecile -8 to everything. Oh come on!

    Well, at least maharaja of Sindh died, so I can go there and remove some kebab.

    Oh and I discovered some real bullshit - I can no longer console switch to my landed son, arrange marriage as them, and switch back, somehow betrothal request would get canceled. So my son and heir Sher married rani Nihal of Gandhara who's #1 on my hit list - cancelling his previous betrothal and ignoring my console switched requests. For fuck's sake. It's India, it's feudal, marriages need to be double-arranged!

    Well, spy focus, and try to murder her. Well, that failed, only getting her wounded. Oh, she's plotting to kill me? Let's arrest her. Oh she even rebelled, how cute.

    Anyway, now the situation is:

    • my oldest son Kharak is a priest and out of succession - fortunately he's married to daughter of king of Orissa which just got independent, sadly not before going Protestant
    • my daughter Ramo is married to prince of Telingana (also unfortunately Protestant), which recently went independent
    • my second son Sher is married to this traitor bitch Nihal, who's in my prison, unfortunately they managed to had a baby daughter before I could intervene - so currently her daughter is in direct line of succession after me, which is disgusting. If I execute Nihal he might remarry and find himself someone nice - or some lowborn dwarf just to spite me.
    • my third son Bhaimani with Mogubai of Marathas is in line to inherit empire of Marathas - because of my plotting my brother in law never went out of hiding to marry. Unfortunately he's an inbecile and there's pretty much no way to overcome -8 to everything, -30 attraction, -10 vassal opinion, and -3 personal combat skill just to be sure. Mogubai is 39 years old and we probably won't have any more reasonable children
    • my fourth son Bhagwant with a concubine is currently not causing any problems, but he's only 1 year old so let's give him time.

    So that's the mess. I thought I'd have trouble with Muslims, instead it's my family which turned my life into hell. If only Mogubai had one more son...

    I'm tempted to make Bhaimani my heir anyway, because Sher is really pissing me off and politically that would me huge chunk of India. All he really needs to do is have some non-imbecile babies before he dies to first plot.

    In other news:

    • Portugal tried to holy war Marathas - it even seemed that they might succeed for a while as Marathas were busy with rebellion, but they ultimately failed.
    • Ottomans lost Greece to crusade led by king of Sicily
    • I'm trying to get castle of Sunni holy order. Apparently ticking warscore doesn't work for such wars, so I'm at 84% and I'm not terribly interested in going all the way to Arabia to their nearest castle.

    1815 start

    Post 2 - Originally published on Google+ on 2015-11-16 13:38:54 UTC

    Greater Punjabistan: Part 02: 1827-1839: Succession is still a mess

    So Nihal goes straight into oubliette with her duchy title revoked. She died soon afterwards, and now my granddaughter rules her 3 counties (I'm tempted to seduction focus her as soon as she comes of age, she's gay for some extra sin). Now if only Sher would remarry, hopefully someone less objectionable - and he got himself a lowborn Buddhist wench with no redeeming qualities.

    Seriously game, why can't I arrange marriages for landed children?

    Anyway, I'll try making some babies with my wife. I switched to family focus for that +25% fertility bonus to maybe have one more baby before my wife gets too old. I made her my spymaster so she'd get a better ambition - and she got "have a daughter". I gave her expensive gifts during Diwali festival as that's 30% chance of her becoming my lover.

    Unfortunately my wife decided to instead cheat on me with my chancellor, who got imprisoned and executed for it, but I still need that heir, so she's getting away with it for now.

    Finally after spending way too much money on festivals and gifts, we became lovers, but at age of 42 she's a bit old... And all got for my trouble was a daughter Lachmi. By the way Indian names are really cute somehow.

    Well, Sunni uprising happened, so I declared wars on Mughals and Afghanistan, called Marathas and Telingana into it (Orissa wouldn't even consider it)

    OK, time to focus. Heir to Marathas is nephew of current emperor. His brother was disqualified as temple holder, but he isn't.

    • bribe some vassals so everyone likes me
    • pass absolute cognatic
    • nominate Lachmi as my successor. Being a girl is bad, still better than being a drooling idiot.
    • press my wife's claim for Marathas - they have another independence rebellion over there and it's just regency

    During the war my wife's brother died, so it was war against his nephew. And a fun race - I was leading armies (he had more than me, even with mercs), and my wife and spymaster was leading spies.

    He did what AI loves doing, hired Hindu holy order against me, and with his illusory numbers decided to charge.

    Well, so my wife got the title, unfortunately our imbecile son is her heir - and I got crown authority revolt because everybody's pissed about raised levies and changed succession laws.

    Unfortunately the rebellion bugged out, rebel leader lost his title, and somehow my son duke of Bhakkar and another count became independent. The count accepted vassalization, but my son didn't. I can't stand this bullshit (how many patches did they introduce temporary faction titles? why are they still bugging out on regular basis) so I got him back by console.

    I repeated the same trick with raj of Multan - take away traitor's title, throw him into oubliette where he dies of natural causes, then give title back to his heir, for instant +100 relations.

    So, line of succession to Marathas is:

    • imbecile son Bhaimani - amazingly he's 1/10/3/0/0, I managed to get him competent at one thing at least
    • imbecile son's equally imbecile son Kharak
    • my daughter and heir Lachmi

    I'm seriously tempted to eugenics the hell out of this situation. If Bhaimani at least had a non-idiot heir...

    But first I needed to finish assassinating the rest of Bhonsle family. There's still two kids with claims - former emperor's nephew and son of former emperor who seems to have been born posthumously.

    Oh and Marathas are somehow agnatic-cognatic gavelkind now... I'm pretty sure they started primo.

    Post 3 - Originally published on Google+ on 2015-11-19 16:16:32 UTC

    Greater Punjabistan: Part 03: 1839-1850: Sorting Out Succession

    First, I eliminated two remaining nondynastic underage claimants to empire of Marathas, so now it was just a question of which dynasty member would inherit.

    And that left me with a huge problem, as line of succession to the Marathas looked like:

    • my imbecile son Bhaimani
    • Bhaimani's imbecile son Kharak
    • Bhaimani's healthy daughter Amro
    • my daughter and designated heir Lachmi

    Unfortunately apparently I can't plot against my children, so I couldn't just kill everyone and had Lachmi inherit it all - and I can't designate anyone except my children as heir, so I couldn't do anything cute like designating Amro. Oh well, I'll deal with it when time comes.

    I passed time making various minors who case out of shattered Afghanistan into my tributaries.

    My wife got into wars against various Protestant minors who came out of British India's shattering, losing one duchy and getting another. Protestants are also sitting on ticking warscore for Portuguese Goa, but it will take them a while.

    And that leads to modding question - is there any way to block this demand conversion? I don't want Indian vassals to hate British queen as that would mean India instantly shattering, but I don't want them to love her so much they accept conversion. Right now I got worst combination - everybody converted, then shattered anyway. Thresholds for accepting conversion and for not joining factions are just too close to each other. Unfortunately this is one of few special interactions CK2 had before they switched to more moddable system, so it's very painful to mod anything here. I could make them tributaries instead of vassals, but tributaries don't work sensibly (they never break by rebellion, but always break by succession).

    I'll leave modding for later. It's really time to fix succession or it will take forever to get anywhere.

    • my imbecile grandson Kharak needs to go, I can plot against my own grandchildren, so that's easy, except my attempt got discovered (but not actual murder).
    • my imbecile son Bhaimani, intrigue focus, spy on, abducted, oubliette - took him 5 years to actually get ill and die there

    And that somehow put my daughter Lachmi over Bhaimani's daughter Amro in order of succession. Seriously, succession part of this game makes no sense, even on primo. So as far as everybody is concerned there was zero kinslaying involved.

    So now it's just waiting for succession. I'm 68 and recently ended illness. My wife Mogubai is 61 and in hiding because apparently people try to plot on her life.

    Lachmi just turned 17 and married younger son of khan of Xinjiang matrilineally - he has weak claims on both of Xinjiangs kingdoms, but that's a bit far, and it would be very difficult to send armies there.

    Elsewhere what little was left of Ottoman Empire went Zikri, and Sunni caliph is some OPM relative of Ottoman emperor. This is the weakest performance by Sunnis I've ever seen- they're getting wrecked by Catholics, Shias, Zikri rebels, even Ibadi Oman. It was due to losing tons of holy wars and decadent caliph, which together stacked their authority to 0% somehow, making everyone go heretic.

    Hindus are not doing too great, we only hold two holy sites, but if Punjab and Marathas unity, that's going to be half of India, and it shouldn't be too hard to cleanup Protestant minors.

    Post 4 - Originally published on Google+ on 2015-11-19 18:37:17 UTC

    Greater Punjabistan: Part 04: 1850-1857: Seduction Based Government

    I want succession to come as quickly as possibly, so rulership focus and hope for depression.

    That did very little, but Ranjit died at age of 72, leaving Punjab to 21 year old Lachmi, whose popularity was:

    • -10 female ruler
    • -10 female heir (her niece for some reason)
    • -16 short reign
    • -10 medium crown authority
    • -20 large feudal tax
    • -20 incestuous adultress (for 20 years)

    Seriously, my heir managed to get into incestuous love affair? I understand me doing this, but my heir on her own, and I can't even see with whom?

    Well, that won't be easy. My husband's branch of family lost Xinjiang, and his stats were miserable, so I got him killed, and went seduction focus.

    I got pregnant by some kind of miracle with game having no idea with whom (before anybody even got seduced, but quite some time after husband got killed). That's the first time I see this. I guess it could be delayed pregnancy event from before I got in power?

    And of course there was inevitable lower crown authority revolt, which I crushed with my mother's help.

    My mother died mid-revolt, I got male heir (+10), Master Seductress trait for +50 attraction opinion with all male vassals, +25 crushed major revolt (in all my territories, not just Punjab), and I made one of major rajas my lover, stabilizing the realm very effectively.

    I also got my karma to -318 due to constantly getting caught in extramarital affairs, but apparently Gods consider +100 winning a holy war and -100 getting caught in illicit sex exactly karmically balanced. That's a suggestion how to proceed.

    Now there's an awkward problem, in that we're the only Hindu realm in the world, and the only Buddhist one is Xinjiang. No Jains. Every single country in India other than us is Protestant, so I can just holy war them quick.

    I'm wondering if I should maybe change to a different Indian religion, as being a Hindu doesn't seem to have much content so far. Other than Tiger Hunts and Diwali Festivals (which allow spending money for 30% chance of making spouse a lover, very useful) instead of Summer Fairs and Feasts, it's pretty much the same as any generic religion. For something that slows that the game so much I expected a bit more.

    Post 5 - Originally published on Google+ on 2015-11-20 12:43:33 UTC

    Greater Punjabistan: Part 05: 1857-1866: What Would Buddha Do?

    I thought about never marrying Lachmi to anyone, but annoyingly bastards have no caste, and that's a big deal for Hindus.

    Oh well, as realm was united by everybody being really hot for Lachmi, I gathered the troops and attacked Muslims of all kinds in Central Asia and East Persia. Strong Persia would be huge pain when inevitable rebellion comes once Lachmi hits the wall at age of 45.

    The biggest problem was coordinating all that, as total Muslim troops were more numerous than total my troops, I had to divide my armies due to supply limits, and there are apparently no rivers there to move quickly.

    I got a white elephant as a gift - which obviously was not meant to be accepted if you have good sense. And obviously I was getting one bad event after another because of it. I think I lost about 2000 gold on it. I bet that's where the Jews gets their money - white elephant business.

    The end result of white elephant was that I got independence revolt once my treasury was depleted to basically zero, and half my troops were gone from war against Persia. Well, ransoming traitors out was one way to get that white elephant fund back.

    Well, there was important business to fix. Marathas were agnatic-cognatic gavelkind, Punjab was true-cognatic primo, there's no way to sync them in one lifetime, but I could bribe vassals to let me switch Marathas to agnatic-cognatic primo at least. The only reason I went true-cognatic with Punjab was because my older brother was an imbecile.

    My nephew successfully used seduction focus on me - how could I refuse family? I guess I should switch religion to Zoroastrian or something, why even pretend? There are no Zoroastrians left in Modern Times? I guess Buddhist will do just fine.

    The choice is between Mahayana (+5 vassal opinion), Vajrayana (+1 health), and Theravada (+1 learning). Health bonus seemed much stronger than other two.

    Nearly all of my vassals converted almost right away with me - demand religious conversion is ridiculously overpowered like that, I wonder if it wouldn't be better to just disable it outright if I can't easily mod it to require a lot higher relations (closer to +80 than current +36).

    This leads to fairly unfortunate situation:

    • Buddhist get 1 county holy wars, which are fairly miserable
    • Everybody in India outside my empire is Protestant, and won't marry into my family (----- political concerns, even my damn nephew maharaja of Telingana won't marry his children), and claimants won't accept invitation
    • Internally empire is very stable, with little to do
    • Hindu or Buddhist, I'm not really getting any special Rajas of India content. Am I doing something wrong, or was there simply never much to do as Indian?

    Post 6 - Originally published on Google+ on 2015-12-01 08:43:26 UTC

    Greater Punjabistan: Part 06: 1866-1878: Scripted Endgame

    I wanted to have India campaign, but everybody went Protestant so it's just annoyingly like Europe all over again. Well, first fix, demand religion cost increased from 0 to 25 piety like it used to be in old CK2. I'd actually much prefer simply increasing acceptance threshold from >+35 to like >+75 or so, but that doesn't seem possible to mod.

    Unfortunately since at this point damage was already done, I also wrote a quick script to reverse it and convert every Protestant in India to randomly one of 3 Indian religions. That leaves Sunni Mughals and a few Protestant Englishmen (Portuguese Goa fell long time ago). I should have done that ages ago.

    Oh and while I was modding it, I already increased allowed number of commanders by a few. Game claims you can always have your marshal lead your troos, but that's a lie. Now dukes have 6 commanders (so 2 stacks), king 9 (so 3 stacks), and emperors 12 (so 4 stacks), meaning less silly reassignment. 8 commanders at emperor (so 2 stacks with all commanders and one with 2/3) was just silly.

    So, let's do some Indian affairs. Now that people were of my religious group, some marriage alliances were possible - and I could help another batch of Indian minors (mostly Bihar) get independence from Britain. I'm not sure they needed that, they seemed to be winning even without me, even if not very decisively.

    I got reduced to county level holy war, so I got Afghanistan's last county. And that's such a bad holy war it didn't even unland Muslim barons, I had to revoke them manually - or such an awesome CB if you want to milk them for +100 crushed for major revolt.

    Simultaneously with this, I pressed someone's claim to duchy held by Mughals - and somehow I couldn't land him with my new Afghan lands. He's casteless Hindu, so he can't get granted any land, even though I'm Buddhist and don't care. Except he can get his claims pressed, so it makes about zero sense...

    Well, other than that I just made a bunch of South Indian minors my tributaries. They were much stronger than they had any reason to be, and fighting in India is significantly harder than in Europe with lower base supply (a lot of jungles - at least it doesn't get winters) and longer average distance to coastline. At least I've been beelining military organization, so that's some decent supply limit bonus.

    I got kingdom of Assam by subjugation. I tried to get kingdom of Tamilakam by dynastic scheming, but that was taking forever so I just invited some claimants to kingdoms of Orissa, Telingana, and Tamilakam, and went for it.

    At this point India was completely dominated by me. There were a few minor things left over, but since challenge was nonexistent and I still wasn't getting any fancy Rajas of India content, I decided to just finish the campaign.

    Muslims are so wrecked Miaphysite Ethiopia took their holy sites

    Close enough to united India

    SQL-based Game of Life refactored

    a185991 sahara-2 by The.Rohit from flickr (CC-NC)

    A couple weeks ago I posted SQL-based Game of Life. It was rather ridiculous, with 3-levels of VIEWs, one of them including LEFT OUTER JOIN.

    I revisited the problem for some refactoring and it turns out solution is far simpler.

    Rules of game of life

    Standard rules are:
    • cell's neighbours are all cells next to the cell
    • cell is not its own neighbour
    • cell becomes live if it was alive and has 2 or 3 live neighbours
    • cell becomes dead if it was dead and has 3 live neighbours
    But I thought, what if we tweaked them a bit so every cell is considered its own neighbour as well? Mathematically tweaking definition:
    • cell's neighbours are all cells next to the cell
    • cell is its own neighbour
    • cell becomes alive if it was alive and has 3 or 4 live neighbours
    • cell becomes dead if it was dead and has 3 live neighbours

    That might or might not lead to simpler query. But those numbers are weirdly close, what if instead we did this:
    • cell's neighbours are all cells next to the cell
    • cell is 0.5 of its own neighbour
    • cell becomes alive if it was alive and has 2.5 or 3.5 live neighbours
    • cell becomes dead if it was dead and has 3 live neighbours
    Wait, doesn't that simply mean...
    • cell's neighbours are all cells next to the cell
    • cell is 0.5 of its own neighbour
    • cell becomes alive if it has between 2.5 and 3.5 live neighbours
    So it turns out we don't need to check alive/dead at all, leading to really simple code to which I'll get soon. Especially if we multiply weight by 2 to avoid floats - so cell counts as 1-weight neighbour and all cells around it count as 2-weight neighbours - and then we look for any total weight between 5 and 7.

    Does that work with other rules?

    For a while I thought it's a hack for standard Game of Life, and it wouldn't generalize to other types, but it totally would. If for example live cells stay live at 1, 6, or 7 neighbours, and dead ones at 2, 4, or 8, then we check for total in [3,13,15,4,6,16]. Or you could weight them at 10/1 instead of 1/2, then rules would be in [11,16,17,2,4,8].

    I didn't use this generalization is the code, as code is a tiny bit simpler for standard case, but it's really tiny difference.

    The code

    CREATE TABLE life(
      simulation string,
      generation int,
      x int,
      y int
    CREATE TABLE neighbour_coordinates(
      dx int,
      dy int,
      weight int
    INSERT INTO neighbour_coordinates VALUES
      (-1,-1, 2),
      (-1, 0, 2),
      (-1,+1, 2),
      ( 0,-1, 2),
      ( 0, 0, 1),
      ( 0,+1, 2),
      (+1,-1, 2),
      (+1, 0, 2),
      (+1,+1, 2);
    CREATE VIEW alive_next_generation AS
        generation+1 AS generation,
        x+dx as x,
        y+dy as y
      FROM life
      JOIN neighbour_coordinates
      GROUP BY simulation, generation, life.x+dx, life.y+dy
      HAVING SUM(weight) BETWEEN 5 and 7;

    Driver being exactly as before. That's ridiculously simple compared with initial solution.

    MongoDB rant

    And then I thought - how about doing this in MongoDB? And oh my god, that aggregation pipeline...

    MongoDB JSON-document model is the sweetest thing ever in the world of databases, and it's interface is OK for simple queries, but it seriously just needs a real query language. So far every time I had to do anything nontrivial in MongoDB I did it in Ruby on application side, and I'm not unusual here.

    SQL world is on the other end of the scale, with literally the worst document model ever invented, but fairly adequate query language. I wouldn't call SQL "good", but compared to monstrosities required by mongo for even fairly straightforward stuff...

    Did anybody ever manage to get best of both worlds with some document model based on JSON or similar, and adequate query language?

    I know some RDBMSs have JSON boltons but they're half-supported bullshit, and SQL is just adequate in comparison to what Mongo requires, not by any objective standard, so I'd rather not get there.

    Some NoSQLs like MongoDB for some reason feel they don't need any kind of real querying language, just some $-trees, but that doesn't get anywhere close to adequate even for rather simple uses and it just moves querying to application side hacks.

    I guess solr/lucene is sort of doing both sides decently, but it's a fairly special kind of NoSQL, and for many reason difficult to use as primary database. (don't even ask what kind of hackery I've done with it over years).