Skip to content

Commit a272911

Browse files
committed
Merge refactor/v0.7.0: Complete repository organization
Complete codebase reorganization from flat structure (45 files at root) to organized directory structure (9 directories): - src/ - Core implementation modules - training/ - Training infrastructure - tools/ - Development utilities - tests/ - Test suite - obsolete/ - Preserved historical files - docs/ - Portfolio documentation - artifacts/ - Training artifacts (models, checkpoints, data, reports) - data/ - Game data (PGN files organized by opponent) - logs/ - Build and test logs All functionality preserved, tests passing (24/24), zero data loss. Tournament submission (my_agent.py) unaffected and verified functional. Root directory: 45 files → 9 committed files (clean structure achieved).
2 parents b50a35d + 5ffb699 commit a272911

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+404
-249
lines changed

.dockerignore

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ phase4_checkpoints/
4545
logs/
4646
runs/
4747

48-
# Test files (exclude future test files, but Phase 2 tests are needed in Docker)
48+
# Test files (v0.7.0: tests/ directory now included in Docker)
4949
# test_*.py # COMMENTED: Blocking test_phase2.py - keep this commented during Phase 2-6
5050
*_test.py
51-
tests/
51+
# tests/ # REMOVED: tests/ directory now part of organized structure
5252

5353
# Phase test files needed in Docker:
5454
# - test_phase2.py (Phase 2 validation)
@@ -91,4 +91,11 @@ __MACOSX/
9191
.cache/
9292

9393
# Debug scripts (not needed in container)
94-
debug_*.py
94+
debug_*.py
95+
96+
# Phase 7.12: Organized artifact directories (v0.7.0)
97+
# These directories contain training artifacts, game data, and logs
98+
# Not needed in Docker container - keeps image lean
99+
artifacts/
100+
data/
101+
logs/

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ best_checkpoint.pkl
234234
test_*.pkl
235235
test_*.npy
236236

237-
# ELO measurement files (can regenerate)
238-
baseline_elo_measurement.json
237+
# Performance reports and measurements (generated artifacts - can regenerate)
238+
*_report.json
239+
*_measurement.json
239240
elo_measurement_*.pgn

.refactor_baseline.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
v0.7.0 Refactoring Baseline (Oct 16, 2025)
2+
==========================================
3+
4+
Starting Point: v0.6.0 (Phase 6 Complete, Tournament Ready)
5+
6+
Current Structure:
7+
- 91 total items at root directory
8+
- 45+ Python files at root level
9+
- Only organized directory: docs/
10+
11+
Validation Status:
12+
- Docker image: neuraltactics (14.4GB)
13+
- test_phase5.py: 24/24 passing ✅
14+
- my_agent.py: Functional ✅
15+
- Tournament ready: Yes ✅
16+
17+
Target: Organize into src/, training/, tools/, tests/, obsolete/
18+
Timeline: 5-6 hours (11 phases)
19+
Zero data loss: All files will be preserved

Dockerfile

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,26 @@
11
FROM python:3.9-slim
22

33
WORKDIR /app
4+
5+
# Set Python path to include /app for module imports
6+
ENV PYTHONPATH=/app
7+
8+
# Install dependencies
49
COPY requirements.txt .
510
RUN pip install -r requirements.txt
611

7-
# Copy tournament infrastructure
12+
# Copy tournament interface and submission
813
COPY agent_interface.py .
9-
COPY game_driver.py .
10-
COPY random_agent.py .
11-
COPY greedy_agent.py .
12-
13-
# Copy student agent and Phase 2 modules
1414
COPY my_agent.py .
15-
COPY chess_state.py .
16-
COPY evaluation.py .
17-
COPY test_phase2.py .
18-
19-
# Copy Phase 3 modules
20-
COPY training.py .
21-
COPY nnue_network.py .
22-
COPY nnue_integration.py .
23-
COPY test_phase3.py .
24-
COPY my_agent_phase3_demo.py .
25-
COPY my_agent_tournament.py .
26-
27-
# Copy Phase 4 modules
28-
COPY phase4_training_pipeline.py .
29-
COPY checkpoint_manager.py .
30-
COPY training_metrics.py .
31-
COPY hyperparameter_optimizer.py .
32-
COPY performance_profiler.py .
33-
COPY advanced_training.py .
34-
COPY test_phase4.py .
35-
COPY validate_phase4.py .
36-
COPY quick_validate_phase4.py .
37-
38-
# Copy Phase 5 modules
39-
COPY tactical_patterns.py .
40-
COPY test_tactical_patterns.py .
41-
COPY endgame_mastery.py .
42-
COPY test_endgame_mastery.py .
43-
COPY middlegame_strategy.py .
44-
COPY test_middlegame_strategy.py .
45-
COPY opening_repertoire.py .
46-
COPY test_opening_repertoire.py .
47-
COPY dynamic_evaluation.py .
48-
COPY test_dynamic_evaluation.py .
49-
COPY test_phase5.py .
5015

51-
# Copy Phase 6 profiling and validation tools
52-
COPY profile_agent.py .
53-
COPY tournament_validation.py .
16+
# Copy organized directories
17+
COPY src/ src/
18+
COPY training/ training/
19+
COPY tools/ tools/
20+
COPY tests/ tests/
5421

5522
# Set memory limits
5623
RUN ulimit -v 2000000 # 2GB memory limit
5724

5825
# Default command
59-
CMD ["python", "game_driver.py"]
26+
CMD ["python", "tools/game_driver.py"]

README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Achieved ~2900 ELO through NNUE neural network training and strategic enhancemen
1818
docker build -t neuraltactics .
1919

2020
# Run a game
21-
docker run neuraltactics python game_driver.py
21+
docker run neuraltactics python tools/game_driver.py
2222

2323
# Run comprehensive tests
24-
docker run neuraltactics python test_phase5.py
24+
docker run neuraltactics python tests/test_phase5.py
2525
```
2626

2727
## Key Features
@@ -65,23 +65,41 @@ Comprehensive technical documentation available in [`docs/`](./docs/):
6565
NeuralTactics/
6666
├── 📄 README.md # This file (quick start)
6767
├── 📄 my_agent.py # Tournament submission (3,168 lines)
68+
├── 📄 agent_interface.py # Tournament interface
6869
├── 📄 Dockerfile # Tournament environment
6970
├── 📄 requirements.txt # Exact dependencies
71+
├── 📄 MIGRATION.md # v0.6.0 → v0.7.0 migration guide
7072
71-
├── 📁 docs/ # Comprehensive documentation
72-
│ ├── 📄 README.md # Detailed overview
73-
│ ├── 📄 ARCHITECTURE.md # Technical deep dive
74-
│ ├── 📄 TRAINING.md # Training methodology
75-
│ ├── 📄 TOURNAMENT.md # Compliance proof
76-
│ ├── 📄 RESULTS.md # Performance analysis
77-
│ └── 📄 FAQ.md # Compliance clarifications
73+
├── 📁 src/ # Core implementation
74+
│ ├── 📁 state/ # Chess state representation
75+
│ ├── 📁 evaluation/ # Position evaluation (6 modules)
76+
│ └── 📁 neural/ # NNUE network implementation
7877
79-
├── 📄 game_driver.py # Game runner
80-
├── 📄 random_agent.py # Baseline opponent
81-
├── 📄 greedy_agent.py # Baseline opponent
78+
├── 📁 training/ # Training infrastructure
79+
│ ├── 📄 trainer.py # Main training loop
80+
│ ├── 📄 pipeline.py # Optimized training pipeline
81+
│ └── 📄 metrics.py # Performance tracking
8282
83-
├── 📄 test_phase5.py # Comprehensive test suite (24 tests)
84-
└── 📄 tournament_validation.py # 100-game stress test
83+
├── 📁 tools/ # Development utilities
84+
│ ├── 📄 game_driver.py # Game runner
85+
│ ├── 📄 random_agent.py # Baseline opponent
86+
│ └── 📄 greedy_agent.py # Baseline opponent
87+
88+
├── 📁 tests/ # Test suite
89+
│ ├── 📄 test_phase5.py # Comprehensive tests (24 tests)
90+
│ └── 📄 tournament_validation.py # 100-game stress test
91+
92+
├── 📁 obsolete/ # Preserved historical files
93+
│ ├── 📄 my_agent_phase3_demo.py # Phase 3 demo (outdated)
94+
│ └── 📄 my_agent_tournament.py # Sep 28 version (outdated)
95+
96+
└── 📁 docs/ # Comprehensive documentation
97+
├── 📄 README.md # Detailed overview
98+
├── 📄 ARCHITECTURE.md # Technical deep dive
99+
├── 📄 TRAINING.md # Training methodology
100+
├── 📄 TOURNAMENT.md # Compliance proof
101+
├── 📄 RESULTS.md # Performance analysis
102+
└── 📄 FAQ.md # Compliance clarifications
85103
```
86104

87105

@@ -91,10 +109,10 @@ NeuralTactics/
91109

92110
```bash
93111
# Comprehensive test suite (24 tests)
94-
docker run neuraltactics python test_phase5.py
112+
docker run neuraltactics python tests/test_phase5.py
95113

96114
# 100-game tournament validation
97-
docker run neuraltactics python tournament_validation.py
115+
docker run neuraltactics python tests/tournament_validation.py
98116
```
99117

100118
### Local Development

artifacts/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Artifacts Directory
2+
3+
This directory contains training artifacts generated during development.
4+
5+
## Structure
6+
7+
```
8+
artifacts/
9+
├── models/ # Trained neural network models
10+
├── checkpoints/ # Training checkpoints
11+
├── training_data/ # Training datasets
12+
└── reports/ # Performance reports
13+
```
14+
15+
## Contents
16+
17+
### models/
18+
- `best_nnue_model.pth` - Best trained NNUE network weights
19+
- Neural network models saved during training
20+
21+
### checkpoints/
22+
- `phase4_checkpoints/` - Phase 4 training checkpoints
23+
- `validation_checkpoints/` - Validation checkpoints
24+
- Intermediate training states for resuming training
25+
26+
### training_data/
27+
- `training_data.pkl` - Complete training dataset (pickle format)
28+
- `training_positions.npy` - Position array for neural training
29+
- `training_outcomes.npy` - Outcome array for neural training
30+
- `training_progress.json` - Training progress metrics
31+
32+
### reports/
33+
- `baseline_elo_measurement.json` - ELO measurement results
34+
- `phase4_performance_report.json` - Phase 4 performance metrics
35+
- Performance analysis reports
36+
37+
## Note
38+
39+
**These files are in `.gitignore` and `.dockerignore`.**
40+
- Not committed to repository (too large, binary files)
41+
- Not included in Docker images (not needed for tournament)
42+
- Generated locally during training and development
43+
- Excluded from portfolio presentation (show code, not artifacts)

data/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Data Directory
2+
3+
This directory contains game data generated during development and testing.
4+
5+
## Structure
6+
7+
```
8+
data/
9+
└── pgn_games/
10+
├── vs_greedy/ # Games against GreedyAgent
11+
└── vs_random/ # Games against RandomAgent
12+
```
13+
14+
## Contents
15+
16+
### pgn_games/vs_greedy/
17+
- PGN files from ELO measurement games against GreedyAgent
18+
- Used for ELO rating calculation and performance analysis
19+
- 10 game files
20+
21+
### pgn_games/vs_random/
22+
- PGN files from ELO measurement games against RandomAgent
23+
- Used for baseline performance comparison
24+
- 10 game files
25+
26+
## PGN Format
27+
28+
Each file contains a complete chess game in Portable Game Notation (PGN) format including:
29+
- Game metadata (players, date, result)
30+
- Move sequence
31+
- Game outcome
32+
33+
## Usage
34+
35+
These files can be analyzed for:
36+
- Game review and blunder analysis
37+
- Position evaluation debugging
38+
- Strategy effectiveness assessment
39+
- Training feedback loop
40+
41+
## Note
42+
43+
**These files are in `.gitignore` and `.dockerignore`.**
44+
- Not committed to repository (regenerated during testing)
45+
- Not included in Docker images (not needed for tournament)
46+
- Generated locally during ELO measurements
47+
- Can be regenerated by running tournament validation

docs/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ docker run neuraltactics python training.py --generate-data --games 1000
263263
docker run neuraltactics python training.py --epochs 100 --batch-size 128 --lr 0.0008
264264

265265
# Validate
266-
docker run neuraltactics python test_phase5.py
266+
docker run neuraltactics python tests/test_phase5.py
267267
```
268268

269269
---

docs/README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ NeuralTactics is a competitive chess AI developed for academic tournament play,
3434
docker build -t neuraltactics .
3535

3636
# Play a game (agent vs RandomAgent)
37-
docker run neuraltactics python game_driver.py
37+
docker run neuraltactics python tools/game_driver.py
3838

3939
# Run comprehensive test suite
40-
docker run neuraltactics python test_phase5.py
40+
docker run neuraltactics python tests/test_phase5.py
4141
```
4242

4343
### Test Agent Performance
4444

4545
```bash
4646
# 100-game tournament validation
47-
docker run neuraltactics python tournament_validation.py
47+
docker run neuraltactics python tests/tournament_validation.py
4848

4949
# Profile performance
50-
docker run neuraltactics python profile_agent.py
50+
docker run neuraltactics python tools/profile_agent.py
5151
```
5252

5353
## Architecture Highlights
@@ -126,13 +126,19 @@ NeuralTactics/
126126
├── 📄 requirements.txt # Exact dependency versions
127127
├── 📄 Dockerfile # Tournament environment
128128
129-
├── 📄 game_driver.py # Game runner and testing framework
130-
├── 📄 random_agent.py # Baseline opponent (random moves)
131-
├── 📄 greedy_agent.py # Baseline opponent (material greedy)
129+
├── 📁 src/ # Core implementation (state, evaluation, neural)
130+
├── 📁 training/ # Training infrastructure
131+
├── 📁 tools/ # Development utilities
132+
│ ├── 📄 game_driver.py # Game runner and testing framework
133+
│ ├── 📄 random_agent.py # Baseline opponent (random moves)
134+
│ └── 📄 greedy_agent.py # Baseline opponent (material greedy)
132135
133-
├── 📄 test_phase5.py # Comprehensive test suite (24 tests)
134-
├── 📄 tournament_validation.py # 100-game stress test
135-
├── 📄 profile_agent.py # Performance profiling
136+
├── 📁 tests/ # Test suite
137+
│ ├── 📄 test_phase5.py # Comprehensive test suite (24 tests)
138+
│ ├── 📄 tournament_validation.py # 100-game stress test
139+
│ └── 📄 profile_agent.py # Performance profiling
140+
141+
├── 📁 obsolete/ # Preserved historical files
136142
137143
└── 📁 docs/ # Documentation
138144
├── 📄 README.md # This file (detailed overview)
@@ -147,7 +153,7 @@ NeuralTactics/
147153

148154
```bash
149155
# Phase 5 comprehensive validation (24 tests)
150-
docker run neuraltactics python test_phase5.py
156+
docker run neuraltactics python tests/test_phase5.py
151157

152158
# Expected output: 24/24 tests passing
153159
# Coverage: Tactical, endgame, middlegame, opening, dynamic evaluation

0 commit comments

Comments
 (0)