update
This commit is contained in:
@@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from tft.model.baseline import classify_role, unit_value
|
||||
from tft.model.calibrate import spearman
|
||||
from tft.model.score import active_trait_tiers, score_board
|
||||
from tft.model.score import active_trait_tiers, board_profiles, score_board
|
||||
|
||||
STATIC = {
|
||||
"units": {
|
||||
@@ -28,8 +28,15 @@ STATIC = {
|
||||
},
|
||||
}
|
||||
|
||||
ARTIFACT = {"meta": {"set": 17}, "static": {**STATIC, "items": {}, "augments": {}},
|
||||
"roles": {}, "learned": {}}
|
||||
ARTIFACT = {
|
||||
"meta": {"set": 17},
|
||||
"static": {
|
||||
**STATIC,
|
||||
"items": {"TFT_Item_InfinityEdge": {"effects": {"AD": 0.35, "CritChance": 35.0}}},
|
||||
"augments": {},
|
||||
},
|
||||
"roles": {},
|
||||
}
|
||||
|
||||
|
||||
def test_unit_value():
|
||||
@@ -57,19 +64,30 @@ def test_score_ordering():
|
||||
assert score_board(strong, [], ARTIFACT) > score_board(weak, [], ARTIFACT)
|
||||
|
||||
|
||||
def test_active_trait_beats_inactive():
|
||||
pair = [{"api_name": "TFT17_A", "stars": 1, "items": []},
|
||||
{"api_name": "TFT17_B", "stars": 1, "items": []}]
|
||||
solo_sum = score_board(pair[:1], [], ARTIFACT) + score_board(pair[1:], [], ARTIFACT)
|
||||
assert score_board(pair, [], ARTIFACT) > solo_sum
|
||||
|
||||
|
||||
def test_items_increase_score():
|
||||
bare = [{"api_name": "TFT17_B", "stars": 1, "items": []}]
|
||||
with_item = [{"api_name": "TFT17_B", "stars": 1, "items": ["TFT_Item_InfinityEdge"]}]
|
||||
assert score_board(with_item, [], ARTIFACT) > score_board(bare, [], ARTIFACT)
|
||||
|
||||
|
||||
def test_augments_ignored():
|
||||
board = [{"api_name": "TFT17_B", "stars": 1, "items": []}]
|
||||
assert score_board(board, ["TFT17_Augment_X"], ARTIFACT) == \
|
||||
score_board(board, [], ARTIFACT)
|
||||
|
||||
|
||||
def test_board_profiles_roles_and_unknown_units():
|
||||
board = [{"api_name": "TFT17_A", "stars": 1, "items": []},
|
||||
{"api_name": "TFT17_B", "stars": 1, "items": []},
|
||||
{"api_name": "UNKNOWN", "stars": 1, "items": []}]
|
||||
profiles = board_profiles(board, ARTIFACT)
|
||||
assert len(profiles) == 2 # unbekannte Units fallen raus
|
||||
tank, carry = profiles
|
||||
assert tank["defensive"] and not carry["defensive"]
|
||||
assert tank["def"] > carry["def"]
|
||||
assert carry["off"] > tank["off"]
|
||||
|
||||
|
||||
def test_spearman():
|
||||
assert spearman([1, 2, 3, 4], [10, 20, 30, 40]) == pytest.approx(1.0)
|
||||
assert spearman([1, 2, 3, 4], [40, 30, 20, 10]) == pytest.approx(-1.0)
|
||||
@@ -88,39 +106,7 @@ def test_craftable_item_pool():
|
||||
assert craftable_items(items) == ["TFT_Item_InfinityEdge"]
|
||||
|
||||
|
||||
def test_stat_mults_rank_within_cost():
|
||||
from tft.model.baseline import compute_stat_mults
|
||||
|
||||
def unit(hp, armor, ad, aspd):
|
||||
return {"cost": 2, "traits": [], "role": "Tank",
|
||||
"stats": {"hp": hp, "armor": armor, "magicResist": armor,
|
||||
"damage": ad, "attackSpeed": aspd, "mana": 60,
|
||||
"initialMana": 0, "range": 1}}
|
||||
|
||||
units = {"tanky": unit(900, 60, 45, 0.6), "avg": unit(700, 40, 55, 0.7),
|
||||
"weak": unit(550, 25, 45, 0.6)}
|
||||
mults = compute_stat_mults(units)
|
||||
assert mults["tanky"] > mults["avg"] > mults["weak"]
|
||||
assert all(0.9 <= m <= 1.1 for m in mults.values())
|
||||
|
||||
|
||||
def test_stat_mults_identical_units_are_neutral():
|
||||
from tft.model.baseline import compute_stat_mults
|
||||
from tests.test_sim import make_static
|
||||
|
||||
mults = compute_stat_mults(make_static()["units"])
|
||||
assert all(m == 1.0 for m in mults.values())
|
||||
|
||||
|
||||
def test_stat_mult_raises_score_legacy():
|
||||
from tft.model.score import score_board_legacy as score_board
|
||||
|
||||
art = {**ARTIFACT, "stat_mults": {"TFT17_B": 1.1}}
|
||||
board = [{"api_name": "TFT17_B", "stars": 1, "items": []}]
|
||||
assert score_board(board, [], art) > score_board(board, [], ARTIFACT)
|
||||
|
||||
|
||||
def _mech_artifact():
|
||||
def _built_artifact():
|
||||
from tft.model import artifact as artifact_mod
|
||||
|
||||
static = {
|
||||
@@ -143,30 +129,18 @@ def _mech_artifact():
|
||||
return artifact_mod.build(static)
|
||||
|
||||
|
||||
def test_mechanical_balanced_beats_lopsided():
|
||||
from tft.model.score import score_mechanical
|
||||
art = _mech_artifact()
|
||||
def test_balanced_beats_lopsided():
|
||||
art = _built_artifact()
|
||||
balanced = [{"api_name": "TANK", "stars": 1, "items": []},
|
||||
{"api_name": "CARRY", "stars": 1, "items": []}]
|
||||
tanks = [{"api_name": "TANK", "stars": 1, "items": []} for _ in range(2)]
|
||||
assert score_mechanical(balanced, [], art) > score_mechanical(tanks, [], art)
|
||||
assert score_board(balanced, [], art) > score_board(tanks, [], art)
|
||||
|
||||
|
||||
def test_mechanical_items_and_stars_raise_strength():
|
||||
from tft.model.score import score_mechanical
|
||||
art = _mech_artifact()
|
||||
def test_items_and_stars_raise_strength():
|
||||
art = _built_artifact()
|
||||
base = [{"api_name": "CARRY", "stars": 1, "items": []}]
|
||||
starred = [{"api_name": "CARRY", "stars": 2, "items": []}]
|
||||
equipped = [{"api_name": "CARRY", "stars": 1, "items": ["SWORD"]}]
|
||||
assert score_mechanical(starred, [], art) > score_mechanical(base, [], art)
|
||||
assert score_mechanical(equipped, [], art) > score_mechanical(base, [], art)
|
||||
|
||||
|
||||
def test_mechanical_recognized_trait_buffs_stats():
|
||||
from tft.model.score import score_mechanical
|
||||
art = _mech_artifact()
|
||||
pair = [{"api_name": "TANK", "stars": 1, "items": []},
|
||||
{"api_name": "CARRY", "stars": 1, "items": []}]
|
||||
solo_sum = (score_mechanical(pair[:1], [], art)
|
||||
+ score_mechanical(pair[1:], [], art))
|
||||
assert score_mechanical(pair, [], art) > solo_sum
|
||||
assert score_board(starred, [], art) > score_board(base, [], art)
|
||||
assert score_board(equipped, [], art) > score_board(base, [], art)
|
||||
|
||||
Reference in New Issue
Block a user