* human-like model * kivy 2 * uv * window location fix * macosx package no thanks to jules who is a derp, but cloud is hapl and fix. * settings gui a bit clearer * better ci i hope --------- Co-authored-by: TuNanTang <tunantang@aliyun.com> Co-authored-by: jtkelm2 <feryllcuber@gmail.com>
52 lines
2.1 KiB
Python
52 lines
2.1 KiB
Python
import os
|
|
|
|
import pytest
|
|
|
|
from katrain.core.ai import ai_rank_estimation, generate_ai_move
|
|
from katrain.core.base_katrain import KaTrainBase
|
|
from katrain.core.constants import AI_STRATEGIES, AI_STRATEGIES_RECOMMENDED_ORDER, AI_HUMAN, AI_PRO, OUTPUT_INFO
|
|
from katrain.core.engine import KataGoEngine
|
|
from katrain.core.game import Game
|
|
|
|
|
|
class TestAI:
|
|
def test_order(self):
|
|
assert set(AI_STRATEGIES_RECOMMENDED_ORDER) == set(AI_STRATEGIES)
|
|
|
|
@pytest.mark.skipif(os.environ.get("CI", "").lower() == "true", reason="GH actions has no OpenCL")
|
|
def test_ai_strategies(self):
|
|
katrain = KaTrainBase(force_package_config=True, debug_level=0)
|
|
engine = KataGoEngine(katrain, katrain.config("engine"))
|
|
|
|
game = Game(katrain, engine)
|
|
n_rounds = 3
|
|
for _ in range(n_rounds):
|
|
for strategy in AI_STRATEGIES:
|
|
if strategy in [AI_HUMAN, AI_PRO]:
|
|
continue
|
|
settings = katrain.config(f"ai/{strategy}")
|
|
move, played_node = generate_ai_move(game, strategy, settings)
|
|
katrain.log(f"Testing strategy {strategy} -> {move}", OUTPUT_INFO)
|
|
assert move.coords is not None
|
|
assert played_node == game.current_node
|
|
|
|
assert game.current_node.depth == (len(AI_STRATEGIES) - 2) * n_rounds
|
|
|
|
for strategy in AI_STRATEGIES:
|
|
if strategy in [AI_HUMAN, AI_PRO]:
|
|
continue
|
|
game = Game(katrain, engine)
|
|
settings = katrain.config(f"ai/{strategy}")
|
|
move, played_node = generate_ai_move(game, strategy, settings)
|
|
katrain.log(f"Testing strategy on first move {strategy} -> {move}", OUTPUT_INFO)
|
|
assert game.current_node.depth == 1
|
|
|
|
def test_ai_rank_estimation(self):
|
|
katrain = KaTrainBase(force_package_config=True, debug_level=0)
|
|
for strategy in AI_STRATEGIES:
|
|
if strategy in [AI_HUMAN, AI_PRO]:
|
|
continue
|
|
settings = katrain.config(f"ai/{strategy}")
|
|
rank = ai_rank_estimation(strategy, settings)
|
|
assert -20 <= rank <= 9
|