發表: 63
誰瀏覽過: 560 users

I wanted to write this down somewhere, so here it goes: as Ivan stated back in 2015, there's really no %. There's no concept of "priority" in the code, just "order and random rolls".

We manage a list of Turn Actions for every player, and they're processed as follows. Let's assume player A attacked player B, while player B tried to run away:

1. Pick a random player.

2. Pick his next action (if any, if no more moves just pick another player). Let's assume player A's action is selected.

3. See where the stack wants to go (e.g attacking another city or unit, or just moving away). If he's not being attacked, complete the move successfully. Mark his target as "attacked".

4. Finish the action, and go again from step 1. Let's assume we now pick player B's Turn Action. He wants to move his units away.

5. Now, we check that this stack is being attacked and it is in defense position. We will calculate the chances of this stack being intercepted: we will roll a random number between 0 and 1. If the number is higher than~~(AttackerArmyCount / (DefenderArmyCount * 2))~~ **[EDIT: the actual formula is AttackerArmyCount / DefenderArmyCount * 2, which is processed as (AttackerArmyCount / DefenderArmyCount) * 2.** then the stack escapes.

This system has been in place for more than 3 years. Updates like this one from 2012 are either outdated or weren't implemented as-is. This explanation reveals lots of unintended behaviors, especially when you consider what a Turn Action really is. I hope it sheds some light for those interested in this system.

**EDIT:** please also check Dave's explanation for more details about this mechanic.

We manage a list of Turn Actions for every player, and they're processed as follows. Let's assume player A attacked player B, while player B tried to run away:

1. Pick a random player.

2. Pick his next action (if any, if no more moves just pick another player). Let's assume player A's action is selected.

3. See where the stack wants to go (e.g attacking another city or unit, or just moving away). If he's not being attacked, complete the move successfully. Mark his target as "attacked".

4. Finish the action, and go again from step 1. Let's assume we now pick player B's Turn Action. He wants to move his units away.

5. Now, we check that this stack is being attacked and it is in defense position. We will calculate the chances of this stack being intercepted: we will roll a random number between 0 and 1. If the number is higher than

This system has been in place for more than 3 years. Updates like this one from 2012 are either outdated or weren't implemented as-is. This explanation reveals lots of unintended behaviors, especially when you consider what a Turn Action really is. I hope it sheds some light for those interested in this system.