Fix the bots' corner bias; settle seat order and RULES v0.9 (6.2, 6.8)

Bots now pick their start square and break path ties in their own
corner's frame; the absolute tie-break made corners 1 and 2 win 25-28%.
With that fixed, seat order is within target at 4 players, and a +1
stripe first-player bonus (new switch) gains only ~1 point, so no
compensation. RULES.md v0.9 lists the tested alternatives; the plan has
the 6.8 consolidation run and the seat-order study.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 18:27:06 +02:00
parent 52d8af620b
commit 79cbbccbb2
9 changed files with 178 additions and 24 deletions
+26 -4
View File
@@ -3,9 +3,9 @@
import random
import pytest
from scripted import make_game, put
from scripted import fixture_board, make_game, put
from dojo.board import Board, Pos
from dojo.board import Board, Pos, rotate
from dojo.bots import (
AGGRESSIVE,
BALANCED,
@@ -15,7 +15,9 @@ from dojo.bots import (
HeuristicAgent,
Profile,
RandomAgent,
own_frame,
series_probability,
start_square,
win_probability,
)
from dojo.engine import Agent, FightView, Game, RandomSource
@@ -73,9 +75,29 @@ def test_heuristic_sees_no_opponent_to_fight_in_round_one() -> None:
put(game, 1, TATAMI, track=3)
# In round 2 the aggressive bot picks the fight (test_profiles_differ_on_an_even_fight).
choice = HeuristicAgent(AGGRESSIVE).choose_path(game.view(0), [(Pos(5, 3),), (TATAMI,)])
# Two plain Tatami tie; the tie goes to the lower square in the bot's frame, (4, 2).
choice = HeuristicAgent(AGGRESSIVE).choose_path(game.view(0), [(TATAMI,), (Pos(4, 2),)])
assert choice == (Pos(5, 3),)
assert choice == (Pos(4, 2),)
def test_bots_start_from_the_same_square_of_every_safe_room() -> None:
board = fixture_board()
assert len({own_frame(start_square(board, corner), corner) for corner in range(4)}) == 1
def test_tied_paths_are_chosen_alike_from_every_corner() -> None:
game, _, _ = make_game(players=4)
agent = HeuristicAgent(BALANCED)
chosen = set()
for seat, player in enumerate(game.players):
player.position = rotate(Pos(4, 3), player.corner)
tatami = [(rotate(square, player.corner),) for square in (Pos(5, 3), Pos(3, 3), Pos(4, 2))]
choice = agent.choose_path(game.view(seat), tatami)
chosen.add(own_frame(choice[0], player.corner))
assert chosen == {Pos(3, 3)}
def test_brown_heuristic_takes_the_exam_when_it_can() -> None: