taw's blog

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

Thursday, February 23, 2023

Europa Universalis IV crownland and negative absolutism bug

This bug can really mess up a campaign, but it's pretty much unknown to the community, as it's hiding behind a few layers of obfuscation.

Land shares

The system is conceptually very simple. Every estate, as well as the crown, have some amount of land.

When new land is conquered, it's distributed to everyone proportionally to their influence. For each estate, its influence is displayed directly. For the crown, influence is 60% + absolutism.

So here's an example. You have 200 dev, distributed as:

  • crown 30% - 60dev
  • nobles 35% - 70dev
  • clergy 20% - 40dev
  • burghers 15% - 30dev

Now you conquer 100dev worth of land, it's one of the first two eras, and let's say influence is 60% for clergy, 40% for nobles, and 40% for burghers. New numbers should be:

  • crown - 60dev + 30dev = 90dev = 30% (+0.0%)
  • nobles - 70dev + 20dev = 90dev = 30% (-5.0%)
  • clergy - 40dev + 30dev = 70dev = 23.3% (+3.3%)
  • burghers - 30dev + 20dev = 50dev = 16.6% (+1.6%)

In theory, it's all very straightforward.

It means it's very difficult to have high crownland share before age of absolutism, and countries with more estates have worse crownland situation, but that's just how the system works.

Also in-game tooltip "Crownland can be gained when: Conquer Land when having less than 60% total influence of all Estates" is a complete lie. This isn't even remotely how it works. It is baffling why they put such completely false information in the tooltip, as the real system is very straightforward.

The Bug

Anyway, the bug. Crown influence is 60% + absolutism, so before age of absolutism it should be just 60%. However it is not. The game still keeps track of absolutism in earlier eras, and it can be negative.

If you engage with the estate system, and give away a lot of privileges, you can spend the first two eras at massively negative absolutism, and all the crownland calculations will be broken.

Let's start as Venice - just doing the bare minimum of 3 mana privileges, and Religious Diplomats.

This brings your Max Absolutism to -56.12, so crown influence instead of 60% will be just 3.88%, and you'll get almost zero crownland from conquests.

It gets a lot worse if you get your max absolutism below -60. Then your crown influence becomes negative, and not only the estates get all the newly conquered land, but also whenever you conquer any land, you give them some of your existing lands as well. This is extremely pathological, but for example Venice gets there with just one more privilege.

There's one more complication, as the game recalculates absolutism only if you perform some absolutism affecting action (most commonly changing local autonomy), and the check (vs 0 or vs max absolutism) seems to depend on that action being absolutism increasing or decreasing.

At least you can recover from that if you increase your Max Absolutism, and then do an appropriate absolutism-affecting action, but there's no easy way to see if it worked in the game (in the save game file, it's "absolutism=XXX" line).

If you're at war, and choose peace terms that would gain you some land, you can see land share changes in the tooltip, and from it you can see if it's broken or not.

Play workaround

If you play a monarchy, and don't grant many privileges, you probably won't be affected, as your Max Absolutism should remain positive.

If you play a republic (planning to go monarchy before age of absolutism), or grant a lot of privileges (planning to revoke them before age of absolutism), this will mess up your game due to the bug. If you do both, it will mess up your game even worse due to negative crownland influence.

So the best way to play is by being extremely careful with Max Absolutism. You can view it in Government tab, in Country Modifiers. It's fine if it's just +0, as long as it never goes negative.

The obvious strategy of "just give all privileges on game start, then conquer something to regain crownland" only works for monarchies. If you try it as a republic (or as a monarchy that granted a lot of privileges) you'll get nothing out of it. And if you get to negative crown influence, you won't be able to even recover by seizing land, as every conquest will mean crownland giveaway.

If you go negative Max Absolutism for a while, but then recover (either to positive, or to less negative value), you'll need to do some kind of recovery by absolutism-affecting action. If you're at risk, verify in peace deal tooltip that land share changes are what they should be.

Mod workaround

Mods can work around this issue by giving all countries +1000% max absolutism in the first two ages with a triggered modifier. This was Max Absolutism will never be negative, until you get to the age where it matters. This way players can play the game normally as if the bug wasn't there, and it won't affect anything else.

I didn't test if the bug is still there in the last two ages, but usually at that point you'd try to have high Max Absolutism anyway.

What Paradox should do

They should make negative absolutism impossible, and that would fix the whole issue.

Sunday, February 19, 2023

How to fix Europa Universalis IV late game problem

This is not a rant post, this is a solutions post. However before discussing the potential solutions, it is important to understand the problem well first.

Late Game Problem

In theory, Europa Universalis IV covers the time period from 1444 to 1821. However, in practice, most players never reach 1821 or simply speed-5 through the late game for the achievement (which is easily attainable, but only 9.4% of players have earned it, due to tedium).

This raises two questions:

  • Why don't players continue to play until the end date?
  • Why don't players simply start the game in a mid/late game bookmark?

Neither of these is inevitable for a grand strategy game. For a contrast I'll be coming to a lot, Crusader Kings 2 has neither of these problems. It can be started at a variety of dates, with 4 official start dates (769, 867, 936, 1066), and a lot of later start dates that are all quite good, and full of different interesting characters.

And while "playing to win" would make a Crusader Kings 2 fairly easy in late game, the game nudges you to embrace "roleplaying". There's a lot of things to do other than expanding, and especially if you're a less experienced player, holding on to what you conquered is a very nontrivial matter, so your realm will ebb and flow naturally.

So let's first explore these two questions, and then look into some potential solutions.

Why don't players continue to play until the end date?

Europa Universalis IV is a game about a country expanding and becoming stronger. When a player's country is weak, expanding can be a challenge. But once a player conquers some land, it's done. There is no ongoing challenge in holding onto lands that have been incorporated into the player's realm and the resources they provide.

Expanding comes with many challenges, such as:

  • getting better casus belli
  • improving your diplomatic position
  • declaring wars where your allies join while enemy's allies don't
  • winning wars
  • getting best peace deals
  • managing aggressive expansion
  • preventing coalitions
  • managing truce timers
  • managing overextension
  • getting the necessary mana for peace deals and coring
  • dealing with one or two waves of nationalist rebels
  • converting conquered lands
  • reducing autonomy in conquered lands
  • managing governing capacity
  • building necessary buildings in conquered lands (since the AI is awful at it, no matter how many times patch notes claim to have fixed it)

Once the player conquers a province without triggering a coalition, cores it, reduces its autonomy, and either converts it or accepts its infidel ways, it's done. It will never cause any problems.

This isn't the only design option available. In Crusader Kings 2, each conquered province beyond your small domain is controlled by a vassal and then their heirs. These vassals could still cause trouble, even if their grandfathers were loyal to your grandfather. This is particularly true during succession. There are many tools available to help manage this issue (and it maybe got too easy in late CK2 patches, early-version CK2 and early-version CK3 are both harder for a less experienced player), but it remains a real concern. Just try it yourself - load up a saved game of your Restored Roman Empire in observe mode and you'll likely see that the empire won't survive two AI successions. In a similar scenario in EU4, however, the AI wouldn't lose a single province.

Returning to Europa Universalis IV, the main objective of the game is to increase your power, mainly through territorial expansion. This leads to a situation where the player becomes more and more dominant at a pace that is much faster than what the AI can match. As a result, the game's challenge level decreases over time. EU4 does offer a few alternative means of increasing strength, such as reducing autonomy, converting conquered territories, constructing buildings and monuments, boosting development, and increasing crown land. However, these methods also result in the player's rapid growth and superiority over the AI.

How EU4 Attempts to Address the Issue of Easiness

The most straightforward approach to addressing the issue of a game being too easy is to increase its difficulty. Europa Universalis 4 has multiple systems in place to do this.

The main one is choosing a more or less difficult starting country, with some countries providing a lot more challenging start than others. Players can also set specific goals for their campaign, along with restrictions such as no restarting or no loans. Although the goals are mostly centered around expanding and becoming stronger, some paths to achieving these goals are more challenging than others. Now this isn't Crusader Kings 2 where goals like filling the entire College of Cardinals with horses or collecting every major religious artifact are legitimate campaign ideas. Pretty much all the potential goals in Europa Universalis 4 involve expanding and getting stronger, some routes are just more difficult than others.

And finally there's the very poorly implemented difficulty slider. Most people play on Normal, where the same rules apply to players and AI, except for a few small AI cheats and hardcoded bonuses for lucky nations. Hard difficulty gives AI nations minor bonuses, and Very Hard gives them much fairly big bonuses.

However, all these systems get it completely backwards. Choosing a difficult starting country or playing on Very Hard can indeed make the early game challenging, but as the campaign progresses, the difficulty drops significantly with each passing decade. For example, playing as a no-ally Hisn Kayfa on Very Hard might be challenging in the early game, but once the player has survived and won a few wars, there will be no more significant challenge left in the game, and a player skilled enough to do so might just as well quit by 1500.

Finally, the game also tries to address the issue by railroading certain AI countries to expand quickly, with a long list of bonuses, including the lucky nations bonus. This does have an impact, but it leads to repetitive and boring mid-games, such as the inevitable Otto-Blob end-game boss. After encountering the same predictable outcome repeatedly, most players learn standard counters, such as the "Ally Austria and Poland No-CB Byzantium" opening.

Could holding to what you have be a challenge?

I don't think there is any way to make holding onto what you already possess be a significant challenge.

I tried many such experiments. For example, I tried to massively increase unrest to see if rebels would achieve anything, only to discover that leads nowhere.

Using the formulas from the game's wiki, let's consider a country with 10 provinces of +1 unrest each. After 100 years, it can expect around 5 rebellions, which is a minor annoyance.

So what happens if we increase the unrest level to an unrealistic +50? The number of rebellions per 100 years only increases to 9, and individual rebellions wouldn't even be any stronger. This is mainly due to "Recent Uprising: −100 unrest for 10 years modifier", which trivializes the whole system by hard capping rebellion frequency regardless of unrest.

But it's not even the only factor. Without Recent Uprising modifier, rebellion counts would be 10 per century and 90 per century respectively, that is 50x unrest translating to 9x rebellions. The formulas themselves are still nonlinear, with rebellions needing 10 monthly ticks to happen, and tick chance is capped at 75% per month, so even nearly infinite unrest translates to less that one rebellion per year without Recent Uprisings, or to one rebellion per 11 years with Recent Uprisings.

The only other consequence of all that extra unrest is longer recruitment time. Somehow unrest in provinces doesn't carry any other penalties. You still get as much money, manpower, and everything else from a rebellious province as one where peasants fully love you.

That's not to say EU4 rebellions are never a problem. Most notably going over 100% overextension directly affects rebellion formulas, resulting in much stronger rebellions. Heavily scripted event chains like Ming Crisis or Dutch Revolt can also cause a lot of problems, at least for the AI or for a player not aware of easy ways out they usually have. And due to the way rebellion formulas scale, rebellions can be really deadly for tiny countries, especially for Japanese daimyos, as even a small rebellion can be bigger than their whole national army.

For most countries, as long as they stay under 100% overextension, rebellions are so insignificant they might just as well not be in the game.

Other ways to delay the inevitable late game easiness

If you really wanted to make the late game difficult, there are a few more options available through mods.

You could slow down expansion. The game already throws so many obstacles to expanding, why not just tweak some numbers? Increase AE, increase coring costs and time, increase province warscore cost, and so on. Weirdly a lot of players do it to themselves already by taking terrible idea groups, but a mod could do a lot more.

This somewhat delays the point at which the game becomes trivial, but there's very little to do in EU4 other than expanding, so you won't actually play longer, you'll just play at higher speed while waiting for various timers. If these same nerfs fairly apply to the AI as well, it won't even be all that effective at making the game more challenging.

In older patches it was possible to make expansion a lot more challenging by increasing number of diplomatic relations. The easiest way to become stronger is by seizing land from a weak country with no or only weak allies. Giving everyone a few more diplomatic relations slots makes it far more likely that someone strong would come to defend your potential victim. However, in recent patches allies are so good offensively I don't think this is even helpful.

Another thing to try is allowing conquest but reducing rewards from conquest by nerfing blobs. Paradox recently tried that with governing capacity system and 90% minimum autonomy in territories, but for most countries governing capacity limit is very generous. With trade companies being nearly as good as states, and courthouses being so cheap to build everywhere, at least with default values it doesn't really work.

One fairly obvious approach I haven't seen attempted yet is to make anti-blob bonus simply increase with time. This could simply be a flat bonus to every country, so small ones would benefit the most. It might start at nothing in 1444, but by 1600 every independent OPM gets +10 force limit, +10000 minimum manpower, and so on. Blobs would get the same bonus, but it would proportionally matter a lot less. This should be very simple to implement, and Extended Timeline already has a kind of era-based bonus system, it's just not used for balancing there. The trigger could be either calendar year or a specific technology.

There are a few additional things to consider - subjects probably shouldn't get this bonus, or get a proportionally lower one, or it would benefit strong countries with subject swarms too much. But tributaries and colonial nations should still get it, as they should be able to fight independent enemies fairly. And perhaps native OPMs shouldn't get such a bonus, or they'd swarm a colonial nation. And so on.

An interesting idea from Crusader Kings 2 (I keep repeating myself, but that's a related game that does so many things right) is giving random tiny countries ridiculous temporary bonuses at random during the game, so you'd have a random regional threat punching far above their size for a while (like IRL Brandenburg). I tried to mod that for EU4, but it really didn't do much, at least for values I tested. I've heard Anbennar does something like that with Great Conquerors, going completely over the top. This probably does more to make the late game unpredictable than difficult as such.

And speaking of Crusader Kings solutions, why not make successions a big event? For how obvious it seems, I couldn't find a single mod that even tries it. You could make successions partly reset diplomacy, reset all rebel timers, and add some modifiers to destabilize the country for the first few years. Right now all you get is one time paper mana tax - I'm not even going to pretend you "lose stability". That was true in EU3 as it took time to recover it, but in EU4 you just press one button and don't spend a single day at lower stability. Depending on how it's implemented, this wouldn't even have to be a nerf. What if it reduced accumulated AE by 25%, removed truce timers etc. as well? It might be worth a hassle of having extra rebels and losing some of your allies. This is all just vague ideas, I haven't done any testing, and a lot of CK2-style effects would be difficult to script in EU4's more limited scripting system. If someone wants to try, I think this idea has great potential.

Anyway, while there some possibilities here, I think the other path is a lot more promising.

Why don't players simply start the game in a mid/late game bookmark?

First, there's lack of flavor. In a game like Crusader Kings 2, every start date has different characters, and many historical dynasties are only available some of the time. In Europa Universalis IV countries are mostly the same, even if their borders change. And if a player would like to play a country that didn't exist in 1444 like Prussia, Persia, Spain, or Commonwealth, it's usually possible to form it, and at least for historical countries, formation is usually very easy.

There are some rare exceptions which would be too difficult or take too long to form, like Qing, United States, or Revolutionary France, and occasionally a player might want to play a specific ruler, but it's a very small factor.

So most players would only play late game starts if gameplay was good. So is it?

What mostly works

There are several things in the game that work fairly well, such as province ownership and rulers. Diplomatic relations are also in good shape, although some countries have too many subjects, causing negative diplomatic power gain, but this is only a minor issue.

The cultures and religions are setup reasonably well. There are some questionable choices, but the same can be said about the game in 1444.

Technology and institutions work quite well. Europeans have a significant technology advantage over rest of the world. Arguably it works even better than in a regular game.

Previously, Europa Universalis IV had technology groups, which gave Europeans a historically accurate technology advantage over the rest of the world. However, when the system was replaced with institutions, the spread of institutions became too fast and easy, as did developing them. As a result, the technology gap has almost become nonexistent. According to a video analysis by Reman's Paradox, the gap peaks at around 2 technologies with the Printing Press and then quickly drops towards zero after Global Trade. This issue has not changed much since the analysis was made.

Paradox is unwilling to address this issue as there is a conflict of perspectives between players who prefer a historically accurate technology (with a significant gap persisting until the end) and players who want an easy game in the Rest of the World (with a minimal gap). There is no way to satisfy both groups.

In any case, starting late means starting with the technology gaps as they were before institutions were introduced, and this is fine.

Goods prices are correct for every start date. Events that happen at specific time to change goods prices are accounted for.

What doesn't work but it doesn't matter much

Unfortunately that's where the good parts end. There's a lot of minor things that don't work, but to be fair they're not a huge deal.

There are some easily fixable bugs. Quite a few provinces are missing cores. Qing will reverse-form Manchu, as end game tag check does not apply for such starts. A mod that aims to make the late game playable should take the time to fix these issues.

There are also some undesirable, but understandable behaviors. For example, all Holy Roman Empire countries that historically had a ruler of one religion and population of another, flip their religion in the first month of any late start. It is not clear what the best fix would be.

There are other values that normally increase as game progresses - absolutism, mercantilism, and professionalism.

Absolutism is not adjusted by start date, but it's not too difficult to catch up quickly. It would probably be better if late game starts had some nonzero absolutism.

Mercantilism is not adjusted by start date. This means everyone's trade powers is lower than what it's supposed to be, but trade power only matters relative to other countries' trade power, so it doesn't really affect gameplay much.

Professionalism is adjusted by start date, and the adjustment is quite aggressive, 20% per age. Everyone starting at 60% professionalism is definitely not where it would get to naturally, but it will diverge pretty quickly as the game continues.

The game features monuments, many of which were built after 1444. This is completely unsupported. Every start has the same monuments at same level. For example even 1792 Ottomans start with tier-2 Hagia Sophia and tier-0 Sultan Mehmed Mosque in Constantinople. Interestingly the comments in monuments files imply that a feature to make them pre-built in later start was planned, just never implemented. Fortunately monuments are self-correcting. Mid/late game both money and manpower should be relatively abundant, so monument construction can definitely catch up, at least if the economy was setup properly.

HRE reforms and China reforms are not present in any late game start, and that's probably fine.

Some religions are seriously nerfed. Counter-Reformation isn't present in late game starts, and that hurts Catholicism. Orthodox countries start at 0% Patriarch Authority. However, most religions are fine, and Catholic and Orthodox are some of the strongest religions in game, so arguably this is not a big deal.

What doesn't work and messes up gameplay

And now the really awful parts.

Late game scenarios have zero buildings other than forts. This completely destroys any economic balance. In the latest 1792 bookmark, the highest income country is somehow Russia at very meager 150, number not much higher than Ming can get in 1400s. 1792 France spends 54 of its 100 income on fort maintenance alone.

There is almost no trade income. End nodes in 1792 earn 36, 28, and 17 gold respectively, numbers that look low even for 1400s.

But while incomes might look like it's 1444, the expenses do not. A lot of expenses including armies, navies, advisors, forts, and so on, scale with time. So you have worst of both worlds - early game income and late game expenses. With everyone suffering so much, nobody is going to invest in buildings with their very slow return-on-investment time, so the problem will not fix itself.

Lack of buildings affects not just economy, but everything else building provide, like manpower, force limit, governing capacity, and so on.

Government reforms are nonexistent. Even if you start in 1792, you have 0 reforms unlocked. This is quite bad, as there's no way to rush them, and you're normally expected to have a lot of reforms by this time, and quite a few late game features are locked behind government reforms.

There are no estate privileges and every country starts at the same 0% effective crownland as in 1444 - that is about 30% which you all lose by giving away the essentially mandatory mana privileges. This is also quite bad, as crownland is designed to increase slowly.

Countries in late game starts don't get to choose their idea groups - game selects them automatically, and the selections are truly dreadful, with ideas both weak and inappropriate for their countries. You can abandon idea group and pick a new one, but it will only refund 280 of 2800 points. This severely restricts player agency. It would be much better if player was offered a choice of already unlocked idea groups when starting a campaign, or if switching was possible, at least before unpausing.

Can mods fix it?

The most impactful fix would be to add buildings. There is no "historically accurate" way to do this. The most obvious solution would be running a few AI observe games, and just collecting statistics like "by 1650 50% of provinces in Western Europe have Workshops", and adjusting history files accordingly. This wouldn't be anywhere close to what a good player can pull off, but it would at least un-break game economy.

Fixing monuments by events would be fine, but I don't think this is necessary.

For government reforms, there are two solutions. Either give everyone a lot of reform points to spend (in line with what they'd get normally at this point), or increase government reform progress depending on campaign's start date so certain amount of catch up is possible. The downside of this is that a lot of countries can change government type with final reform, so it might lead to a lot of awkward month one flips.

Crownland issue could be solved either by some crownland bonus dependent on start date, or at least by starting with mana privileges, so you start the game in neutral territory. I don't see any obvious way to accelerate crownland gain. For example reducing seize land timer in later starts would be an interesting way to offer catch up, but it seems to be hardcoded.

With idea groups it's obvious what we want - for the player to be able to choose idea groups they start with, and have them already unlocked. But I'm not sure how that would be implemented. We can't even just full refund, as it would go well over mana cap, and it wouldn't be possible to change to idea group from different type this way. There are some messy solutions, most involving making idea groups nearly free before unpausing.

Summary of fixes

A mod to make late game bookmarks playable should attempt to do the following:

  • fix obvious bugs like missing cores
  • add buildings to match what AI would typically build at given time in given location
  • add government reform progress, either upfront, or by faster growth
  • fix crownland, either by increased starting crownland, or by starting with mana privileges
  • figure out some ways to let player choose idea groups

And with this, late game EU4 starts could be quite decent.

Of course someone would now need to make such a mod, and some of these can be quite challenging to do right.

Monday, January 16, 2023

How to configure OSX 13.1 Ventura for software development

wilma kitten-4 by julochka from flickr (CC-NC)

With every new Macbook, I'm updating the guide, previous version is here.

Things didn't change too much from the previous version. The main difference is that because new Macbooks use Apple Silicon and that causes endless issues, it's pretty much mandatory to install Docker.

Basics

  • Go to Settings > Privacy & Security > FileVault, turn on FileVault. Do not use iCloud for recovery, just note your recovery key somewhere. This used to require computer restart, but it just works now.
  • Install some sensible browser like Chrome or Firefox.
  • Afterwards either sign up into your account on which you hopefully have your ad blocker setup, or install some. Most popular seems to be uBlock Origin these days, but pretty much any of them will do just fine.
  • Install iTerm2 for sensible terminal emulator. If you start it, it will also prompt you to install XCode Command Line Tools, which you'll definitely need, so do it now.
  • Install whichever cloud sync service you're using like Dropbox etc. And start syncing your stuff.
  • Clean up all crap from dock. Other than Launchpad and System Settings, everything else should be gone. Add iTerm2, your browser, and your text editor, and any application you wish to install there instead of stock Apple crap.

Editor

Install some sensible text editor. These days most people use Visual Studio Code. If you do, go to Options, search "Telemetry" and disable it all.

If that's your choice, run it, open Command Palette, and choose: "Shell Command: Install 'code' command in PATH".

Settings

Like every other operating system, OSX has a lot of bad default settings. Here are some obvious fixes:
    • If you have multiple monitor setup, go to Settings > Display > Arrangement and drag and drop them into correct arrangement so mouse can move between them correctly. To make Spaces work correctly, you'll also need to set your external monitor to be the main one by drag and dropping menu bar to it.
    • You might need to do it twice - with laptop screen open, and with laptop screen closed.
    • Also set up which will be your main monitor by dragging that white bar on top of the display icon to it. This looks like Menu placement, but it really mostly controls Dock placement.
    • Settings > Appearance > Dark. If you're setting up a new laptop, this will be asked during installation.
    • Settings > Keyboard > Key Repeat > Fast (max is correct)
    • Settings > Keyboard > Delay Until Repeat > Short (max is correct)
    • Settings > Keyboard > Disable keyboard brightness completely. Defaults (slow keyboard, highlight keys) are meant for people who are bad at typing. If this somehow applies to you, get some typing lessons, you can save huge amount of time by getting better at typing.
    • Settings > Keyboard > Text Input > Edit ... > Disable "Add full stop with double-space" - this one really messes up coding
    • Settings > Trackpad > Scroll & Zoom > Disable "Natural scrolling". This will also apply to the mouse, restoring correct direction.
    • Settings > Sound > Disable "Play sound on startup"
    • Settings > Sound > Disable "Play user interface sound effects"
    • Settings > Sound > Alert volume > 0% (for Terminal ping)
    • Settings > Desktop & Dock > enable "Automatically hide and show the Dock"
    • Settings > Desktop & Dock > disable "Automatically rearrange Spaces based on most recent use"
    • Settings > Displays > Max out brightness
    • Settings > Displays > Turn off "Automatically adjust brightness"
    • Settings > Displays > Turn off "True Tone"
    • Settings > Control Center > Battery > Enable "Show Percentage"
    • Settings > Control Center > Clock > Clock Options > Use a 24-hour clock. This might be already on based on your regional choices during installation.
    • Settings > Mouse > increase scrolling speed and tracking speed a bit
    • Settings > Lock Screen > Start Screen Saver when inactive > Never. You should generally be doing it yourself, and you often need to leave the laptop running upgrades or unit tests or such, and you want to be able to see the status without constantly poking it.
    • Settings > Lock Screen > Require password after screen saver begins or display is turned off > After 5 minutes. You can move it down to 1 minute if you use your laptop in public. I don't recommend Immediately, as that causes endless annoyance with connecting and disconnecting external monitors and just moving laptop around requiring new password.
    • Settings > Sharing > Remote Login > Turn on
    • Settings > Sharing > Remote Login > (i icon) > All Users
    • Settings > Sharing > Remote Login > (i icon) > Allow full disk access for remote users
    • iTerm > Preferences... > Profiles > Terminal > Unlimited Scrollback
    Press Ctrl-Up arrow, add a few desktops (or "spaces" as they were used to know), then go to Settings > Keyboard > Keyboard Shortcuts > Mission Control - and enable their keyboard shortcuts Ctrl-1 to Ctrl-6 or however many you have there. Sometimes I've seen shortcuts for extra desktops not being there, and in such case I just restarted, and the problem fixed itself.

    Open Screenshot app, choose options, then:
    • disable "Show Floating Thumbnail"
    • Save to > Other Location... choose "Downloads" folder

    Drivers

    OSX already includes drivers for laptop itself, but you might need some for peripheral hardware.

    In particular, external PC keyboard need a tweak to work properly, as left and left Windows keys are in reverse order from Mac keyboard.

    Go to Settings, Keyboard, Modifier Keys..., choose the right keyboard from the dropdown (strangely I had ordinary wireless mouse selected by default), and swap positions of Option and Command keys. Feel free to change functionality of Caps Lock key as well, it's a huge easily accessible key with no useful function people love to remap, usually to extra Control.

    New Macbooks now come with Fn/Globe key. You probably don't need i to change your keyboard layout so feel free to use it for emoji keyboard or something like that.

    If you need any special keyboard layouts, get them too.

    Another thing - when you plug in external keyboard, you'll get choose keyboard type dialog. It will likely choose the wrong type. Just pick ANSI, whatever it claims to detect. Otherwise the backtick key will be wrong.

    Home/End keys on OSX are also broken. Use this as a fix. You'll need to log out and log back in for it to take effect.

    Development tools

    You'll need a package manager, and the only one anyone uses is homebrew, MacPorts and the rest died long time ago. You need to tell homebrew to not spy on you with brew analytics off command.

    You'll need Xcode. Fortunately iTerm does it for you automatically, and if not homebrew will. If you need to do it manually for some reason, you can install Xcode manually by running xcode-select --install from command line.

    Deal with stupid access popups

    New in Big Sur, first time you access some folders from terminal, you get a stupid popup asking you to confirm that you're indeed fine with terminal accessing various folders. So run:

      find .

    and confirm all those stupid popups to be done with it once and for all. Well, except you'll still have them when accessing USB drives and such. 

    And just to be extra sure, go to Settings > Privacy & Security > Full Disk Access, and add iTerm there.

    Create new SSH key pair

    Before you do that, name your computer something memorable with sudo scutil --set HostName your_host_name command. You probably go through a lot of laptops, so names like "Name's Macbook" are completely useless to you. Just pick a theme like cats or dinosaurs or whatnot, and give every computer a distinct nam

    Open Terminal and run ssh-keygen to create ~/.ssh/id_rsa, then upload the generated key to any place that needs to know about it like githubbitbucket, or whatever else you use.

    Alternatively you could copy your keys from your old laptop, but it's generally more secure to have separate fresh keys for each machine.

    Checkout your dotfiles

    Hopefully you're storing your dotfiles somewhere. If it's a git repository, or your Dropbox account, get them now and symlink them all properly.

    If there are any other repositories you might need, checkout them too.

    Standard paths

    OSX renames a lot of directories. The most annoying of those is that instead of /home it has /Users. It used to be very easy to add a symlink, but this kept getting more and more complicated, so I stopped doing this.

    Install homebrew packages

    Your list might vary. Here's a few obvious suggestions:

    brew install rbenv ruby-build mc wget p7zip trash git htop bash zsh youtube-dl jq imagemagick coreutils bash-completion zsh-completion nodeenv

    Then enable all services you installed, unless you want to start them manually:

      ln -sfv /usr/local/opt/*/*.plist ~/Library/LaunchAgents/

    And install non-system ruby, so you can install gems without sudo. Currently latest is:

      rbenv install 3.1.3
      rbenv global 3.1.3

    To make that actually work, you need to make sure ~/.rbenv/shims is in your $PATH. If you type rbenv init, it will tell you what to do.

    There's also asdf that offers this kind of service for all languages, if you want to use it instead of rubenv/nodenv/etc. I don't recommend rvm, I've seen it cause too many issues in the past.

    Due to OSX limitations you'll need to run sudo htop if you want to use htop.

    Install gems

    Again, your list my vary. These days most of the software will have its own Gemfile so long list of gems are generally unnecessary. But some global utilities are still useful:

    gem install bundler rak pry pry-rescue

    Different Shell

    OSX switched from ridiculously outdated bash to up to date zsh, so it's no longer a mandatory step.

    If you want to use system zsh, it's fine.

    If you want to install something else, like proper bash (or brew version of zsh; or something else), first brew install bash.

    You'll need to edit /etc/shells as admin and add the following lines at the end of it to enable your newly installed shell:
    /usr/local/bin/bash
    /usr/local/bin/zsh

    Then set it as your shell, with whichever one you prefer:
      chsh -s /usr/local/bin/bash $USER
      chsh -s /usr/local/bin/zsh $USER

    Hushlogin

    For some reason OSX prints worthless annoying messages on every open terminal tab. Run to touch ~/.hushlogin to prevent that.

    Coreutils

    This is optional step. OSX coreutils are generally a lot worse than GNU versions you might be used to from Linux. However switching means occasional minor incompatibilities, so it's up to you if you want to do it or not.

    If you want to do so, brew install coreutils, then add GNU coreutils to your PATH:

      export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
      export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"

    OSX coreutils are not as bad as they used to (for example cp -a now works), so this step can be skipped.

    Better window manager controls

    Sadly OSX window manager is extremely dubious for keyboard use. Fortunately programs to make it usable exist. Unfortunately there's a lot of churn among those programs, and every couple of years the ones I use become unmaintained and need to be replaced by something else.

    Currently I recommend:
    • Rectangle - for moving windows around on big screens - I don't really like the default keybindings, so I change them to Cmd-Control-Option with 1,2,3,4 for corners, arrows for halves, and M for maximize and get rid of the rest. Also set Repeated commands to "cycle through displays".
    • AltTabfor switching between windows - it's baffling that OSX completely lacks this function - and Cmd-Tab to switch between applications is absolutely inadequate for any application that has more than one window, which is most of them (browsers, editors, terminals etc.) if you're developing software.
    You'll need to give them necessary access. To do so:
    • Settings > Security & Privacy > Privacy > Allow the apps below to control your computer > enable AltTab and Rectangle
    Also open its preferences, and set it to run in the background, show in menu bar, and start at login.

    Open files limit

    For some insane reason OSX has default open file limit of only 256, and that breaks a lot of software like databases.

    You can do it for processes in terminal by putting ulimit -n 100000 in your .zshrc, which might be adequate, but not every process runs from the terminal. 

    Enabling it globally gets more and more complicated with every OSX version. Instructions for Ventura are here.

    Lower security settings

    Unix used to have very simple model where root user could do anything, and that was great for development. OSX keeps adding more and more security restrictions. They are absolutely detrimental to developing software, and of questionable value to regular users - primarily they're Apple's way of slowly turning computer world into something more like iOS world where they can decide who can run what and take 30% tax on everything.

    You'll need to disable some of them. Most important such setting is this:
    sudo spctl --master-disable
    After you run it and reboot, a lot of software like Ghidra will work properly.

    Android File Transfer

    It's honestly embarrassing to both OSX and Android that there's no out-of-the-box way to move files between them either over WiFi or USB cable.

    There's official Android File Transfer program but it's just awful. OpenMTP is somewhat less awful, but still not great. If you know of any program that's actually good, definitely let me know.

    On Linux and Windows it's possible to mount MTP devices, which is very slow, but still beats OpenMTP. I don't know if it's possible on OSX.

    All other software

    There's a lot of other software you might want. The most obvious one is the VLC media player.

    You might also want some kind of Git UI program, like GitUp (brew install homebrew/cask/gitup).

    If you want to use SSHFS, the one in homebrew (macfuse and sshfs packages) don't seem to work, so you might want to try downloadable versions. First time you try to use it, OSX will block it, so you'll need to go to Settings > Privacy & Security, allow it there, and restart (you'll get popup for that).

    Docker

    There's a lot of software that just plain won't run on Apple Silicon, so you'll need Docker. You can either use Docker Desktop, or if you have licensing issues with that Rancher Desktop. If you use Rancher, set it to Docker compatibility mode.

    Enjoy

    Once you go through this list, and successfully get everything going, I'd recommend modifying it to your liking and reposting your version on your blog. Everybody's needs are different, so guide like this is just a starting point.

    Tuesday, December 20, 2022

    Fun and Balance for Europa Universalis IV 1.34

    Europa Universalis IV is a good game with a lot of minor issues, and the goal of Fun and Balance is to fix such small issues, to provide a "better vanilla" experience.

    I created the mod long time ago, and I've been updating it every major patch. As the game changes, so does the mod, and it's been a while since I last documented the full list of what the mod is doing exactly.

    I drop features from the mod a lot - usually problem areas are quite obvious to devs as much as to me, so they tend to get addressed eventually, and then my fixes aren't necessary. Occasionally a fix outlives its usefulness, but I've been trying to clean things up if they're not pulling their weight.

    The mod doesn't try to affect game difficulty to a significant degree. It used to be somewhat harder than vanilla, but due to recent changes in favor systems, it's probably about even now.

    So here's the full list of changes Fun and Balance makes, with their rationale. This is a fairly long list, with more important ones first.

    More diplomatic relations

    There are +2 base relationships, from 4 to 6. This is probably the most impactful change, and it used to be +4 before base game started adding a lot of ways to increase your relationships like Strong Duchies estate priviledge, and various monuments.

    This generally increases difficulty of expanding. AI is very reluctant to go over its limit, so this change dramatically increases density of AI alliances, and makes expansion harder. Not just because there are now 2 more countries to help your target, denser network of alliances makes it a lot harder to fully isolate multiple targets diplomatically, so expansion and coalition management are both considerably harder.

    As allies are a lot more important defensively than offensively, this change is a lot less useful for the player, but it enables having long term small vassals, royal marriages, or guarantees without obsessing over diplomatic slot utilization. A lot of options from the base game were very rarely used because of overly low limit.

    In recent patch, with curry favors being arguably overpowered, this is less true. 2 extra allies are worth a lot more offensively than they used to. I think it still makes the game harder overall, but less so than it used to.

    All strait bridges removed

    Now you'll need transport ships to cross even narrow straits. This makes navies far more important, not something you need just once a game to invade Great Britain.

    This surprisingly makest the game a bit harder, as AI is a lot better at dealing with such local transport than with long range invasions. Many scenarios like getting landlocked allies like Austria or Poland to help you fight Ottomans or Denmark, it's not so easy anymore.

    I had to leave one, or the game would crash.

    Eurocentric Institutions

    Institutions were an interesting system, but they completely broke the balance between Europe and Rest of the Old World. They spread far too fast, so tech gap between Europe and India, China, or East Africa is near zero, or even goes the wrong way. That means the whole Old World plays pretty much the same way, and there's no threat of European invasion.

    So the following changes have been introduced to slow down institution spread:

    • passive spread of institutions ("neighboing province has X", "friendly neighboring province has X", and "X embraced") between neighboring provinces slowed down by half - but all other spread just like before
    • spread of institutions only happens if previous institution is already present, notably you can't really get Colonialism without getting Renaissance first
    • Colonialism can only start in Europe, you can still get it as non-European from your CNs
    • dev pushing for institutions made 20% less effective - this isn't a huge change, but it prevents Korea or Ming from randomly dev pushing all institions. Realistically dev pushing as soon as possible is still optimal strategy for Rest of the Old World.
    • Harar Jugol tier 1 monument nerfed - it was giving East African every institution for free really early and breaking the system, tiers 2-3 work exactly like before

    This delays spread of early/mid game institutions and should increase mid-tier tech gap somewhat, from 1-2 to 3-4. Late game none of the institutions are region-locked, so the tech gap will go away eventually, just more slowly.

    The mod also reduces ahead of tech penalty from 10%/year to 1%/year. But notably you'll still be paying penalty for not having relevant institution, even if that institution didn't spawn, so realistically you can get techs 1-2 tech ahead of time.

    Between these two changes, Europeans can be scary again. But I've also seen AI Delhi exceed AI Commonwealth's tech levels even with institution penalties, so don't expect return to EU3 style tech gap here.

    Religious leagues for all Christian denominations

    In vanilla Catholic vs Protestant religious leagues can trigger. The mod adjusts the code so that all Christan denominations can do it. If 4/7 electors follow specific non-Catholic denomination, they can even happen very early, long before the usual time.

    In a typical game, Protestant is still the most likely to trigger, with smaller chance of a Reformed league, and very remote chance of a Hussite one. But if you're playig with a custom non-Catholic nations, or specifically trying to spread some other religion like Hussite, Orthodox, Coptic, or Anglican, you can now do it.

    More formable countries

    Every culture has primary tag, and I made it possible to form most of them, changing your traditions, and missions. Some are not included if there are already obvious regional goals like Bharat, China, Russia etc. AI will also occasionally do this.

    There aren't any obviously overpowered choices here, as end game tag formables usually get a lot better traditons and missions than regular countries. You can get a few decet ones, but it's mostly for more roleplaying options.

    The "end game tag" check for formable tags is also disabled for the player, but AI playing as end game tag will still not form any other tags.

    Disabled anti-player mechanics

    EU4 is mostly fair between player and AI, but it has a few baffling mechanics where AI gets to cheat. These are removed.

    Naval attrition form being at see, player-only in vanilla, is removed.

    Call for Peace, also affecting only the player and never the AI, has no consequences now.

    All coutries with capital in Asia can get Mandate of Heaven

    This mostly gives additional options to Muslims and Hindus. Or you could go crazy, move Pope's capital to Jerusalem, and make the Pope be Emperor of China as well.

    Restore Roman Empire works with subjects

    Restore Roman Empire has extremely long list of provinces it needs, and they needed to be held directly, so a random PU could block you from getting it. Changed the decision so you can use it if (non tributary) subject holds them.

    Trade map changes

    Vanilla trade map makes it impossible for Asian to benefit from New World trade, just to let Europeans get Philippines. While historically it makes some small sense, it almost never happens in real gameplay - Europeans who colonize Asia get trade through Cape or Alexandria not through Mexico. Reversing direction of Pacific trade lets Asians get trade from New World's West Coast.

    Casus Belli changes

    CBs with locked out peace terms have been fixed to allow them. They're mostly useless or extremely niche, in base game. You'll still pay full cost for any such term, same you would without a CB. The biggest effect on the game is that you can declare war on your rival in December 1444 without waiting for fabricated claims and get some (undiscounted) land.

    If both you and your subject have religious ideas, you can get CB on a country that your subject borders, but you don't. This doesn't significantly increase your ability to get CBs, as you could usually get one province to border your target, but it reduces bordergore slightly.

    Coalition wargoal is defend capital (like it was in early patches), not win battles. Winning battles wargoal in EU4 has a lot of issues, and normally this is fine, but for coalition wars, you can get to situations where you're winning in every objective way, didn't lose a single battle, but your allies accumulated so many tiny battles lost that it would take you decades to convince the coalition to end war, while they can stab hit you every month. This isn't the most common, but it happened enough times that I decided to change it.

    As defender in war you get 50% AE discount, instead of vanilla's 25%. EU4 makes being defender awful, as you don't get any CB discounts, so this brings some balance into it. It's still better to be the attacker generally, as you get your choice of CB, and most give decent discounts.

    Maximum amount of gold you can get from a peace deal is doubled from 25% of warscore to 50%. This makes it slightly more worthwhile to get something from war when you don't want to take land. It's still far less than what EU3 or early EU4 allowed.

    AI insistence on staying in war due to war being too short reduced by 1/3.

    Power projection changes

    I'd love to replace rival system completely, so that any Great Power can rival any other Great Power within range. Usually you get very limited choice of rivals beyond very early game. Sadly this is not possible, the rival system is nearly hardcoded.

    The mod increases max distance for rival by 1/3, which seems to be the right number to give some flexibility without too many weird rivalries.

    Power projection from rival related issues increased somewhat, and decaying more slowly, mostly to avoid nonsensical situations where you're too strong to get any power projection, as game won't let you pick rivals. I'd much rather fix rival selection, but that's not possible to mod.

    Subject and opinion changes

    Max hard cap of dev for diplovassalizing increased from 100 to 300. You'll still need a lot of factors to get anywhere close to that number.

    Opinion penalty for annexing vassals capped at -100. In base game it could build up to ridiculous numbers if one of vassals was impossible to annex for some reason while others kept getting annexed over longer time. It was always possible to reset it to 0 by not annexing vassals for 20 years, but tracking exact date is just awkward as game does not show it anywhere. Capping it improves gameplay.

    Supporting independence gives bigger relation boost, can be done from lower starting opinion, and AI doesn't care as much about having too many relations when it can support independence. All this modestly increases independence support.

    Colonial Nations now consider their own power (as well as that of their supporters) for liberty desire, but to balance it out gets -25% base liberty desire. In base game supporting independence of a colonial nation does not increase liberty desire at all. This overall makes holding onto colonial nations as a very weak colonizer harder, most commonly Portugal might struggle with it, if it loses its army in war and its rivals support CN's independence. But it's still a modest factor.

    Quite a few vastly excessive opinion penalties got reduced to sensible levels.

    Unlawful HRE territory is capped at -50 to prevent spam. Violating treaty of Tordesillas is capped at -50.

    Pirated us cap changed from -100 to -25. It really made no sense that countries would be more bothered by some minor piracy than by declaring war on them and occupying all their land, and it interfered with diplomacy as AI just loves spamming piracy. Converted our culture penalty cut from -30 to -5 and capped at -100.

    More building slots

    Building limit increased by +1 base, and from +1 per 10dev to +1 per 5dev.

    This was much more aggressive previously, but I toned it down once game made Courthouses not take building slots, effectively giving every province +1 slot.

    Extra slots mostly allow a bit more flexibility with buildings, and they benefit smaller richer countries more. Especially AI as it's bad at using its slots well. Big poor countries which can't fill their slots benefit from it the least.

    Unlock regional features

    The mod lets everyone claim whole areas, not just individual provinces. It was locked to Russia in base game. I originally wanted to make it available at empire tier only, but last time I checked that didn't work without making separate empire versions of every government reform. In any case, this mostly reduces border gore, and saves you a modest amount of diplomatic power early game.

    Catholic Holy orders are unlocked so all Catholic can use them, not just Iberians.

    Covert actions changes

    Covert actions are massively underpowered, so they're buffed across the board.

    Stealing maps cost reduced 50 to 20. Infiltrate administration cost 40 to 20. Agitate for liberty cost 90 to 50. Slander merchants cost from 70 to 20.

    Agitate for liberty and infiltrate administration unlocked without requiring any tech.

    Supporting rebels made significantly cheaper and more effective.

    Even with all this aggressive buffs, none of these are particularly strong.

    Custom nation tweaks

    Max tier of ideas increased from 4 to 10, at costs following the curve, so you'll spend a lot of points on high tiers.

    Penalty for max ideas from same group removed, as it's mostly for roleplaying.

    Max distance between provinces increased from 400 to 1000, again for roleplaying.

    Base monarch skill changed from 2/2/2 to 3/3/3, which is actual average.

    Religious rebels changes

    Religious rebels increased in priority, so a province with missionary is likely to spawn religious rebels, even if other kinds are also possible. They also always want to convert your country, even Pagan rebels, and province targetting weights changed to be more interested in going after provinces they can convert or provinces with a missionary.

    Religious Shift Decision

    If your capital has a different religion, you can pay 3 stability to shift to that religion, similar to CK2. AI will not use this.

    This is an alternative to the very frustrating experience of hoping that religious rebels will do what you want - but if you can use rebels, that's a way to get free conversions and not lose stability.

    Balkan Changes

    Europa Universalis IV makes a lot of highly questionable decisions for Balkans, trying to railroad Ottomans as end game boss, at expense of making a lot of things nonsensical. Ottomans do not need any help, they'll be end game boss even if we fix things.

    Ahistorical "Byzantium" renamed to "East Rome". It is also primary tag for Greek culture. Concept of "Greece" as a country is an invention from 1800s', Greek-speaking Romans saw themselves as Romans well into EU4's end game. It's also possible to form it as Romania, Ottomans, or HRE, if you're Greek Orthodox.

    Turkish moved to its own culture group.

    "Carpathian" culture group removed. Slovak moved to West Slavic, as it was really nonsensical that it was a different culture group from Czech. The rest merged with South Slavic into "Balkan" culture group. Notably Greek is still not in it, and I'm wondering if it should (together with two micro-cultures in its group).

    Ottoman decision to move capital to Constantinople does not do free culture and religion conversion.

    You can declare wars in regency

    This was a pointless restriction nobody needs.

    Improved bad idea groups

    Some idea groups - notably Naval and Maritime - are just awful, so I tried to improve them somewhat.

    The mod used to give Naval extra leader slot so it can recruit some admirals, but game changed its mind and increased leader slots to such high numbers you'll never need more, especially not admirals.

    It still gives Maritime +1 merchant and +50% light ship trade power. To be honest, it's still so low tier I'm not sure anyone would take it even with the buff.

    War Exhaustion changes

    In vanilla War Exhaustion is largely just a tax on diplomatic power. The mod changes it so cost to reduce it is doubled if you're at war. Originally I disabled it completely, but sometimes you get stuck at long term fake war due to your allies, and I didn't want you to be stuck with big war exhaustion in such case.

    War Exhastion gets reduced at peace twice as fast. It also convinces AI to peace out twice as much.

    Other changes

    Tradition from battles doubled, so it's influenced somewhat more by actually fighting or not, and somewhat less by forts and idea choices.

    Costs to change culture, move capital, or move main trade port halved, as they were all seriously excessive. In a typical game you'll not use any of these features.

    Limit of idea groups from same category removed, but that's already an option when you start a new campaign.

    You can customize it

    If you want to customize your experience, I tried to keep different changes separate, so you can adjust or delete any tweaks.

    Overall the mod isn't trying to make it a completely different game, just a better version of what it could be.

    I play about one campaign per major patch, plus run a lot of AI simulations to see if the changes work as intended. But it's definitely possible that some of the changes have serious side effects. If you play Fun and Balance, and have issues with either fun or balance, let me know.

    Friday, May 06, 2022

    Chinese Lockdowns

    A few weeks ago I wrote Pandemic Retrospective. Events since then pretty much confirmed everything I wrote.

    The West got over covid. It's still there, but old people are overwhelmingly vaccinated, so nobody cares.

    Meanwhile, China is doing its best to implement Zero Covid policy. OK, so here's what I wrote back then:

    There's also an interesting idea for stage 1, to totally close not just countries but each city and region, and wait for covid to disappear there, before reopening only borders between covid-free areas. But this would only work if external country borders were closed as well, and it would be extremely disruptive. China sort of did that initially, but nobody else really tried that at all.

    And what China did 5 days after I wrote that post? Literally what I said, on a much larger scale than in 2020.

    Chinese lockdown is based on setting up borders. Not just external borders, and just borders outside cities, but borders between districts inside cities. It's extreme borders more than extreme lockdowns.

    Instead of closing factories, China converts them to a closed system, where workers live in their workplace, so they don't need to cross internal borders. That's something Europe never considered, travel was open for "essential workers" which were a huge chunk of the population, far too great for covid to be possible to contain.

    It's unclear if this will be enough to achieve Zero Covid - so far the signs aren't too great, but let's imagine they do. Whichever way it goes, one thing it proves beyond any doubt is that European approach - late severe lockdowns without corresponding external or internal hard borders - didn't have the slightest chance of ever working. European style lockdowns were completely 100% counterproductive.

    And since I'm in a prophetic mood, Ukraine will destroy Crimea Bridge.

    Tuesday, March 29, 2022

    Russia is Doomed

    I drafted this post last year, with this exact title, but I ended up writing the 100 Programming Languages Speedrun instead, and didn't have time to finish it. I'm feeling a bit silly now. Anyway, nothing here is in any way related to the Russian invasion of Ukraine, so just imagine that this was posted before all that.

    Russia is a regional power like Italy, Turkey, Brazil, or Saudi Arabia, LARPing as a superpower. It's baffling that people actually buy that, and think that Russia is some kind of a global superpower like US or China.

    If you look at GDP or population, Russia is really unimportant. Projected population growth for Russia looks even more miserable than for the West, and their economic growth potential is very poor if you exclude two sectors.

    Now Russia has two important things going for it, but here's why both will end soon.

    Fossil fuel exports

    Russia's biggest strength is its fossil fuel exports. If you look at export statistics, they constitute about 50% of all of Russia's exports. Exact number varies year to year based on their prices. Russia has been called "gas station masquerading as a country" for a good reason.

    This is not sustainable. I despise virtue signaling over climate, but regardless of that, renewables technology is ceaselessly advancing. We already reached the point where renewables, with reasonable subsidies, are almost competitive with fossil fuels for electricity generation during good parts of the day. The main problems are intermittency of renewables, use of fossil fuels for transportation, and cost of switching all the existing infrastructure.

    The first two can be solved by cheap batteries, and battery cost fell about 90% over the last decade, with little reason that this will stop. And given enough time and money, existing infrastructure will get replaced.

    Full replacement of fossil fuels will take many decades, but this is not a growth sector. And Russia has nothing to replace it with. Other raw natural resources bring a small fraction of that money.

    Green useful idiot

    One thing Russia succeeded in doing, is funding "environmentalist" group that oppose European energy independence. Europe could have been far closer to energy independence already if it proceeded with fracking, nuclear, clean coal, and other technologies, just as US have done. It took US twenty years from being in just as deep shit as Europe to being a net energy exporter. All it took was political will.

    However "environmentalist" groups, some receiving substantial Russian funding, others being Putin's useful idiots, managed to prevent European energy independence, and made Europe more dependent on imports from Russia for the time being.

    Also did I mention recently that this guy should hang from a lamp post for treason, and it's a disgrace to his whole country that nobody hanged him from a lamp post or other suitable object yet?

    Anyway, while this has been extremely successful Russian subversion of democratic countries, in the long term it won't matter, as it will be possible for just about any country to just buy enough batteries, solar panels, and EVs to gain energy independence.

    Weapon exports

    The second thing Russia has going for them are their exports of military equipment.

    Russia is targetting mid-tier market. Their equipment is much worse than top-tier exports from the US, but it's a lot cheaper, and still a lot better than low-tier weaponry poorer countries can manufacture locally.

    This is going to unravel really quickly, much faster than energy exports. The reason is China. China has been trying to build weapon export industry, and there's nothing that could possibly stop them from succeeding.

    Chinese industry outproduces Russian industry 20:1 and the gap is growing every year, China has amazing track record at going from low-tier to mid-tier in any key industry it wants. That's what happened to far more competitive low-tier and mid-tier smarphone market over just a few years. The high end is safe - be that Apple and Samsung or US and other NATO military equipment. And countries can do their own low-tier basic stuff like rifles if they really want to. But China is amazing at going after the whole global mid-tier market.

    I don't know why nobody talks about this, but it's pretty much guaranteed that the same will happen with Russian weapons exports. China will dominate this. And other mid-tier competitors like Turkey are also trying to break into this market, all at Russia's expense.

    Why military exports matter?

    Weapons exports are not a huge money maker for Russia. Overall global weapons trade is about $100bln a year, just 0.5% of $20,000bln a year global trade.

    This is important to Russia for two reasons. First is that modern weapon development is horrendously expensive. Spending all that R&D money and your own military being the only buyer, translates to enormous unit cost. Even US can just barely get away with it, and non-exportable F-22 was in retrospect a huge mistake, compared with exportable F-35.

    Russia is just far too small a country to even attempt creating any modern non-exportable weapon systems.

    The second reason is that weapon exports give Russia a lot of political influence among world's poorer countries. It's hard to criticize what Russia is doing, after your minister of defense took Russian bribes to get them to win the contracts, and now your air force is now made of Russian planes, and Russia is the only source of spare parts.

    This is not going to last. Oven the next few years Chinese offers will be better, cheaper, and for most countries less politically toxic, than Russia's.

    There will be some markets left, like India might be unwilling to buy from China, and too corrupt to buy from the West (which is far less willing to engage in outright corruption necessary to win military contracts), and too poor for high-end gear anyway, so they might still buy worse Russian jets over better Chinese ones. But overall, this part of Russian economy will collapse even faster than their energy exports.

    Postscript

    As it turns out, I was late with this post. Europe is now scrambling to reduce their exposure to Russian fossil fuels, and Russian weaponry turned out to be a lot worse than advertised, so both sectors might collapse a lot sooner than I thought.

    By my original guesstimated times for these, Russian energy sector would go into serious decline in 2030-2040 kind of range, but their weapon exports likely as soon as 2025-2030, while Chinese weapon exports would skyrocket just like their smartphone exports did.

    People are now willing to talk about Russian fossil fuels, so that take isn't all that hot anymore. However, I haven't heard a single other person even entertaining the second point of the inevitably coming Chinese (and surprisingly Turkish) competition crushing Russian weapons exports.

    Wednesday, March 23, 2022

    Pandemic Retrospective

    There won't be anything too controversial here, just a bit of big picture view.

    Basics

    Covid-19 is not over, and there's no indication that it will ever be eradicated, there are just a lot more important things going on right now.

    So far the only established human disease we managed to eradicate was smallpox. Polio eradication efforts have largely stalled, with little progress since year 2000. I still have some hopes that we'll win over polio, but the chance of total elimination of covid-19 in any realistic timeframe is essentially zero.

    The most outcome is that covid will be just another seasonal disease like the flu, with us for the long run. This is mostly fine, as going forward, most people will get exposed to mild infection when they're young, and by the time they're old and vulnerable, they'll have some degree of immunity, from some combination of previous infections and vaccines.

    Age is the main risk factor, far greater than anything else. Every extra 20 years means 10x higher death rate, or in other words every additional year of your life is extra 12% risk of death if infected.

    This is a good way to put things in perspective. For example according to the few RCTs we have, masking (with a real medical mask) may offer about 10%-20% reduction in infection chance, with no reduction in severity of symptoms in case of infection. So you're about as vulnerable masked in 2022 as you'd be unmasked in 2021, just because you aged enough to counter all that benefit. And "masking" with non-medical mask doesn't seem to do anything at all.

    Vaccination with regular boosters may reduce risk of death by about 80%-ish, equivalent to being about 15 years younger. So a fully vaccinated and boosted 40 year old is at about as much a risk as completely unvaccinated 25 year old. There doesn't seem to be much reduction in chance of getting infection in the first place, mostly reduced severity.

    It's often underestimated just how much covid is a single-risk-factor disease, that factor being age. For example obesity increases risk of covid death by 25%. So 40 year old obese person is at as much risk as 42 year old healthy weight person.

    I think it's a useful visualization tools to translate all relative risk factors into equivalent age differences.

    Risk of hospitalization and other serious health outcomes roughly follows risk of death, with similar risk increase for every additional year of age.

    Anti-Covid Measures

    There are three stages at which we could intervene to prevent covid deaths (and other severe outcomes):

    1. prevent pandemic from getting to your country in the first place
    2. reduce spread of infection once there's already community spread
    3. reduce chance of death for an infected person

    A lot of measures have been taken, but only two have been very highly effective:

    • total border closures (step 1)
    • vaccinating old people (step 3)

    Everything else did either nothing, or had minor effect, or was outright counterproductive. These include such measures as:

    • bank account closures
    • contract tracing
    • firing people for having different opinion
    • hand washing
    • ivermectin
    • lockdowns
    • mask mandates
    • masking
    • mass event closure
    • partial border closures
    • quarantines for travelers
    • riots
    • school closures
    • social media bans
    • stimulus checks
    • testing
    • vaccinating low risk people
    • vaccine mandates
    • voluntary masking
    • work from home
    • etc.

    In the end, none of them had a big impact on the death rate. Notably almost all the measures attempted to target stage 2 (reduce infection rate once it's already established), and for covid that was simply the least effective stage to target.

    The most unexpected thing about covid is that stage 1 interventions (total border closures) were extremely effective even after covid already got established. The original Wuhan lab leak variant was just not all that infectious, so closing borders and preventing much more infectious subsequent variants from coming in was an extremely successful approach, even in absence of other interventions. Japan is a good example of this combination.

    Cargo Culting

    A huge problem with global pandemic response is that countries threw away all established science, and mindlessly copied what other countries were doing, even if it was completely ineffective. So instead of 200 different policies we could meaningfully compare, it's largely same ineffective policies tried over and over.

    Knowing just country age structure, border closures, and vaccination rates among old people, we can fairly accurately estimate pandemic severity, throwing away all other information.

    Arguably the main problem with global pandemic response was that everyone was cargo culting part of Chinese response that was pointless (lockdowns), and in a half-assed way that couldn't have possibly worked anyway; and they did not copy the part of Chinese response that actually worked (total border closures).

    What Was Not Tried

    In retrospect was can safely say that nothing targetting stage 2 would have worked. Any response strict enough to eradicate transmission after it was well established would just completely crash the economy, and with borders even partially open, covid would get back in anyway. And if you closed the borders, then you didn't need to be that strict in the first place (see Japan again).

    At least none of such interventions would work if they targetted general population. We could have absolutely done crazy strict lockdowns of nursing homes specifically. About a third of all covid deaths in US was in long-term-care facilities, and these are not economically significant. We could have completely isolated them from the rest of the population (food delivery in full body ppe suit kind of isolation), and likely avoided 1/3 of all covid deaths. By moving more old and vulnerable people into similar protected environments, deaths could have been reduced even more.

    Nobody really tried that, and there's been overwhelming lack of interest in any interventions that segregated people by risk level. If we did something more along the lines of:

    • no restrictions of any kind on under-30s
    • some modest risk reduction recommendations for 30-60s (no mass events, work from home recommendations, masking on public transport recommendation etc.)
    • total lockdown for 60+s

    That would be far more effective and far less destructive than what actually happened. To repeat the basic fact, 20 years of age difference means 10x risk of death difference. There's no sane way to treat kids and elderly the same, and that's what all countries did.

    More idiotically, students were often restricted far more than adults, just because schools have far too much power over students' personal lives. It was cruel, and it did nothing to help with the pandemic.

    There's some stage 3 interventions that could have had a meaningful effect, but weren't attempted.

    The most notable one that would be mass vitamin D supplementation, as pre-infection vitamin D levels correlate very strongly with risk of death, and vitamin D insufficiency has been widespread in most modern populations. For people with most severe deficiency, effect size looks about as big as vaccines, based on observational studies. It would be much smaller averaged over entire population, as not everyone is as severely deficient. Unless you know that your vitamin D levels are adequate, you should absolutely get daily supplement, especially during winter, and not just for covid.

    There's also some new antiviral drugs that could reduce risk of death. They happened late in the pandemic, but I guess if someone writes similar retrospective in 2025 they might get added to the list of interventions that made a big difference.

    There's also an interesting idea for stage 1, to totally close not just countries but each city and region, and wait for covid to disappear there, before reopening only borders between covid-free areas. But this would only work if external country borders were closed as well, and it would be extremely disruptive. China sort of did that initially, but nobody else really tried that at all.

    Who Predicted It Correctly?

    Nobody at all.

    Pre-pandemic expert consensus was very strongly against lockdowns, border closures, masking, and most other measures that ended up happening. Pretty much none of that was followed.

    Epidemiologists' models were all universally worthless, and the whole field of epidemiology turned out to be about as reliable as social psychology.

    Governments were both extremely incompetent and openly lying. The media were even dumber than usual. Social media companies were banning people for saying true things.

    I don't think even any individuals got it right. As far as I know, nobody predicted either of these:

    • the initial Wuhan Lab variant was no big deal, the variants were a big deal, so total border closures would be super effective even after Wuhan lab leak variant was already there
    • vaccines would be developed very quickly, but they'd only offer big redution in severity and risk of death, and wouldn't meaningfully reduce infection rate, so mass vaccinating old people was really important, but any mass mandates are pointless

    I don't think anything useful came out of prediction markets either.

    Who Did Well?

    The private sector did amazingly well. Rapid transformation of big parts of the economy from office-based to remote-first was amazing, and we should absolutely embrace the remote-first world, even if it made little difference for covid.

    Similarly supermarkets, restaurants and so on switched very effectively from location-based services to delivery-based services. Restaurants have a lot more reason to exist than offices, but this shift is likely permanent, and a much bigger share of the economy will be online or delivery-based going forward.

    Big Pharma did quite well. Multiple vaccines were developed in record time, of kind not used ever before, for kind of a virus that never had an effective vaccine before. Tests, antivirals, and so on were also developed very quickly.

    What It All Means For The Next Pandemic?

    Very little actually. Covid-19 had so many unusual features, there's no reason to expect the next one to be like that.

    Wednesday, March 09, 2022

    crystal-z3

    A small announcement. Mostly as a way to play with Crystal, I created Crystal bindings for Z3 library, and I think it might be quite usable as a MVP.

    Check included examples and specs for how to use it.

    Monday, March 07, 2022

    New series - Open Source Adventures

    I started a new series last week, Open Source Adventures. It's not terribly focused, it will be some random unrelated Open Source things I wanted to do. The first mini-project is Z3 support for Crystal programming language, but I'll jump to some very different subjects.

    Just like with previous two series, you can read it on dev.to or hashnode.

    The code for the series, unless it has specific reason to go elsewhere, will go to this repo.

    Thursday, February 24, 2022

    100 Languages Speedrun Finished!

    About 100 days ago, I started the 100 Languages Speedrun series. It is now finished.

    You can read all 100 episodes, as well as two bonus episodes - Tier List, and Series Retrospective.