Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 1.89 KB

File metadata and controls

27 lines (17 loc) · 1.89 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

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

Conventions

  • Хрестики - сині, нолики - жовті
  • Нічого не зберігаємо між сесіями
  • Всі тексти у грі - українською мовою

Architecture

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), indexed row * 3 + col. Win detection (check_winner) checks this list against WIN_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 with create_line/create_oval in draw_mark/draw_win_line, keyed off cell geometry (CELL, PADDING). Clicks are hit-tested by dividing event.x/event.y by CELL (on_click), not via per-cell widgets/bindings.
  • Header vs. board are separate build steps (_build_header, _build_board), called once from __init__; update_header and update_score later just mutate label text rather than rebuilding widgets.
  • Score is in-memory only (self.score = {"X": ..., "O": ...}), incremented in on_click on a win, and intentionally not reset by reset() (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.