# marzan3015/tictactoe architecture

> Architecture diagram of the GitHub repository marzan3015/tictactoe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marzan3015/tictactoe
- Repository: https://github.com/marzan3015/tictactoe

## Overview

This repository contains two independent Tic-Tac-Toe games: a terminal game where a human plays against a rule-based computer, and a graphical two-player game. The terminal workflow accepts and validates a human move, chooses a computer move, checks outcomes, and prints the board. The GUI workflow handles mouse and keyboard events, updates the board, checks for wins or ties, and redraws the game. Both implementations are concentrated in single files; the README provides no additional capability details.

Main entry points: [`Tictactoe-in-powershell-Using-Minmax/main.py`](https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py) (Terminal Game Loop), [`tictactoe_version01/TicTacToe.py`](https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py) (GUI Event Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Terminal Game"]
  node_terminal_loop["Terminal Game Loop<br/>[main.py]"]
  node_terminal_moves["Move Handling<br/>[main.py]"]
  node_computer_strategy["Computer Strategy<br/>[main.py]"]
  node_terminal_board["Board Rules<br/>[main.py]"]
  node_terminal_display["Board Display<br/>[main.py]"]
end

subgraph group_graphical["Graphical Game"]
  node_gui_loop["GUI Event Loop<br/>[TicTacToe.py]"]
  node_gui_board["Board State<br/>[TicTacToe.py]"]
  node_gui_rules["Win Detection<br/>[TicTacToe.py]"]
  node_gui_drawing["Board Rendering<br/>[TicTacToe.py]"]
  node_gui_restart["Restart Handling<br/>[TicTacToe.py]"]
end

node_human(("Human Player"))
node_gui_player(("Local Players"))

node_human -->|"enters moves"| node_terminal_loop
node_terminal_loop -->|"requests move"| node_terminal_moves
node_terminal_loop -->|"requests move"| node_computer_strategy
node_terminal_loop -->|"checks outcome"| node_terminal_board
node_terminal_loop -->|"prints board"| node_terminal_display
node_terminal_moves -->|"checks and marks"| node_terminal_board
node_computer_strategy -->|"tests candidates"| node_terminal_board
node_gui_player -->|"sends input"| node_gui_loop
node_gui_loop -->|"updates squares"| node_gui_board
node_gui_loop -->|"checks win"| node_gui_rules
node_gui_loop -->|"draws board"| node_gui_drawing
node_gui_loop -->|"handles restart"| node_gui_restart
node_gui_rules -->|"draws win line"| node_gui_drawing

click node_terminal_loop "https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py"
click node_terminal_moves "https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py"
click node_computer_strategy "https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py"
click node_terminal_board "https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py"
click node_terminal_display "https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py"
click node_gui_loop "https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py"
click node_gui_board "https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py"
click node_gui_rules "https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py"
click node_gui_drawing "https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py"
click node_gui_restart "https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_terminal_loop,node_terminal_moves,node_computer_strategy,node_terminal_board,node_terminal_display toneBlue
class node_gui_loop,node_gui_board,node_gui_rules,node_gui_drawing,node_gui_restart toneAmber
class node_human,node_gui_player toneIndigo
```

## Components

### Terminal Game

- [Terminal Game Loop](https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py): `Tictactoe-in-powershell-Using-Minmax/main.py`
- [Move Handling](https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py): `Tictactoe-in-powershell-Using-Minmax/main.py`
- [Computer Strategy](https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py): `Tictactoe-in-powershell-Using-Minmax/main.py`
- [Board Rules](https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py): `Tictactoe-in-powershell-Using-Minmax/main.py`
- [Board Display](https://github.com/marzan3015/tictactoe/blob/main/Tictactoe-in-powershell-Using-Minmax/main.py): `Tictactoe-in-powershell-Using-Minmax/main.py`

### Graphical Game

- [GUI Event Loop](https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py): `tictactoe_version01/TicTacToe.py`
- [Board State](https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py): `tictactoe_version01/TicTacToe.py`
- [Win Detection](https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py): `tictactoe_version01/TicTacToe.py`
- [Board Rendering](https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py): `tictactoe_version01/TicTacToe.py`
- [Restart Handling](https://github.com/marzan3015/tictactoe/blob/main/tictactoe_version01/TicTacToe.py): `tictactoe_version01/TicTacToe.py`

### Other components

- **Human Player**
- **Local Players**

## Connections

- Human Player → Terminal Game Loop: enters moves (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Terminal Game Loop → Move Handling: requests move (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Terminal Game Loop → Computer Strategy: requests move (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Terminal Game Loop → Board Rules: checks outcome (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Terminal Game Loop → Board Display: prints board (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Move Handling → Board Rules: checks and marks (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Computer Strategy → Board Rules: tests candidates (evidence: `Tictactoe-in-powershell-Using-Minmax/main.py`)
- Local Players → GUI Event Loop: sends input (evidence: `tictactoe_version01/TicTacToe.py`)
- GUI Event Loop → Board State: updates squares (evidence: `tictactoe_version01/TicTacToe.py`)
- GUI Event Loop → Win Detection: checks win (evidence: `tictactoe_version01/TicTacToe.py`)
- GUI Event Loop → Board Rendering: draws board (evidence: `tictactoe_version01/TicTacToe.py`)
- GUI Event Loop → Restart Handling: handles restart (evidence: `tictactoe_version01/TicTacToe.py`)
- Win Detection → Board Rendering: draws win line (evidence: `tictactoe_version01/TicTacToe.py`)
