#!/usr/bin/env python3 """A surgical one-cell control of a verified public replay, not a legal move.""" import json from datetime import datetime, timezone from replay import ROOT, count, evolve def main(): match = json.loads((ROOT/'public-match.json').read_text()) r = match['history'][3] point, width, height = [22, 23], 24, 24 i = point[1] * width + point[0] assert r['round'] == 4 and r['board_seeded'][i] == 3 assert point in r['red_placements'] and point in r['blue_placements'] actual = evolve(r['board_seeded'], width, height, 8) controls = {} for state, name in ((0, 'removed'), (1, 'red'), (2, 'blue')): board = r['board_seeded'].copy() board[i] = state controls[name] = evolve(board, width, height, 8) assert actual[-1] == r['board_after'] assert all(actual[t] == controls['red'][t] == controls['blue'][t] for t in range(1, 9)) changes = [[{'x': j % width, 'y': j // width, 'actual': a, 'removed': b} for j, (a, b) in enumerate(zip(actual[t], controls['removed'][t])) if a != b] for t in range(9)] assert changes[1] == [ {'x': 23, 'y': 22, 'actual': 0, 'removed': 1}, {'x': 23, 'y': 23, 'actual': 0, 'removed': 1}] assert len(changes[8]) == 51 data = {'match_id': match['id'], 'round': 4, 'width': width, 'height': height, 'point': point, 'red_name': match['red_name'], 'blue_name': match['blue_name'], 'actual': actual, 'removed': controls['removed'], 'changes': changes, 'counts': [{'tick': t, 'actual': count(actual[t]), 'removed': count(controls['removed'][t]), 'different_cells': len(changes[t])} for t in range(9)]} (ROOT/'collision-data.json').write_text(json.dumps(data, separators=(',', ':'))+'\n') report = {'checked_utc': datetime.now(timezone.utc).isoformat(), 'match_id': match['id'], 'round': 4, 'coordinate': point, 'coordinate_system': 'zero-based x,y; row 0 at top', 'neutral_dead_at_tick_one': actual[1][i] == 0, 'red_blue_neutral_recolorings_identical_after_tick_one': True, 'first_tick_differences': changes[1], 'counts': data['counts'], 'control': 'Replace only the disputed neutral cell with dead immediately after seeding; all other cells fixed.', 'limits': ['This removal is not a legal full-budget alternative move.', 'The replay contains both committed choices; no claim that either player knew the opposing choice beforehand.', 'Only this round is compared; later recorded moves may not be legal on the altered board.'], 'all_assertions_passed': True} (ROOT/'collision-verification.json').write_text(json.dumps(report, indent=2)+'\n') print(json.dumps(report, indent=2)) if __name__ == '__main__': main()