-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (66 loc) · 2.95 KB
/
Copy pathMakefile
File metadata and controls
71 lines (66 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.PHONY: help install clean train play
help:
@echo "Snake AI - Available Commands:"
@echo ""
@echo " make install - Install package and dependencies"
@echo " make train CONFIG=<file> - Train with specific config file"
@echo " make play [OPTIONS] - Watch trained agent"
@echo " make clean - Remove training runs and cache"
@echo ""
@echo "Play Options (all optional, smart defaults):"
@echo " RUN=<name> - Experiment name (default: latest run)"
@echo " GENOME=<file> - Genome to play (default: best_genome.npy from RUN)"
@echo " CONFIG=<file> - Environment config (default: config_used.yaml from RUN)"
@echo " TWIST=<mode> - Twist mode (overrides config if set):"
@echo " aggregating - Obstacles accumulate over time"
@echo " rotating - Max 3 obstacles, oldest rotates out"
@echo " static - 3 random fixed obstacles"
@echo " EPISODES=<n> - Number of episodes (default: 3)"
@echo " FPS=<n> - Playback speed (default: 10)"
@echo " VISUAL=0 - Disable visualization for faster testing (default: enabled)"
@echo ""
@echo "Examples:"
@echo " make train CONFIG=configs/winner.yaml"
@echo ""
@echo " # Basic play - uses best genome & saved config"
@echo " make play RUN=winner"
@echo ""
@echo " # Customize episodes and speed"
@echo " make play RUN=winner EPISODES=10 FPS=30"
@echo ""
@echo " # Fast testing without visualization"
@echo " make play RUN=winner EPISODES=20 VISUAL=0"
@echo ""
@echo " # Watch earlier checkpoint"
@echo " make play RUN=winner GENOME=runs/winner/gen_50.npy"
@echo ""
@echo " # Cross-environment test (baseline agent in twist mode)"
@echo " make play RUN=baseline CONFIG=configs/twist_quick_test.yaml"
@echo ""
@echo " # Test with different twist modes"
@echo " make play RUN=my_run TWIST=aggregating"
@echo " make play RUN=my_run TWIST=rotating"
@echo " make play RUN=my_run TWIST=static"
@echo ""
install:
@echo "Installing Snake AI package..."
pip install -e .
@echo "Installation complete!"
train:
ifndef CONFIG
@echo "Error: CONFIG not specified"
@echo "Usage: make train CONFIG=configs/your_config.yaml"
@echo "Example: make train CONFIG=configs/winner.yaml"
@exit 1
endif
@echo "Training with config: $(CONFIG)"
python scripts/automated_training.py --config $(CONFIG) --checkpoint-every 50 --name $(notdir $(basename $(CONFIG)))
play:
@python scripts/play.py $(if $(RUN),--run $(RUN)) $(if $(GENOME),--genome $(GENOME)) $(if $(CONFIG),--config $(CONFIG)) $(if $(TWIST),--twist $(TWIST)) $(if $(EPISODES),--episodes $(EPISODES)) $(if $(FPS),--fps $(FPS)) $(if $(filter 0,$(VISUAL)),--no-visual)
clean:
@echo "Cleaning up..."
rm -rf runs/*
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
@echo "Cleanup complete!"