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

Wednesday, December 10, 2008

The ancient art of stabbing people

Here's a blogified version of a talk I gave on BarCamp London 5. Most BarCamp talks tend to be about Internet, computing, startups and the usual topics that everybody's heard about over 9000 times. This one is going to be different because it talks about ancient human history.



London is the stabbing capital of the world. While rests of the world shoots at each other, 29% of our homicides are good old making holes in thy neighbour. But stabbing is older than humanity. Here's a photo of an orangutan getting his food by stabbing some fish.



Our closest relatives chimpanzees also hunt with spears. Here's a chimp sharpening a spear, so it makes good holes.



Chimps use spears to hunt for galagos like the one here, killing them while they sleep. Can you imagine anything more adorable than a monkey stabbing a cute little sleeping galago? What is clear from these examples is that stabbing is an instinctual behavior for hominid primates including humans, and that sense of fair play isn't.



Prehistoric humans obviously used stabbing tools for hunting. It's not really clear at which point we started to use them to stab fellow humans. There's plenty of ancient skeletons with wounds caused by weapons, but some of them might just be hunting accidents. When a group is hunting accidents are very common - lately Dick Cheney shot a 78-old guy in a face while hunting for quail, and when half of humanity hunted daily for whatever they could find it's certain many people died of stab wounds even without any foul play. Or if you didn't like someone you could make it look like a "hunting accident" and the rest of the tribe probably couldn't tell.



At some point people clearly started systematically killing each other. That's a good time to ask the question - why stabbing? When you look at most movies and computer games people almost exclusively slash, shoot, and bludgeon each other, while stabbing is very rare. Historically on the other hand stabbing was the best and most common way to hurt other people through almost entire human history.

The first thing to forget is shooting - unless you're firing at point-blank range there's almost no way an arrow or bullet is going to hit the intended target. Even with modern precisely manufactured and very powerful weapons, if they didn't have insanely high rate of fire you'd be better off with a knife than a gun. For virtually the entire history the way bows, crossbows, guns, slingshots, and all other projectile weapons were used was a large number of people shooting another large group of people. You had a small chance of hitting a particular guy at a distance, but some of you will probably hit some of them. Unfortunately for you the other guys will catch up with you quickly, so very few battles were won by just shooting with small weapons.

The main problem with bludgeoning is its low lethality. Human body can take a very high number of blows before you die. It's going to hurt like hell, and some bones might be broken, but you will only notice that after adrenaline rush of the battle cools down. If you're trying to bludgeon some guy to death, it's going to take so much time that he might very well die of boredom before he dies of wounds.



Stabbing on the other hand was very lethal - a deep stab would can destroy vital organs, cause massive bleeding, or if it doesn't work, kill by infection. Before the invention of antibiotics, what happened very recently on historical scale, even a very small stab wound could easily kill you a few days after the fight.

Slashing was somewhat popular, but there are many problems with it. First, it is a lot slower than stabbing. It also has a short range - long slashing weapons like huge jrpg swords would be way too slow to be practical. It also causes shallow wounds that are a lot less likely to kill than deep stabbing wounds, is much easier to parry, and its effectiveness is seriously reduced by even light armor. There are also technological issues - many materials like bronze are too weak for long slashing weapons, and you need a lot of metal to make a sword than just a spearhead that you attach to a wooden stick.

Most historical slashing weapons are really hybrid stabbing/slashing weapons, with stabbing being the primary mode of use.



It's time to leave prehistory and enter history. The best known spearmen in the world are Greek Hoplites, and among them obviously Spartans.



The "300" movie is very inaccurate in its depiction of ancient Greek warfare. Persians didn't really have war rhinoceros, and Spartans didn't fight barechested to show off their abs. Hoplites were really fighting in heavy armor, as the very idea was to make holes in the enemy before he makes holes in you - bare chest doesn't really help with that.



Here's a guy reenacting a Greek Hoplite. I totally love those reenactment guys and great photos they provide. You can see he's got a good stabbing tool, and the best body protection he can get, even if it hides some of the muscle.



Hoplites did not fight alone - weight of all the armor slows them down a lot, and spear is not the greatest weapon unless at the right range. Hoplites fought in a phalanx. Phalanx is a long line of hoplites, many people deep, and sometimes many kilometers long, with all spears pointing in direction of enemy. Big shields are used to protect you and the guy on the left. It is very deadly as long as the enemy is in front of you and the formation holds. It also has very low mobility - it can go forward fast enough, but changing direction without breaking formation takes ages.

It is very vulnerable from the back and flanks, so it must be long not to get outmaneuvered, and it must be deep not to be broken by a frontal assault. Another useful thing is that the guy standing behind you also points his spear in direction of the enemy.



Greek and in particular Spartan Phalanges dominated Greek warfare, but they were far from invincible. In battle of Lechaeum a bunch of lightly armored Peltasts throwing javelins, which is like no-contact stabbing, destroyed Spartan Hoplite unit by "throw a javelin and run" tactics. That's the only such case in history, as normally a Phalanx was accompanied by support troops like Peltasts and cavalry, so tricks like that didn't work and the fight returned to phalanx superiority.

A much more significant blow to Spartan reputation for masculinity was battle of Leuctra where significantly smaller Theban hoplite army led by openly gay-married Sacred Band of Thebes totally pwned Spartan asses and killed Spartan king.



At some point Greece and in fact most of the known world was conquered by Macedon. Macedon armies also used Phalanx formation, with a tiny difference of using very long spear called sarissa in place of traditional short Greek spear dory.



Sarissa was very heavy, was carried in two parts that were only assembled before the battle, and was almost completely useless as a weapon except when used as part of a Phalanx.



The difference as shown by the reenactors is very clear.



And here are they charging at each other. Both weapons make sense only in a Phalanx, and sarissa more so. It also takes two hands to use, so Macedonian reenactor has a much smaller shield attached to his arm, while Greek reenactor can hold a big shield in his left hand.



The real power of sarissa can be seen in Macedon Phalanx. Now instead of two spearheads between you and the enemy there are five, what significantly increases enemy's expected number of blood-letting holes.



Here's another picture of a Macedon Phalanx, this time from one of my favorite games Rome: Total War. The game shows warfare with reasonable levels of historical accuracy, so there's a lot of hot stabbing action.



This was one of the greatest triumphs of stabbers. Macedon Phalanx was a deadly force but very vulnerable. Alexander used his tactical genius to leverage its power and minimize its vulnerabilities, and so conquered most of the world in just twelve years starting from a very small kingdom.

Here's a picture of Alexander showing equipment of Macedon cavalry. They used 4 meter long spears which they used to stab people. Charging with couched lance known from late Medieval era was completely unknown to the ancient people.



The next big power after fall of Macedon was Rome. Roman army completely changed many times during Roman history. At first Romans used walls of spears just like Greeks. Here's a picture of Roman Triarii from Rome: Total War.



Roman Legions in their best known form fought using short sword gladius. It was primarily a stabbing weapon. Romans didn't introduce many technical innovations to the art of stabbing, they were really good at tactics, engineering, and especially politics.



Another important part of Legionary equipment were usually two pila. They were thrown before engaging in melee. The part behind the head is made of soft iron which bend on impact, making it difficult to get rid of a pilum. This way even if pilum hit a shield, now the enemy had a sharp point sticking out of it, was made the shield a lot less useful or even dangerous to the user.



No history of stabbing would be complete without mentioning the most famous stabbing victim - Julius Caesar.



Caesar was killed by repeated stabbing with a Roman utility knife pugio.



Senators who killed Caesar intended to restore the Republic. The assassination was successful, but as far as restoring the Republic, it was an epic fail.



There were almost no innovations in stabbing technology for the next millennium after stabbing of Caesar. In late antiquity stabbing from horseback got quite popular. Here's a picture of heavily armed Parthian Cataphract cavalry.



Cataphracts look a lot like Medieval knights. Both them and their horses are heavily armored, and they use long spears to stab enemies. They didn't have stirrups, and still stabbed their enemies instead of charging at them.



This way of fighting didn't change until Late Middle Ages. In Battle of Hastings depicted by Bayeux Tapestry you can see cavalry having stirrups, but still using their spears as stabbing weapons, not for couched charge.



At some point in the Medieval era couched charge was developed. It was a result of better horse-riding technology including stirrups, nailed horseshoes, and solid tree saddle, as well as better armor of soldiers, which required more punch from the charge.



Cavalry was heavily armored, both riders and horses.



Here's a great photo of a knight reenactment.



Late Medieval infantry battles also had a lot of happy stabbing. Because soldiers were so heavily armored, slashing was almost useless. Armor like that needs to be pierced if you want to kill, slashing plate armor with a sword is not much better than bludgeoning it with a club.



And finally era of heavy cavalry was over. But it wasn't because of gunpowder yet. At first gunpowder was used more for siege artillery than for a field battle - guns were too slow and inaccurate for battle, but city walls are hard to miss and aren't really going anywhere.

What killed heavy cavalry was rise of pikemen and halberdiers, who were in many ways similar to ancient Greek Phalanx, and definitely not something you want to charge.



Masses of mercenary pikemen charging at each other were a bloody and quick way to resolve their differences.



One problem with pikes and other long polearms is that when fighting gets close enough, they are very hard to use, and something like sword is a lot more practical.



Pikemen armies saw gradual introduction of firearms. Arquebus is a very slow weapon, so unit equipped with them can easily be crushed by cavalry or infantry charge. A combination of arquebusiers, pikemen, and sometimes also swordsmen, and halberdiers can deliver hot lead over the distance, and make stab holes in anybody who comes too close.



This was however the end of stab-centric armies. As you don't need to shot and stab at the same time, "pike and shot" formation always leaves half of the troops unused. We could give everybody a gun and a pike, but that would be rather unwieldy and heavy. But hey - isn't a gun already a long stick that just needs something sharp on its end?

The idea isn't new, even 13th century Chinese cavalry used it. In this case it was more of a spear with attached gun than a gun with attached bayonet.



Muskets with bayonets replaced "pike and shot" armies. Even in Napoleonic Wars bayonet charges were important part of military strategy, as rate of fire was very low. Also a quick decisive charge is much more likely to rout enemy forces than slow fire.



As rate of fire increased tremendously, bayonets became less relevant. Now they're basically utility knifes, and even at very short ranges it makes a lot more sense to shoot than to stab. Stabbing after long history is no longer part of mainsteam military.



Tradition of stabbing continued for some time after mainstream militaries moved on. Polish heavy cavalry Hussars dominated 17th century Central Europe. They had those cool bad-ass wings, nobody's really sure what for.



Even in 19th century, Zulus were able to build an empire using mostly spears. It was probably the last stabbing-based empire in human history.



Now that stabbing is no longer of any military significance, it's mostly used for crime by people without access to guns, like the British. But you can stab even without a knife - there's a great collection of improvised stabbing tools from prisons - The Art of Shiv by Brett Yasko.



I tried to keep historically accurate but some simplifications were necessary for the sake of a good story. If you have any questions - use comments below the post.

Funny characters in Unicode

This post is a blogified version of a lightning talk I gave on BarCamp London 5. It was inspired by Chris Ball's Favourite Unicode Codepoints post. It's going to be in a weird talk/blogpost hybrid form that I hope my readers will excuse.



First, I want to say that this talk is not going to convey any useful information whatsoever. You won't learn anything about internationalization, or anything else from it. I'm doing it just because it's going to be fun and awesome.

upside-down

uʍop-ǝpısdn


First the famous mirror trick, where text can be seen upside down, or mirrored left to right. None of it is real Unicode characters like "mirrored e" or "upside down a". It's just a bunch of characters that happen to look like that - for example "upside down p" (like in pet) is obviously "d" (like in dog). If there's no good Latin letter, a letter from other script is used, like Cyrillic or IPA phonetic alphabet. It will be more or less noticable depending on your font.

U+2620


SKULL AND
CROSSBONES


Here's a real Unicode character - Skull and Crossbones, arrr! It's used as danger signal, so it's arguably common enough for inclusion in Unicode.

U+2603


SNOWMAN


This one I totally don't get. It's just a random icon that somehow got into Unicode. Unicode is huge, so they have very low standards for inclusion. Maybe it was in Microsoft Wingdings or something like that and they thought it's a good enough reason to include it.

U+3020


POSTAL MARK FACE


I half-get this one. Top three lines are Japanese Post symbol. Where does the rest of the face comes from and how it got into Unicode is a mystery to me. It was probably included in some JIS standard as a joke, and Unicode copied it, or something along these lines.

U+2368


APL FUNCTIONAL SYMBOL TILDE DIAERESIS


Operators from APL programming language got into Unicode too. APL is like 1960s' Perl. This operator doesn't feel too good because it has to program in APL.

U+FBF9


ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM


It's called Arabic ligature Uighur Kirghiz yeh with hamza above with alef maksura isolated form, and it's exactly what it says it is. It looks rather ordinarily for this list, but it might be the character with the longest name.

U+FDFA


ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM


Another Arabic one. Most ligatures are for just 2 or 3 characters, but canonical decomposition of this one is whooping 18 characters. It means something like "May Allah bless him and grant him peace" and is used when Prophet Muhammad is mentioned. By the way I had a really funny picture of Muhammad that I wanted to put here, but I somehow cannot find it.

U+0E5B


THAI CHARACTER KHOMUT


How many loops are there?


U+2C22


GLAGOLITIC CAPITAL LETTER SPIDERY HA


This letter is very spidery so better be careful or it will bite you.

U+22D9


VERY MUCH GREATER-THAN


Sometimes it's not enough to be greater than, or even much greater than something else. Oh no, you need to be very much greater than. I think TeX is spoiling mathematicians and they come up with way too many symbols, and then we have to support them.

U+2278


NEITHER LESS-THAN NOR GREATER-THAN


A polar opposite of the previous character. It's not greater than, neither is it less than. We kinda have a symbol for that already - U+003D EQUALS SIGN. OK, I know it's about partial orders, and it means that two objects cannot be compared, but it's not any less funny for knowing that.


U+2764


HEAVY BLACK HEART


This is a very sad symbol. Not only its heart is heavy, it's also black. Is it a waste of codepoint or what? It's just a random icon not a meaningful "character".

U+2619


FLORAL HEART BULLET, REVERSED ROTATED


That's my personal favorite for "worst waste of codepoint award". Not only is "Floral Heart Bullet" not a character, they even included a reversed rotated version of it in Unicode. It's an icon, not a character.

U+203D


INTERROBANG


We really need a punctuation mark that says "WTF". This entire list is one big interrobang use case, am I right?


TIBETAN


The last one is not a character, but the entire Tibetan script. It looks absolutely beautiful.

If you have any questions related to this talk/blogpost, just put them in comments.

Friday, November 07, 2008

Iraq War scorecard

empezando a pelear by bdebaca from flickr (CC-NC-SA)
The Iraq War isn't over yet. Wars in the Middle East have nasty tendency of being long, bloody, and reigniting long after everybody thought they're done. However I would be really surprised if anyone moved between the losers and winners part of the scorecard. So let's go.

Losers

  • Saddam Hussein and Baath Party - before the war they had a safe grip on a failed country. If they could somehow get the world to add enough loopholes to the sanctions that would be plenty of money and power. Now they're all dead or broke and powerless.
  • American economy - war spending so far has been $550 billion, with new $12 billion being spent every month. That's not even close to the total cost, as the war is fought on borrowed money. According to study by Nobel Prize winner Joseph Stiglitz total cost of war in Iraq together with interest is around $3 trillion. That's $10,000 per person or over four Wall Street bailouts. This massive debt was undoubtedly one of the main triggers of financial system collapse and global recession, and is massively larger than subprime mortgages and other small failures. It wasn't the first war that bankrupted a country, and it won't be the last one.
  • George Bush and Republican Party - before failures in Iraq and economic collapse caused by this and other economic failures (massive deficits, irresponsible deregulation, procyclical monetary policy) nothing even suggested they were heading towards their greatest electoral failure ever. In spite of four years of Bush 2004 elections were a huge success and Democratic Party wasn't able to offer any attractive alternative to the voters. If it wasn't for failures in Iraq and resulting economic collapse Republican Party would most likely still be in power.
  • People of Iraq - political rights improved, as Iraqis can now vote (along tribal and religious lines) and have access to independent media, but that's small conciliation for death of 650,000 - 1,200,000 people, 4,700,000 people losing their homes, religious persecution of minorities, gays, women, people from the wrong tribe, and everybody with bad luck.
  • United States of America - the war crushed their economy, proved their military completely incapable of running a successful occupation (but very capable of destroying conventional army in a conventional war), and completely ruined their reputation and international standing. Americans don't understand the soft power, but EU managed to annex Central Europe this way, and Chinese are going to use it to build their global dominance.

Winners

All enemies of America were big winners of the war.
  • Iran - it's always nice to see your two biggest enemies - Saddam Hussein and USA - butchering each other. Religious Shiite government of Iraq is rather friendly towards Iran, and after USA got burned they lost a lot of power and influence in the Middle East. Other world powers like EU, China, India and Russia are much more friendly to Iran than USA was, so multipolar world is definitely in Iranian best interest. It's quite likely now that the new American administration will pursue normalization.
  • China - they never had any interest in Middle East, but weakening American economy is essential to them if they want to take over as the global superpower. According to IMF Chinese economy is about half as big as American economy. That's less than a decade at their current growth rate. Most modern empires started this way - economy and soft power first, military to back it up later.
  • Russia - was in truly dismal shape before the war. It was uplifted primarily by drastically higher prices of oil and other commodities, but it would never get the balls to invade a sovereign country allied with USA if American power wasn't as completely broken as it is now.
  • Islamists - secular Baathist government of Iraq was very hostile towards religion, now Islamists dictate how people live in Iraq. They're also been a resurgence of Islamism in other countries in the region, like Lebanon and Pakistan. Not much, but it reverses past trend of secularization, and from purely demographic perspective if secularists cannot convince religious people to join them, they're going to lose big.
  • Taliban - they almost collapsed after invasion of Afghanistan, but then somehow American focus got split, and crushing defeat turned into a lasting guerilla warfare in two countries. It's not a Taliban victory yet, but they might very well at least get into a power sharing agreement with current Afghani government, and get control over Sharia courts in exchange for leaving politics to others or something like that.
  • North Korea - they got a fucking nuke while Americans were busy. That's a country with economic power (PPP) similar to Luxembourg (city of less than half million people). Only part of it can be blamed on Iraqi War, but it certainly didn't help.

Mixed

  • Europe - Europeans participated in the war half-heartedly out of goodwill left from the Clinton era, sending some troops to the safest regions and trying to avoid casualties. Not only did they suffer military loses and financial costs, Americans proved they cannot even be relied as allies when they failed to protect Georgia against Russian aggression. On the other hand their loses were rather minor.
  • Israeli government - one the one hand they got rid of Saddam Hussein without paying the price. On the other hand the price was paid by their main ally USA which in future might be much less willing and able to intervene in Israeli interests. During this time Israel also lost a war against Hezbollah big way, resulting in major humiliation but no lasting damage and their PR in the region has never been good anyway.
Thinking about what various sides actually got out of the war is much more meaningful than babbling about military victories and propaganda political goals. The best example is the Second World War which was won by Stalin big way in spite of tens of millions deaths, and British Empire was a bankrupted loser in spite of not suffering too much in human or military terms. I also haven't listed Bin Laden and Al-Qaeda, because on global scale they're about as relevant as trolls from /b/.

Monday, October 20, 2008

Put your variables on diet

Svanspervot on a Chair by Steffe from flickr (CC-NC-SA)

There are all kinds of categorization schemes for programming languages, by paradigms or checklists of supported features. Categorizations criteria tend to be highly subjective (e.g. "builtin support for regular expressions"), useless (e.g. "significant indentation"), or both (e.g. "does it have a standard").

I want to propose a new categorization - objective, easy to evaluate, and at the same time exposing something very deep about programming languages.

I will divide languages into:

  • thin variable languages - where variables refer to data.
  • fat variable languages - where variables contain data. Variables can also contain references to data, but there's a distinction between direct and indirect access.


This division is very old. Assembly language is obviously a fat variable language, even though its variable system is very simple - registers and memory locations contain stuff directly, or contain references (memory addresses) to stuff. As languages need to be compiled to assembly plenty of high performance languages follow this road. Fortran and C variables are just assembly variables plus types. C++ didn't break up with it, it made container variables much fatter and much more complicated - RAII, copy constructors, assignment operators, and all the related mess. Java in spite of superficial similarity to C++ is definitely a thin variable language.

Thin variable languages are also very old. The original Lisp was the first language with thin variables, and all Lisp dialects, just like all ML and Haskell dialects, are thin variable languages. I don't think a single seriously functional language uses fat variables.

All object-oriented languages, most popular of them being Smalltalk, Ruby, Javascript, and (let's be charitable) Java - use thin variables too. There are some fat languages like C++ and Perl with objects bolted on top of them, but they are definitely not object-oriented, they just support some limited object functionality.

Scripting languages are interesting. Old languages like Unix shell have very fat variables, even though all variables are simple strings. Perl and PHP continue this tradition, but Python and Ruby are soundly in the thin variable camp.

Observations


Having categorized all popular languages let's do some observations.

  • All (pure and impure, strict and lazy) functional languages are thin variable.
  • All honestly object-oriented languages are thin variable.
  • Thin variable languages and garbage collected languages are very closely related categories. There are some reference counted languages in both camps (Perl, PHP on thick side, Python on thin side), but there seem to be no thin language with manual memory allocation or thick language with full GC.
  • All segfaulting languages (assembly, C, C++) use fat variables, but many fat variable languages are non-segfaulting (Fortran, bash, Perl, PHP).
  • Dynamic typing is on both sides (Perl/PHP vs Lisp/Ruby).
  • Explicit static typing is also on both sides (C/C++ vs Java).
  • Implicit static typing is only no the thin side (ML/Haskell) and is actually quite popular there.
  • Almost all thin languages have closures. A few languages like Python and Java have less than full closures, in form of named inner functions or anonymous inner classes. In both cases it's a syntactic not semantic limitation.
  • Almost no thick language has closures. A big exception is Perl, which has full closures.
  • Lexical and global scope exists on both sides, in almost every language.
  • Dynamic scope is unusual, but is supported on both thick (Perl), and thin (some Lisp dialects including the original Lisp, Emacs Lisp, and Common Lisp, but not Scheme) side.
  • Rich literal notation is supported (Perl vs Python/Ruby/Lisp/ML/etc.) and not supported (C/C++ vs Java) on both sides.
  • Macros exists only on the thin side (Lisps, Dylan, Nemerle). There doesn't seem to be any obvious reason for it.


I could go on. It actually surprises me how many semantic differences follow the thin vs fat divide, with Perl and Java being the biggest outliers (and also their derivatives like PHP and C#). These outliers are very interesting. Java's lack of power is definitely syntactic not semantic and there is plenty of JVM languages which are little more than fully compatible alternative syntaxes for Java with more expressive power. Nothing like that ever happened to popular fat variable languages like C/C++, which fail for semantic not syntactic reasons.

The biggest outlier on the fat side in Perl. While Perl was able to get almost 100% score on supported features checklist, it seems to be an evolutionary dead end. Every new thin variable language steals ideas from Perl, but Perl 6 effort was never able to transform the language, and Perl programmers have been leaving for Ruby and Python for years now.

If you're writing a new language today, and every programmer should do that, just forget about fat variables. They have one big advantage of allowing explicit memory management, what can still result in more memory efficient programs, but that's about it. Expressiveness of fat variable languages have been pushed to the limits by Perl, and it seems it cannot be pushed any further. Thin side is already far ahead, with Ruby, Scheme, Haskell and all the small research languages you've never heard of.

Monday, October 06, 2008

Rome Total War strategy guide

cat&stone by Ray Chang from flickr (CC-NC-SA)
I'm not sure why but all strategy guides I've seen on the Internet suggest gameplay very different from how I've been playing. It's quite likely that on higher difficulty the strategy I'm proposing doesn't work any more, so you should listen to them instead of me.

In a way of full disclosure I play with fog of war turned off (~ toggle_fow), Follow AI movement turned off (in menu when you start), and battle camera movement restriction turned off (~ toggle_restrictcam). I don't think it affects difficulty at all, it mostly makes interface nicer.

You already know map of Europe, and turning off FOW doesn't reveal enemy units or buildings, so you still need some spies to learn that. Battle camera restrictions make giving orders to your units in battle much harder, especially when the battle gets bigger or you get some reinforcements. It's just user interface pain in the ass, so I got rid of it. I also played with low unit size not to fry my GPU, but it seemed to handle it quite nicely, so maybe I'll up it to medium next time.

Economy

I think the most confusing part of Rome: Total War interface is city income. Real city income is revenue minus garrison cost. Income displayed by the game is revenue minus total cost of your army divided proportionally to city population. This leads to bullshit numbers, as revenue is not growing proportionally to population. So totally ignore city income figures.

You want as much revenue and as little spending as possible. Two most important revenue sources are sea trade, and land trade. Build best ports you can, and paved roads (or even highways) as early as possible, and get trade right with everyone. Trade-enhancing buildings like traders, market etc. are also very useful. Trade revenues grow only slowly with city size, so you basically want to have as many cities as you can, even if they're quite small, as long you they can build paved roads or port (that's level 2).

The second biggest source of income is farming and mining. Because it doesn't depend on city size at all, it's better to build basic farming and mining everywhere you can before you build advanced farming/mining. For 4000 you can build two mines in two cities, producing 400/turn. If you built mines+mines upgrade in one city instead it would cost you 5500 and produce only 350/turn. It's quite similar with farms - it's cheaper to have a little everywhere than to concentrate them all in one place.

Your next major source of income are wonders. Hanging Gardens give you +20% to farming income, unfortunately it's on the edge of the map. Colossus of Rhodes is even better as gives you +40% to naval trade income and is often barely defended by very weak Greek Cities faction.

Taxes aren't worth that much. There's some tricky equation to make them grow much slower than population, so big cities produce maybe ten times less in taxes than you'd expect. And in any case tax income is going to be much lower than trade income, and as higher tax rates reduce growth and public order I normally set all tax rates to Low by default. In smaller settlements it's important for the sake of growth, in larger settlements for the sake of public order. If you don't want to grow the settlement any more and it has high public order you could set tax rates higher, but it's usually not worth the bother.

Public order

It's important to keep your public order high, otherwise citizens can rebel damaging population, buildings, and your soldiers, brigands will spawn more often, and the whole city may even rebel throwing your garrison away. If a big city with a lot of military buildings rebels they will have a very respectable army and will be a major pain in the ass to retake.

Public order is determined by many factors. First is distance to capital, with very distant settlements getting even as much as -80%. So move your capital close to center of your empire every now and then and try to conquer in one nice block, not random settlements all over the map. Starting positions of Carthage, Greek Cities and Parthia are pretty bad for this reason. It will also make your empire easier to defend, another reason to try having solid empire. There's even a Javascript app to determine best location for your capital.

Another is culture penalty. I'm not exactly sure how it's calculated, but it's based on buildings from foreign cultures. There are six cultures - Barbarian (Britons, Dacia, Gauls, Germans, Scythia, Spain), Carthaginian (Carthage, Numidia), Eastern (Armenia, Parthia, Pontus), Egyptian (Egypt), Greek (Greek Cities, Macedon, Seleucid, Thrace), and Roman (Brutii, Julii, Scipii, Senate), and conquering within your culture should give you no penalty.

Government buildings and religious buildings having the biggest effect, so the first thing you want to do to reduce it is destroying any religious building they might have and building your own. Then upgrade all buildings you can, especially government building, as upgrading removes culture penalty for them. If you cannot upgrade, you can sometimes destroy and rebuild, what's going to cost you some money but it will work. Unfortunately you cannot destroy many buildings, especially the important government buildings, so you might need to live with some culture penalty forever.

The next important factor is unrest. Unrest starts high when you conquer a city, and then goes down by 5% until reaching the base level, but only if public order is at least 75%. So if you can get a conquered city to 75% by temporary measures like large garrison and good governor then just by staying in the city for a few turns the unrest will disappear. On the other hand if you cannot even reach 75% you will have pretty much permanent problems with the city. Well, not really permanent as rioting kills of citizens, what solves your problem slowly, but if you think the city is going to be a problem, just enslave it, and by the time it grows back it will have no unrest. Basic unrest rates are 0% for most cities but can be 15% for many and even 30% for a few like Jerusalem.

The next factor is squalor, based on city size. Big cities simply have high squalor, and it makes people unhappy. That's why when you're conquering a new city, with high distance to capital, high culture penalty, high unrest, and high squalor, it will be totally ungovernable. Better to enslave or even exterminate its population to reduce squalor, then quickly raze their temples and build your own to reduce culture penalty, keep large garrison in it for a few turns to reduce unrest, and keep capital close to center of your empire to make distance to capital penalties manageable.

To increase public order you can build buildings, especially religious buildings which usually give you +10% increase per level. Some give you only +5% and some other bonus, so you need to decide if the extra bonus is worth losing 5-25% of public order (depending on city size, unfortunately you cannot change your mind easily later, you'd need to raze the temple completely and start from shrine). Depending on culture there are some other buildings like execution square, odeon, tavern etc.

Wonders are also helpful here. Statue of Zeus at Olympia gives you permanent bonus to all your settlements, capturing any wonder gives you a high bonus for a few turns but it wears off too quickly to be worth relying on.

Influence rating of the governor improves public unrest, but you won't have enough governors with high influence for all of your empire. I never did it, but maybe you could try a shitty governor and building an academy for him to get better stats. Governors can also get useful retinue from religious building.

A very important way of improving public order is garrison. The most important fact is that the bonus is based on ratio of total number of troops to total population. So 30 peasants are worth as much as 30 cataphracts. But everything including Town Guard is significantly more expensive per person than peasants - so seriously use only peasants as a garrison. Using serious combat troops for garrison in all your cities is going to cost you a lot of money, and you cannot even use them for crushing rebellions, as then you'd need another way of keeping your public order up.

Also - only use garrisons in small to medium settlements. In a small settlement, one stack of peasants can give you +80% garrison bonus (you can never go higher than that) and will cost you 100 denari/turn. In a large settlement, one stack of peasants will give you less than +5% and sitll cost you 100 denari/turn. Every other method costs the same no matter the settlement size. So it simply makes no sense to use garrison as a way of keeping large settlements happy, unless you positively have to. Much more effective ways are low taxes, religious buildings, governor influence, games, wonders etc. Oh and having absolutely no troops in a settlement gives it extra -15%, not to mention making it super easy to lose, so keep at least some peasants in all of them.

Tactics

Most strategy guides talk a lot about advanced unit types, but unless you play very slowly you will only get them in the end game, when you're so strong that it doesn't really matter that much.

A very important unit type are peasants, which you should use exclusively for garrisoning, but never for battles. Peasant garrisons are half the upkeep costs of the weakest battle units, so use them. If you have some spare peasants you can take them with your army so they can serve as an occupying force for the captured settlements, while your real forces go forward. Or maybe if someone needs to hold battering rams and you have pure-cavalry army, but that's already getting somewhat dubious.

One of the nicest things about Rome: Total War is richness of unit types and tactics you can develop with different combinations of unit types against different combinations of enemy unit types.

Many tactics can be formed around phalanges. First you take a wall of any units capable of forming a phalanx, which most factions can get almost immediately. Then you make either your opponent run into the wall of spears, or attack your opponent with this wall. If you set guard mode on your units will try to keep the wall of spears, if you set it to off they will break it to attack the enemy. Either can be useful depending on circumstances.

Even a phalanx formed with very cheap units can kill most of enemies. Non-phalanx infantry, and light cavalry will simply get massacred. With heavy cavalry, elephant, and chariots it's not that simple. Depending on your and their strength they might be killed by your phalanx (instant win) or break it (instant lose), but often they will simply get entangled in it without getting killed. Now it's time to attack, either with adjacent phalanx unit, or even better with your cavalry attacking from a side or a back. You will have some loses in your cheap phalanx, but you'll kill a much more expensive heavy cavalry unit this way, for a major win.

To fight with other phalanx you simply form a pushing match. If you have stronger phalanx, especially one with longer spears, you can outstab the enemy. If not, just attack the enemy phalanx with some cavalry while they cannot move.

The main problem with phalanges is that they are very vulnerable from flanks and back, so you want to keep some cavalry, or at least some non-phalanx infantry on both wings. Not only will it protect your phalanx, they can attack and destroy any enemy captured by it.

If enemy has some cavalry, you might want to take all your cavalry, charge into his, and try to destroy it before the infantry battle begins. Cavalry has very high charge bonuses so by properly maneuvering you can do disproportionate damage even without very strong units. If they rout, don't follow but go back to wings of your formation - you won't catch horses with horses, and your cavalry is too important to waste just yet. Even if the enemy reforms they won't have much morale left and you can rerout them later with a simple charge.

It's important to have cavalry superiority, even though the cavalry won't win the battle for you. If you charge at a phalanx, or even straightforward melee infantry, you're going to suffer heavy loses. Cavalry is strong because of high charge bonus, if they're entangled they suddenly become very vulnerable. There are some units you can safely charge at - missile units like archers/bowmen, peltasts/velites/skirmishers etc.; very light infantry like rebel peasants; other cavalry units, including generals (who are weak without their bonus charge); and later artillery units. Charging at anything else means high loses even with relatively heavy cavalry, and is outright suicidal for light cavalry. Even if some unit is weak, you can still suffer if there's a strong unit in its proximity. So obviously bowmen shouldn't be left without protection.

Another important thing you can do with cavalry is killing off routing infantry units. The difference between defeated army suffering 30% loses refilled in the first visit to nearby city, and 90% loses that are impossible to refill comes from your cavalry. Normally infantry cannot catch routing infantry, and cavalry cannot catch routing cavalry, so the only kind of massacre you will be able to do is cavalry massacring routing infantry. Even the cheapest light cavalry is very important just for this purpose.

If you have cavalry superiority you can get some missile units, or later some artillery. They are very weak against cavalry, and it's not too easy to protect them using just infantry after the chaos of the battle starts. Your tactics depends on range of your missile units, so usually it makes no sense at all to have multiple kinds of missile units in the same army. Either take all bowmen, or all peltasts, or all onagers, or some other consistent army.

Missile units cause free damage to your opponents. They can try to stand it out until you run out of ammo and suffer heavy casualties, or else they'll be forced to attack you on your terms. If the enemy has no cavalry and no missile units (or you just killed them with your cavalry), you can even send your missile units in skirmish mode way in front of your main units to pepper them with arrows and javelins. Normally however you want to keep them close to your units, either behind your main infantry line, or just in front and then making them fall back when the attack finally happens.

Missile troops alone are not going to win the battle. But with enough damage the enemy will be losing morale and will rout more easily. After some of the enemy starts routing the battle is pretty much won, and just use your cavalry to kill off what's left. Missile units are also quite useful at finishing off routing units.

There are a few more tactics you can try. Romans have strong infantry units that throw javelins before attacking. It's like an ok missile troop and a good melee troop in one unit. If you stand against enemy phalanx with Roman infantry try splitting your troops and attacking from flanks. It might work just fine.

Chariots are like heavy cavalry except you can have them very early in the right faction like Egypt and Seleucids. They have even lower defense than normal cavalry, so try charging through enemy unit to the other site, not on enemy unit. Also, never let enemy missile units fire at your chariots, or anybody to attack a standing chariot. It takes some practice to learn how to use chariots properly, but it's fully worth the effort.

If you have mixed heavy and light cavalry and want to charge a strong unit, charge with your heavy cavalry first, immediately followed by the light cavalry. This reduces your loses a lot. On the initial charge will still be capable of defending itself, so a heavy charge is needed. Just afterwards it will be completely disorganized so even light cavalry will be able to make a kill.

Sieges

You're not fighting for the sake of fighting, you're fighting to conquer, so many battles will be sieges. The good news is that in early game most settlements will at most wooden wall. Just make one battering ram, and here we go. Easy way to win a siege is having missile units and cavalry. Take battering ram and missile units to the gates, and fire at anybody standing next to the gate. Because unlike in a field battle they're not going to charge at you, if you're patient you can empty all your ammo on them and inflict severe loses, no need to hurry with the ram.

Once it's done take your cavalry and charge at everybody. Hopefully there aren't any strong phalanges in the vicinity of the gate now that you peppered them with arrows. Everything else will just rout when charged. It's important to kill them off now, otherwise they'll run towards the town square and reform there. As you go toward the town square just charge on every unit you find on the streets. AI tends not to offer any organized resistance on the streets, so it's going to be an easy kill. You may find some serious resistance in the town square, hopefully by this time you inflicted sufficient damage that it's just a matter of finishing everyone off.

In my experience for settlements without at least stone walls, AI defending army is a hell lot weaker than the same army would be on a field.

It's much much worse if they have stone walls and some missile units to man the walls. Because they're higher and protected by walls they're easily ten times as deadly as your missile units shooting at them. Add to that fire coming from towers, and reinforced games slowing down ramming a lot, and you can lose a quarter of your army before even coming inside.

You can obviously starve them, forcing them to attack you, but that's going to be very slow. Fortunately there's a much better way. First you need at least one hole in the walls. In can be gate opened by your spy, or a sap point, or hole made by your onagers if you already have them (onagers come late in the game, but so do stone walls). Then charge with all your cavalry, the more and heavier the better, and go towards the city center as soon as possible. By not wasting time on the gates and moving all your units at an instant you won't get fired upon that much. If you take the city center the enemy has 3 minutes to take it back or they lose and all die, so they'll have to go off their comfy wall posts and fight on the street, and they really suck at it.

If you make more holes you can choose one that will take you away from the walls as soon as possible, and that's the least defended. If you have some artillery you can even try to shoot at units protecting the hole to make it easier for your cavalry to charge over them. Unfortunately bowmen won't do, as enemy bowmen have better range while on the walls.

If this siege tactic won't work, well starving them is always an option.

I wouldn't depend on city defenses too much. Walls delay the enemy, but you still need enough field army to defeat him. Otherwise he can just starve you off.

Strategy

In Rome: Total War there's a very smooth transition between high level strategy and battle tactics, with both level affecting each other. Your strategic choices will have major impact on your battles, and your battles will have major strategic implications.

Unfortunately diplomacy is pretty much broken, and all AIs will attack you sooner rather than later, so you cannot go to the very high level and try forging one alliance against another alliance. Sadly it's like that in almost every strategy game I can think of. At least everybody against the player is better than everybody pussying out from every fight and letting you do whatever you want like in Colonization. So don't think too much about diplomacy.

You should have some idea on how you're going to play. In my last game with Egyptians I took all my armies, bought all the mercenaries I could, and expanded in three directions at once, west to Siwa and Cyrene, east to Petra, and Bostra, and north-west to Kydonia, and Sparta. Initial battles were tough, but this way I had a decent empire before anybody could even react. This plan was very ambitious, and it's quite likely that it might not have worked on higher difficulty levels, but it's a good idea to have some plan before starting to play.

It's important to move early, as you get some decent army to start with, often with units that you won't be able to make for a long time, while everybody's armies are still quite small and many settlements are barely defended, especially the rebel ones.

It's plenty of fun to start a war, but before you do think how you're going to end it. Can you take all enemy settlements quickly? Or at least all that are nearby, if the enemy is all over the place like Greek Cities, Carthage, and Parthia.

If you don't think of it, you might get into a long trench warfare that someone else will use to backstab you. In my last game I wasn't thinking enough about this and at one point I had wars with Parthia, Armenia, Seleucids, Pontus, Greek Cities, Macedon, Thrace, and all four Roman factions.

Your armies are investment. Don't keep them in secure cities. Actually don't keep them in cities at all - peasants should patrol cities, all your armies should be in the field fighting. Upkeep is very high compared to initial cost. Typically cost is about three turns worth of upkeep. So if you have a unit that's going to spend four or more turns doing nothing it's cheaper to disband it and make a new one when it's needed. You cannot make them as fast as you'd like to and you'd lose all experience, so maybe the threshold is higher than four, but armies should fight.

If you need some troops fast, and are far from your lands you might want to get some mercenaries, but normally cheaper and stronger units are available in your cities. Exception are units that you cannot produce but would like to, like Sarmatian Cavalry, and Createan Archers, depending on your faction.

Bribing is even more dubious practice. It costs more to bribe than to recruit an army (even mercenary army), defeat whoever you were thinking of bribing, and disband just afterwards. Bribing should be thought of as a really special case situation. Maybe if you want to bribe generals, because you cannot normally recruit them. But you can recruit a unit, take it into a fight, and you have a chance of getting "man of the hour" free general. I got plenty of generals this way.

Navy is expensive. You can do two things with Navy. In early game you want to transport armies from one coast to the other in a single turn (or otherwise as quickly as possible), so they are never vulnerable. There's no point fighting at this point, unless someone is trying to blockade you and you really have no choice.

The other thing is total domination of a sea. If you have plenty of money you can buy enough ships to take total control of a large body of water, like "whole Mediterranean sea east of Sicily". Just buy loads of ships, attack everywhere it in, then you can blockade everything, and safely transport all your troops.

There's little reason to go between the two extremely. Semi-strong navy that won't protect your transports is just throwing money away. If your navy isn't useful any more, just disband it.

When you're waging a war on a strategic level it's important to achieve local superiority of force. It doesn't matter who's got more units on the entire map. What matters is who's got more and better units in the place of battle. So go completely out of proportion, committing all your armies you can to the small part of the front where you want to achieve your objectives, like conquering enemy city, or destroying his not very strong armies. If AI has weakly protected settlement, take your big army and take it. If it has medium sized army in the field, crush it with army twice the size. If it took all its strongest units and heads towards your capital, raid his territory and force it to go back home.

You will be much more mobile if you have paved roads, a bit of navy, and no sense of fear. It's even more important to have all your battle troops on the front, not back home patrolling streets.

The biggest factor however is economy strong enough that you can easily raise new armies and replace your loses while the opponent cannot, even if they manage to win a few big battles, because that's how Rome became great!

Monday, August 25, 2008

Black hat SEO on Amazon

What happens after mom spends a weekend in Mexico by Malingering from flickr (CC-NC-ND)

Amazon started as a bookstore, then after a brief period of being a patent troll it became an generic Internet shop, now it seems to be turning more and more into a shopping search engine, with thousands of sellers using it as an intermediary between themselves and the customers. I'd really enjoy the fight for shopping search engines between Amazon-style thick intermediaries and Google Products-style thin intermediaries. For now I must say Amazon is much more useful than Google Products, but maybe some day with some open standard shopping metadata the fight will be more even.

And just like every search engine Amazon starts to see the problem of black hat search engine optimization. Some time ago I was looking for earphones extension cord on Amazon, and the first results was one by Belkin with cost of £0.01. That's a pretty good price except there was a shipping cost of £4.50 per item, so they were basically abusing the search results screen.

Right now it seems Belkin isn't doing this anymore. I guess someone at Amazon noticed the abuse and wrist slapped them. Amazon as a thick intermediary has plenty of power over the sellers to control abusive behavior. It would be much more difficult for Google Products to enforce good behavior. Here's my prediction:

If thin intermediaries for shopping like Google Products ever become widespread, abusing behavior like hiding shipping costs, transaction costs, taxes and other fees will become as common as it is now in the airline industry.

Sunday, August 03, 2008

Highly innovative YCombinator startups

Lolcat by taw based on Blogging for Cats by Vicki's Pics from flickr (CC-NC-SA)

A couple of weeks ago Paul Graham wrote a list of startups Y Combinator wants to fund. That's an interesting list, but I'd rather like to know what kind of startups they actually funded, and even better what kind of startups that they funded became successful. Every step on the road from a plan to a success can change the list quite significantly.

While I was somewhat interested in it, up till now I was also too lazy to do the research. Fortunately a recent thread on Reddit did it for me and provided an official list of Y Combinator startups that are considered "successful", for some definition of "successful". I'm not sure if "getting bought" is really the apex of success - it basically means you lose all control over your startup and work at a huge corporation again, exactly what you were trying to escape. At least unless they pay you enough money to buy a small island and retire, but press releases rarely mention how much money the founders got out of the deal.

So here's my list of Y Combinator successful startups with a brief explanations of what they're all about. The descriptions might be less that 100% accurate, but that's the impression I got from 5 minutes of interacting with their websites, and if an user doesn't get what your website is about in 5 minutes then fix your website, don't blame the user.

  • Infogami. Wiki-style website builder. I don't see what's the big deal.
  • Reddit. Just like Digg except without all the Digg users, so at least at first comments were of higher quality. Now that it got bigger it's just like Digg, except that you don't have to waste your precious time writing descriptions of your submissions and have more time to read how Ron Paul used Lisp to impeach Bush. I guess I shouldn't be so cynical as I'm using it as my main source of the news and one third of my readers come from Reddit, but cynicism is one of Terms & Conditions you need to agree to when you start a blog.
  • ClickFacts. Online ads fraud detection. I don't know how well it works, but it looks the most innovative of them all. By the way isn't it kinda ironic that geeks do ad-supported startups and block all ads at the same time?
  • Zenter. Web clone of PowerPoint, website died after Google bought them.
  • Auctomactic. Another user interface for eBay.
  • Parakey. Some sort of "Web operating system". They were bought by Facebook, but their website is dead, and it's not obvious if they actually built anything beyond buzzwords.
  • Anywhere.FM. Website where you can upload MP3s you own, play on your other computer, and then pay RIAA for it. So much for "A cure for the disease of which the RIAA is a symptom".
  • Omnisio. YouTube clone with a bunch of extra nifty features for cutting and annotating videos. They have nice screencasts. Too bad you cannot annotate Colbert with it, that would be awesome.
  • Xobni. Microsoft Outlook plugin for social networking. Kinda client side version of what Trampoline Systems is doing on server side. The obvious problem with pure client side solution like that is that you probably already know about your direct contacts, and you won't learn anything about your second-level connections without access to your first-level connections' mailboxes. So I'm not sure how much value there is it in, not to mention it only supports one bad email client on one bad operating system.
  • Scribd. You thought PDFs are bad? Now you can upload them to Scribd and make them even worse by displaying them in a shitty Flash applet. Scribd has a distinction of being the Y Combinator startup with highest chances of making the Web even worse than it is now. I seriously hope they never succeed.
  • Wufoo. Online builder for web forms. Nifty little app.
  • VirtualMin. Just like WebMin except on the Web. I think the main problem with most shared hosting/DNS registrars s not lack of GUIs, but too many crappy GUIs and limitted control over direct shell access or some sort of API.
  • SnapTalent. Use targeted online ads for recruitment. I like the idea, I just don't think it's likely to work, as contrary to the popular opinion most smart people do not work at Google. They probably don't do it, but it made me see a fresh wave of startups approaching, all based on a:visited security hole. a:visited is a fundamental problem with the web security architecture and isn't going to be fixed anytime soon, as people like marked visited links and CSS too much, and the only simple way to fix it is getting rid of either one of them. So from now on every website has access to your full history, and I know that you've visited: but not: Digg Reddit YouTube RedTube XTube YouPorn Facebook Orkut Adult Friendfinder. (it doesn't require JavaScript or cookies to track users, CSS background images are good enough). Architectural problems like that are fascinating. Even when you think you've covered every possible security issue, somebody comes up with an attack that cannot be fixed except with major rearchitecture of the Web. My favourite example is the Epilepsy Foundation attack (Encyclopedia Dramatica is for things Wikipedia doesn't have balls to write about). I don't think anybody expected that an animated GIF could be more than an annoyance and actually cause people seizures. No way to fix it now without breaking the Web, just like there's no way to fix a:visited attack. I'm getting sidetracked here, but my dear readers seem to like it when I'm getting sidetracked.
  • Justin.TV. Another YouTube clone. My first impression is that it's a lot less interesting than Omnisio.
  • Weebly. Another website creator.
  • Loopt. Let friends spy on you with their mobiles. Some people might find it usefull, but I don't get the whole mobile thing. Skype, email and IM are vastly superior for communicating with people than phone calls and SMS texting, cost a fraction of them, and most of the time people do have Internet access so they don't need mobiles. I just don't get it.
  • RescueTime. A service which records your browsing habits to sell to advertisers and CIA, I mean to help you avoid procrastination. If they convince people to install it they have the chance to be the new Google and earn billions on ads.

So most of them seem follow pattern of "just like X only Y", where Y more often than not equals "online". Don't get me wrong, I'm not saying that's a bad thing - most of the progress in the human history follows the "just like X only Y" pattern, and with sufficient number of "only Y"s you can create something that creators of X never dreamed of.

It's kinda proving that Paul Graham was right saying the idea doesn't really matter, as in most of these startups it was good execution not brilliant idea what made them successful. So go ahead and start your startup.

EDIT: As some people on Hacker News noticed, I was wrong, and justin.tv is for live streaming with webcams, not for recording YouTube-style videos using webcams as I guessed from looking at their website and reading their FAQ. The point of the article was not a detailed review of every startup on the list, but getting a general idea of what kind of startups YCombinator funds. Sorry if I haven't been clear about that. My conclusion that most of the startups follow the "just like X only Y" still follows, in case of justin.tv for X="Youtube" and Y="live not prerecorded".