One deterministic unit-activation ordering strategy. 更多...
#include <TurnPolicy.h>
Public 成员函数 | |
| virtual | ~ITurnPolicy ()=default |
| I turn policy. | |
| virtual std::string_view | id () const noexcept=0 |
| Return the stable protocol id this policy is registered under. | |
| virtual TurnOrder | order (const Battle &battle, const UnitOrder &left, const UnitOrder &right) const =0 |
| Report the order of two units in the current round. | |
| virtual ChargeModel | chargeModel (const Battle &battle) const |
| Declare the charge rule this policy schedules by. | |
详细描述
One deterministic unit-activation ordering strategy.
A policy answers exactly one question — which of two units acts first inside a round — so policies cannot reach into resource resets, events or objectives. The caller owns the canonical-subject tie-break, which means every policy is automatically deterministic on equal keys and cannot restate that rule.
Implementations are stateless value-like objects shared across battles. They must be pure: no clock reads, no random draws, no mutation of the battle.
在文件 TurnPolicy.h 第 103 行定义.
构造及析构函数说明
◆ ~ITurnPolicy()
|
virtualdefault |
I turn policy.
成员函数说明
◆ chargeModel()
|
virtual |
Declare the charge rule this policy schedules by.
- 参数
-
battle Read-only battle, for policies whose charge rule depends on it.
- 返回
- The charge rule; the default reports "no charge model".
- 备注
- Implementations must be pure and must return the same value for the same battle state: the rule is applied to persisted per-unit charge, so a rule that changed between calls would make a restored battle schedule differently from the one that was saved. A rule with
threshold > 0must advance some unit's charge every round, or the round machine can never make progress;BattleSystem::startrefuses a battle whose units could never reach that threshold.
在文件 TurnPolicy.cpp 第 80 行定义.
◆ id()
|
pure virtualnoexcept |
Return the stable protocol id this policy is registered under.
◆ order()
|
pure virtual |
Report the order of two units in the current round.
- 参数
-
battle Read-only battle, for policies that depend on round or phase.
- 返回
- Which unit acts first, or
Equivalentwhen the policy has no opinion and the caller's canonical tie-break must decide.
- 备注
- Must be antisymmetric and transitive over the three outcomes, so the caller can sort with it:
order(a,b)andorder(b,a)must not both report a winner, andEquivalentmust be consistent.
该类的文档由以下文件生成:
- src/modules/tactics/TurnPolicy.h
- src/modules/tactics/TurnPolicy.cpp