This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Single-file Python app with no external dependencies (stdlib tkinter only) and no build/lint/test tooling configured.
- Run the game:
python main.py - Syntax check:
python -m py_compile main.py
- Хрестики - сині, нолики - жовті
- Нічого не зберігаємо між сесіями
- Всі тексти у грі - українською мовою
The entire game lives in main.py as one TicTacToeApp class driving a Tkinter UI:
- Board state is a flat 9-element list (
self.board), indexedrow * 3 + col. Win detection (check_winner) checks this list againstWIN_COMBOS, a fixed list of index triples for rows/columns/diagonals. - Rendering is canvas-based, not widget-based: the board is a single
tk.Canvas; X/O marks and the winning-line highlight are drawn directly withcreate_line/create_ovalindraw_mark/draw_win_line, keyed off cell geometry (CELL,PADDING). Clicks are hit-tested by dividingevent.x/event.ybyCELL(on_click), not via per-cell widgets/bindings. - Header vs. board are separate build steps (
_build_header,_build_board), called once from__init__;update_headerandupdate_scorelater just mutate label text rather than rebuilding widgets. - Score is in-memory only (
self.score = {"X": ..., "O": ...}), incremented inon_clickon a win, and intentionally not reset byreset()(which only clears the board for a new round) — it only resets when the process restarts, per the "нічого не зберігаємо між сесіями" rule above. - Colors (
X_COLOR,O_COLOR,WIN_COLOR, etc.) are centralized as module-level constants at the top of the file — change appearance there rather than inline in drawing code.