Alignment Rating (AR) is a measure used to help protect weaker players from being repetitively attacked by stronger players. Everytime a person sends out an attack or is attacked, their alignment rating will either go down or up depending on the relative size of the attacks.
When a city is first created, its alignment rating is set to 50. This is its "natural value." If the city is attacked by a much greater force and it has no protections, its alignment rating will increase. Once the alignment rating hits 75, only the top 25% of the city's resource will be able to be looted. For example, if the city has a cap of 2000 wood then only the wood over the first 1500 will be up for grabs. If the alignment reaches 90, then buildings will only take 10% of the damage dealt to them.
Once the city sends out an attack, its alignment rating will decrease. The amount that the alignment rating increases/decreases depends on the relative size of the attacks. Therefore, attacking other players of the same magintude or stronger won't affect your alignment rating. The alignment rating will also increase/decrease automatically every 30 minutes back to its natural level of 50.
This mechanic is not in place to prevent fighting. It is in place only to protect players from being repetitively attacked. Players that are bashed often quit since they are unable to progress in the game and that's just not really any fun.
PS: Idle cities will not receive any bonuses from alignment ratings. So farm away on them!
Here's a quick breakdown on the numbers:
Case 1: Attacker has LESS upkeep than Defender: NO change in AR
Case 2: Attacker has MORE upkeep than Defender: AR is calculated by (atkUpkeep / defUpkeep - 1) OR 4, whichever is LOWER. That number is then multiplied by the number of rounds the battle lasted divided by 20. Example: Attacker has 100 upkeep, defender has 50. (100 / 50 - 1) = 1. Min (1,4) = 1. Battle lasts 15 rounds. 1 * 15/20 = 0.75 AR for the battle. That means the attacker's AR goes DOWN by 0.75 and the defender's goes UP by 0.75.
Case 3: Defender has 0 upkeep. In this case, AR is calculated strictly by 4 * battle rounds / 20. If the battle lasts 10 rounds before you retreat, the attacker goes up 2 AR and the defender goes down 2 AR.
AP naturally returns to 50 at a rate of 0.25 AR per hour. If I have 40 alignment, and don't send out any attacks or get attacked, 4 hours later my AR will be 41.
If you are curious about the design behind AR, check out the official alignment rating spec .