# ollie2405/ai_assignment architecture

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

- Interactive diagram: https://gitdiagram.com/ollie2405/ai_assignment
- Repository: https://github.com/ollie2405/ai_assignment

## Overview

Hinger is a two-player strategy game on a 5×5 board, with an optional webcam-based ASL input path and a separate landmark-classification model workflow. The main play loop obtains moves, applies board rules, scores moves, and determines the winner; the AI selects moves from generated states. The ASL branch recognizes a hand sign and supplies a validated letter to the game. The graph also preserves the documented image-to-model preparation stages. Some dataset-stage handoffs are inferred from file roles rather than shown calls, so those links are dashed and uncited.

Main entry points: [`a3_advGame.py`](https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py) (ASL game mode), [`a3_game.py`](https://github.com/ollie2405/ai_assignment/blob/main/a3_game.py) (Game loop), [`supervised_learning_model/training_and_optimisation.py`](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/training_and_optimisation.py) (Model training), [`supervised_learning_model/feature_engineering.py`](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/feature_engineering.py) (Feature engineering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Game runtime"]
  node_game_loop["Game loop<br/>[a3_game.py]"]
  node_board_state["Board state<br/>[a1_state.py]"]
  node_ai_agent["AI agent<br/>[a2_agent.py]"]
end

subgraph group_recognition["ASL input"]
  node_asl_game["ASL game mode<br/>[a3_advGame.py]"]
  node_asl_player["ASL player<br/>[a3_advGame.py]"]
  node_recognizer["Sign recognizer<br/>[a3_advGame.py]"]
end

subgraph group_modeldata["Model preparation"]
  node_photos[("ASL photos")]
  node_image_prep["Image preparation<br/>[prepare_images.py]"]
  node_processed_images[("Processed images")]
  node_landmark_extraction["Landmark extraction"]
  node_landmark_data[("Landmark tables")]
  node_data_cleaning["Data cleaning<br/>[clean.py]"]
  node_normalization["Landmark normalization<br/>[preprocess.py]"]
  node_feature_engineering["Feature engineering"]
  node_model_training["Model training"]
  node_knn["kNN classifier<br/>[knn.py]"]
  node_trained_models[("Trained models")]
end

node_player(("Human players"))

node_player -->|"provides moves"| node_game_loop
node_game_loop -->|"applies moves"| node_board_state
node_game_loop -.->|"requests AI move"| node_ai_agent
node_asl_game -->|"uses player"| node_asl_player
node_asl_player -->|"requests prediction"| node_recognizer
node_asl_game -->|"validates move"| node_board_state
node_asl_game -->|"uses opponent"| node_ai_agent
node_asl_game -.->|"accepts ASL input"| node_player
node_photos -->|"reads photos"| node_image_prep
node_image_prep -.->|"prepares images"| node_processed_images
node_processed_images -.->|"extracts landmarks"| node_landmark_extraction
node_landmark_extraction -.->|"writes landmarks"| node_landmark_data
node_landmark_data -.->|"cleans table"| node_data_cleaning
node_data_cleaning -.->|"normalizes data"| node_normalization
node_normalization -.->|"builds features"| node_feature_engineering
node_feature_engineering -.->|"supplies features"| node_model_training
node_model_training -->|"uses classifier"| node_knn
node_model_training -.->|"saves models"| node_trained_models
node_recognizer -.->|"loads model"| node_trained_models
node_recognizer -->|"prepares inputs"| node_feature_engineering

click node_game_loop "https://github.com/ollie2405/ai_assignment/blob/main/a3_game.py"
click node_board_state "https://github.com/ollie2405/ai_assignment/blob/main/a1_state.py"
click node_ai_agent "https://github.com/ollie2405/ai_assignment/blob/main/a2_agent.py"
click node_asl_game "https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py"
click node_asl_player "https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py"
click node_recognizer "https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py"
click node_photos "https://github.com/ollie2405/ai_assignment/tree/main/ASL_photos/dataset"
click node_image_prep "https://github.com/ollie2405/ai_assignment/blob/main/ASL_photos/prepare_images.py"
click node_processed_images "https://github.com/ollie2405/ai_assignment/tree/main/data/ASL_PROCESSED"
click node_landmark_extraction "https://github.com/ollie2405/ai_assignment/blob/main/landmark_extraction.py"
click node_landmark_data "https://github.com/ollie2405/ai_assignment/tree/main/data/landmarks"
click node_data_cleaning "https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/clean.py"
click node_normalization "https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/preprocess.py"
click node_feature_engineering "https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/feature_engineering.py"
click node_model_training "https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/training_and_optimisation.py"
click node_knn "https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/knn.py"
click node_trained_models "https://github.com/ollie2405/ai_assignment/tree/main/models"

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_game_loop,node_board_state,node_ai_agent toneBlue
class node_asl_game,node_asl_player,node_recognizer toneAmber
class node_photos,node_image_prep,node_processed_images,node_landmark_extraction,node_landmark_data,node_data_cleaning,node_normalization,node_feature_engineering,node_model_training,node_knn,node_trained_models toneMint
class node_player toneIndigo
```

## Components

### Game runtime

- [Game loop](https://github.com/ollie2405/ai_assignment/blob/main/a3_game.py): `a3_game.py`
- [Board state](https://github.com/ollie2405/ai_assignment/blob/main/a1_state.py): `a1_state.py`
- [AI agent](https://github.com/ollie2405/ai_assignment/blob/main/a2_agent.py): `a2_agent.py`

### ASL input

- [ASL game mode](https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py): `a3_advGame.py`
- [ASL player](https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py): `a3_advGame.py`
- [Sign recognizer](https://github.com/ollie2405/ai_assignment/blob/main/a3_advGame.py): `a3_advGame.py`

### Model preparation

- [ASL photos](https://github.com/ollie2405/ai_assignment/tree/main/ASL_photos/dataset): `ASL_photos/dataset`
- [Image preparation](https://github.com/ollie2405/ai_assignment/blob/main/ASL_photos/prepare_images.py): `ASL_photos/prepare_images.py`
- [Processed images](https://github.com/ollie2405/ai_assignment/tree/main/data/ASL_PROCESSED): `data/ASL_PROCESSED`
- [Landmark extraction](https://github.com/ollie2405/ai_assignment/blob/main/landmark_extraction.py): `landmark_extraction.py`
- [Landmark tables](https://github.com/ollie2405/ai_assignment/tree/main/data/landmarks): `data/landmarks`
- [Data cleaning](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/clean.py): `supervised_learning_model/clean.py`
- [Landmark normalization](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/preprocess.py): `supervised_learning_model/preprocess.py`
- [Feature engineering](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/feature_engineering.py): `supervised_learning_model/feature_engineering.py`
- [Model training](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/training_and_optimisation.py): `supervised_learning_model/training_and_optimisation.py`
- [kNN classifier](https://github.com/ollie2405/ai_assignment/blob/main/supervised_learning_model/knn.py): `supervised_learning_model/knn.py`
- [Trained models](https://github.com/ollie2405/ai_assignment/tree/main/models): `models`

### Other components

- **Human players**

## Connections

- Human players → Game loop: provides moves (evidence: `README.md`)
- Game loop → Board state: applies moves (evidence: `a3_game.py`)
- Game loop → AI agent: requests AI move (evidence: `a3_game.py`)
- ASL game mode → ASL player: uses player (evidence: `a3_advGame.py`)
- ASL player → Sign recognizer: requests prediction (evidence: `a3_advGame.py`)
- ASL game mode → Board state: validates move (evidence: `a3_advGame.py`)
- ASL game mode → AI agent: uses opponent (evidence: `a3_advGame.py`)
- ASL game mode → Human players: accepts ASL input
- ASL photos → Image preparation: reads photos (evidence: `ASL_photos/prepare_images.py`)
- Image preparation → Processed images: prepares images
- Processed images → Landmark extraction: extracts landmarks
- Landmark extraction → Landmark tables: writes landmarks
- Landmark tables → Data cleaning: cleans table
- Data cleaning → Landmark normalization: normalizes data
- Landmark normalization → Feature engineering: builds features (evidence: `supervised_learning_model/feature_engineering.py`)
- Feature engineering → Model training: supplies features
- Model training → kNN classifier: uses classifier (evidence: `supervised_learning_model/training_and_optimisation.py`)
- Model training → Trained models: saves models
- Sign recognizer → Trained models: loads model
- Sign recognizer → Feature engineering: prepares inputs (evidence: `a3_advGame.py`)
