Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
273 commits
Select commit Hold shift + click to select a range
58c5b30
fix(merge_data): correct project_root path to parent.parent.parent
HDAnzz Apr 29, 2026
e10af97
fix(train): use absolute path data/arknights.csv
HDAnzz Apr 29, 2026
a6ce8a0
fix(config): set FIELD_FEATURE_COUNT to 0
HDAnzz Apr 29, 2026
e4df8d9
refactor(core): move winrt_capture to core as winrt_connector
HDAnzz Apr 29, 2026
b047551
fix: update imports and paths after refactors
HDAnzz Apr 29, 2026
154364a
refactor(analytics): rename data module to analytics
HDAnzz Apr 29, 2026
5d1a4b2
refactor(models): separate model definitions from training
HDAnzz Apr 29, 2026
25bdde4
refactor(training): move training logic to training module
HDAnzz Apr 29, 2026
eb75c01
refactor(training): remove model/dataset definitions from trainer.py
HDAnzz Apr 29, 2026
4804ad0
docs: update AGENTS.md for Phase 9 module separation
HDAnzz Apr 29, 2026
b351fb9
refactor(cli): rename cli.py to console.py and add training __main__.py
HDAnzz Apr 29, 2026
8c95fe5
feat(config): add centralized path management in config/paths.py
HDAnzz Apr 29, 2026
e13e67e
refactor: convert os.path to pathlib.Path throughout codebase
HDAnzz Apr 29, 2026
4ade6d9
refactor(cli): simplify load_all_images with single CSV read
HDAnzz Apr 29, 2026
ebdc423
fix(console): launch GUI when no subcommand provided
HDAnzz Apr 29, 2026
a4e9f60
fix(console): use PyQt6 AA_UseHighDpiPixmaps instead of deprecated AA…
HDAnzz Apr 29, 2026
7716e8f
fix(console): remove deprecated PyQt6 DPI attribute
HDAnzz Apr 29, 2026
703a7b2
fix(console): import ArknightsApp instead of MainWindow
HDAnzz Apr 29, 2026
900ffd1
fix(auto_fetch): convert OCR number string to int before assignment
HDAnzz Apr 29, 2026
d90c59d
refactor(cli): move utilities to tools directory
HDAnzz Apr 29, 2026
da3ff39
fix(__main__): update import from cli to console
HDAnzz Apr 29, 2026
515398b
docs(core): add file-level docstrings
HDAnzz Apr 29, 2026
1bc522b
refactor(core): move loadData to core.connector with MAA support
HDAnzz Apr 29, 2026
f138c39
refactor(core): update imports to use new connector module
HDAnzz Apr 29, 2026
d54ad84
refactor(core): rename winrt_connector to winrt_capture
HDAnzz Apr 29, 2026
60827de
refactor(core): remove maa_adb_connector.py, create maa_registry.py
HDAnzz Apr 29, 2026
4c220a6
refactor(recognize): use PcConnector for screenshot instead of direct…
HDAnzz Apr 29, 2026
a76d6cd
refactor(core): modularize recognize functionality
HDAnzz Apr 29, 2026
3c5c6fd
fix(connector): MAA Framework initialization and cleanup
HDAnzz Apr 29, 2026
e1f77d4
refactor(recognize): load relative regions from config
HDAnzz Apr 29, 2026
b637da1
fix(connector): add is_maa_available property
HDAnzz Apr 29, 2026
985c0e0
fix(connector): add adb_path to AdbController initialization
HDAnzz Apr 29, 2026
7b8998f
fix(predict): handle CUDA initialization errors with CPU fallback
HDAnzz Apr 29, 2026
b2180aa
fix(main_window): update WIN mode check to use _connector
HDAnzz Apr 29, 2026
f6f6ab4
fix(connector): add device_serial property to AdbConnector
HDAnzz Apr 29, 2026
439a52b
fix(gui): 修复深色模式弹窗和 WindowPickerDialog 导入
HDAnzz Apr 29, 2026
5418760
fix: 修复自定义 ROI 未生效导致截图错误
HDAnzz Apr 30, 2026
8946107
refactor: 重构 RecognizeMonster 分离截图和识别职责
HDAnzz Apr 30, 2026
017d8a8
docs: Add Connector unification design spec
HDAnzz Apr 30, 2026
967ffc1
feat: Add ConnectorFactory for lifecycle management
HDAnzz Apr 30, 2026
1c1f195
feat(WindowPickerDialog): Add filter_hwnds for PC multi-window selection
HDAnzz Apr 30, 2026
28e991e
feat(PcConnector): Add multi-window detection and selection
HDAnzz Apr 30, 2026
b14f4ef
refactor(RecognizeMonster): Remove method parameter, handle full-scre…
HDAnzz Apr 30, 2026
420842e
fix(RecognizeMonster): Clarify _recognize_region input contract
HDAnzz Apr 30, 2026
a48ae65
refactor(ArknightsApp): Replace dual connectors with factory pattern
HDAnzz Apr 30, 2026
0eea368
Task 5 cleanup: remove dead code references to old connector pattern
HDAnzz Apr 30, 2026
45a080d
fix(ArknightsApp): Replace active_connector references with connector
HDAnzz Apr 30, 2026
db6a713
refactor(ArknightsApp): Implement on_mode_changed with factory
HDAnzz Apr 30, 2026
878aa91
refactor(ArknightsApp): Update get_recognize to use single connector
HDAnzz Apr 30, 2026
c729198
refactor: Complete Connector unification
HDAnzz Apr 30, 2026
ab05586
fix: Restore missing methods and fix connector initialization
HDAnzz Apr 30, 2026
0eec762
fix: Add None check in update_device_serial
HDAnzz Apr 30, 2026
3293b27
fix: Async device list loading and pre-initialization
HDAnzz Apr 30, 2026
d8dfc16
fix: Replace QThread with QTimer.singleShot for device list loading
HDAnzz Apr 30, 2026
4c83ed6
feat: Auto-connect ADB mode on startup
HDAnzz Apr 30, 2026
df595fb
docs: Add lazy connection design spec
HDAnzz Apr 30, 2026
723ea4f
docs: Update lazy connection spec with retry logic
HDAnzz Apr 30, 2026
734bfc3
plan: Add lazy connection implementation plan
HDAnzz Apr 30, 2026
b6f7d5f
feat: Add ensure_connected() and internal hook methods to BaseConnector
HDAnzz Apr 30, 2026
9d48c92
feat: Implement template methods in BaseConnector
HDAnzz Apr 30, 2026
3a81fb6
feat: Implement ensure_connected() with 3-retry in AdbConnector
HDAnzz Apr 30, 2026
8a82fe1
refactor: Rename AdbConnector.capture_screenshot to _capture_internal
HDAnzz Apr 30, 2026
1625cf9
refactor: Rename AdbConnector.click to _click_internal
HDAnzz Apr 30, 2026
4419853
feat: Implement ensure_connected() and rename methods in PcConnector
HDAnzz Apr 30, 2026
5852c81
feat: Remove auto-connect and silent parameter from MainWindow
HDAnzz Apr 30, 2026
0d04d80
feat: Update get_recognize with lazy connection and better error mess…
HDAnzz Apr 30, 2026
7215687
fix: Restore ADB mode initialization on startup (lazy connection)
HDAnzz Apr 30, 2026
6f64d88
fix: Correct _load_device_list_async to use self.connector (AdbConnec…
HDAnzz Apr 30, 2026
0fafd4e
refactor: Use importlib.metadata for version detection
HDAnzz Apr 30, 2026
12d85b6
refactor: Inline ADB initialization, remove on_mode_changed call
HDAnzz Apr 30, 2026
b5a419a
fix: Use np.array([]) instead of None for feat_past
HDAnzz Apr 30, 2026
a004a55
feat: Use threading.Lock to protect mode switching critical section
HDAnzz Apr 30, 2026
336c349
refactor: Use Qt QMutex instead of threading.Lock for mode switching
HDAnzz Apr 30, 2026
35622a9
fix: Use _ for unused QMutexLocker variable
HDAnzz Apr 30, 2026
2635304
refactor: Move connector ready/failed logic to get_recognize for lazy…
HDAnzz Apr 30, 2026
e8673bb
fix: Remove duplicate DarkModeStyleFix.apply() from console.py
HDAnzz Apr 30, 2026
a715e57
feat: Attempt reconnect before destroying disconnected connector
HDAnzz Apr 30, 2026
7bc5771
feat: Check kwargs match before reusing connector from pool
HDAnzz Apr 30, 2026
f08a99e
feat: True lazy connection - factory creates connectors without conne…
HDAnzz Apr 30, 2026
39a880c
fix: Set default MAA status to '未连接' (gray) in UI initialization
HDAnzz Apr 30, 2026
95d1114
refactor(main_window): Complete state-based connector switching logic
HDAnzz Apr 30, 2026
9ed96cc
fix: Import ConnectorState enum in main_window
HDAnzz Apr 30, 2026
5fc2e9a
config: add DEBUG_MODE constant and remove obsolete TODO
HDAnzz Apr 30, 2026
948f294
connector: add mark_valid method and fix logging format
HDAnzz Apr 30, 2026
9bcc506
recognize: use DEBUG_MODE constant and fix logging format
HDAnzz Apr 30, 2026
ab06cc5
gui: use mark_valid and fix ROI selection
HDAnzz Apr 30, 2026
af8e482
tests: add mark_valid tests and update imports
HDAnzz Apr 30, 2026
43d3d3f
auto_fetch: use DEBUG_MODE, fix logging format and typos
HDAnzz Apr 30, 2026
3fd98dc
gui: set default ADB serial before creating connector
HDAnzz Apr 30, 2026
888fdc5
core: remove screenshot_helper.py
HDAnzz Apr 30, 2026
dac81d3
utils: restore original find_monster_zone.py and fix UnboundLocalError
HDAnzz Apr 30, 2026
7f518e3
utils: fix UnboundLocalError in cutFrame + complete recognition tests
HDAnzz May 1, 2026
65bbf42
utils: rewrite find_monster_zone with refactored structure
HDAnzz May 1, 2026
c06401c
utils: rename cutFrame to find_monster_zone
HDAnzz May 1, 2026
7d0ef72
docs: monster bar detection comparison report (main vs refactor)
HDAnzz May 1, 2026
9d2cea0
docs: revise fix design — use crop_ratio + use_crop_ratio flag instea…
HDAnzz May 1, 2026
41cc89b
docs: redesign RecognizeMonster with crop_ratio parameterization
HDAnzz May 1, 2026
59047ab
plan: crop_ratio refactor implementation plan (9 tasks)
HDAnzz May 1, 2026
a65eee3
config: add DEFAULT_CROP_RATIO constant
HDAnzz May 1, 2026
e5a87fa
recognize: add ROINotSelectedError, refactor with crop_ratio and proc…
HDAnzz May 1, 2026
987d6b5
gui: update get_recognize, reselect_roi, fix choose_capture_window
HDAnzz May 1, 2026
61b36aa
test: add crop_ratio and process_regions tests (11 tests)
HDAnzz May 1, 2026
70d08e2
recognize: precise region splitting and OCR — align with main branch
HDAnzz May 1, 2026
cab5b67
test: remove dead EXPECTED dict, rename test to match assertion
HDAnzz May 1, 2026
af9ee09
test: verify monster type (matched_id) and number in accuracy tests
HDAnzz May 1, 2026
e22282a
tools: add select_crop_ratio utility for interactive crop ratio calib…
HDAnzz May 1, 2026
3fd42f4
tools: refine select_crop_ratio to use find_monster_zone auto-detection
HDAnzz May 1, 2026
223382e
tools: select_crop_ratio now outputs all 3 configs
HDAnzz May 1, 2026
a2d616b
tools: add Q key to quit select_crop_ratio tool
HDAnzz May 1, 2026
375b067
tools: add visual confirmation of detected avatar/number regions
HDAnzz May 1, 2026
297dc31
recognize: add mode parameter for PC-specific region defaults
HDAnzz May 1, 2026
8a55275
fix: logger format error, inverted PC coords, add PC tests
HDAnzz May 1, 2026
d351643
gui: show reference image (eg.png) during ROI selection
HDAnzz May 1, 2026
509415f
fix: replace invalid -1 embedding index with topk approach
HDAnzz May 1, 2026
f4a7ae2
fix: restore original fc head (Sequential 128→256→1)
HDAnzz May 1, 2026
fb40849
fix: clear recognizer custom settings on mode switch
HDAnzz May 1, 2026
b31bcc9
fix: update connector on WIN capture window selection
HDAnzz May 1, 2026
b037bea
fix: replace stale connector after WIN window selection
HDAnzz May 1, 2026
d1fd644
refactor: move WindowPickerDialog from connector to gui/dialogs
HDAnzz May 1, 2026
2e01bed
style: apply ruff format to all Python source files
HDAnzz May 1, 2026
672e426
config: load recognition settings from config/app.json
HDAnzz May 1, 2026
cd14148
test: restructure tests with images/tests/ and WIN cropped screenshots
HDAnzz May 1, 2026
aac72a5
fix: pass capture_mode to process_regions in auto_fetch
HDAnzz May 1, 2026
3370558
gui: block mode switch during auto-fetch, disable auto-fetch in WIN mode
HDAnzz May 1, 2026
091e010
gui: use Qt QMutex for toggle_auto_fetch lock
HDAnzz May 1, 2026
3ca678c
gui: protect all auto_fetch_running reads with QMutexLocker
HDAnzz May 1, 2026
c370365
gui: remove redundant QMutexLocker from mode switch and closeEvent
HDAnzz May 1, 2026
6224676
config: add control.disable_maafw option to app.json
HDAnzz May 1, 2026
a241fc4
gui: limit auto-fetch to ADB mode only
HDAnzz May 1, 2026
45fa042
pc_connector: add warning logs for click operations
HDAnzz May 1, 2026
1e1b85e
docs: testing architecture with 3-layer unit/integration/e2e + CI
HDAnzz May 1, 2026
f3638e0
plan: 10-task testing implementation plan (unit/integration/e2e + CI)
HDAnzz May 1, 2026
598307a
test: add input_panel, predict, mock_connector tests
HDAnzz May 1, 2026
d7fb4dd
test: add auto_fetch state machine tests and CI workflow
HDAnzz May 1, 2026
e2973e1
test: add GUI e2e tests with @pytest.mark.e2e marker
HDAnzz May 1, 2026
f8306c9
refactor: reorganize model and config directories
HDAnzz May 1, 2026
635dccc
test: fix predict exit on missing model, register e2e marker
HDAnzz May 1, 2026
4ec69c4
test: fix predict model path to models/predictor/
HDAnzz May 1, 2026
34f0cce
test: rename test_monster_crop.py to test_recognition_accuracy.py
HDAnzz May 1, 2026
29e6d67
fix: remove unused MODELS_DIR import from test_predict.py
HDAnzz May 1, 2026
4853fd4
fix: update bat script entry point from main.py to cannotmax
HDAnzz May 1, 2026
4c6aa65
refactor: use MODELS_DIR/predictor as default model path
HDAnzz May 1, 2026
ccc5222
fix: correct method name in e2e test: on_mode_changed
HDAnzz May 1, 2026
27f9833
fix: close modal popup in e2e test to avoid blocking
HDAnzz May 1, 2026
f450120
fix: use QTimer.singleShot to close popup before click
HDAnzz May 1, 2026
8c8fae9
refactor: move monster avatars to images/monsters/
HDAnzz May 1, 2026
5fa281a
fix: display captured screenshot after recognition
HDAnzz May 1, 2026
8db8e4c
fix: use numpy channel swap instead of cv2 for BGR->RGB
HDAnzz May 1, 2026
aa9c718
fix: remove dead update_image_display method and call
HDAnzz May 1, 2026
815b6b9
fix: update monster avatar display path to images/monsters/
HDAnzz May 1, 2026
9f9d771
docs: update AGENTS.md with verified architecture and current entry p…
HDAnzz May 1, 2026
f90f4d4
merge: integrate main branch changes into refactor structure
HDAnzz May 2, 2026
b57a084
refactor: move eg.png to images/samples/roi_selecting_eg.png
HDAnzz May 2, 2026
7784718
refactor: move analytics module to utils
HDAnzz May 2, 2026
257bbea
style: format all python files and optimize imports with ruff
HDAnzz May 2, 2026
50feba3
chore: add pre-commit hooks for ruff import sorting and formatting
HDAnzz May 2, 2026
b74d299
chore: add ruff lint check to pre-commit hooks
HDAnzz May 2, 2026
244c2a0
fix: resolve code review issues from merge
HDAnzz May 2, 2026
338f69c
docs: generate main vs refactor comparison report
HDAnzz May 2, 2026
58f26ab
docs: generate PR message from diff comparison
HDAnzz May 2, 2026
5de7bec
docs: add v2.0.0 changelog
HDAnzz May 2, 2026
8fa1621
refactor: rename main.spec to cannotmax.spec
HDAnzz May 2, 2026
da2c7d5
fix: correct monster avatar image paths and typo in similar_history_m…
HDAnzz May 2, 2026
5f45cdc
refactor: move data packaging output to output/data/ and add empty-da…
HDAnzz May 2, 2026
b1f6e8d
refactor: move data package output dir to config/app.json
HDAnzz May 2, 2026
5d190f0
fix: indentation error in package_data_and_show
HDAnzz May 2, 2026
398a564
fix: use config.paths for DATA_DIR/COMPRESSED_DIR in merge_data.py
HDAnzz May 2, 2026
cf9f413
fix: correct date dir length check and monster CSV path in merge_data
HDAnzz May 2, 2026
8d9918e
refactor: use PROJECT_ROOT instead of DATA_DIR.parent in merge_data
HDAnzz May 2, 2026
a452a92
docs: update README for v2.0 refactored structure
HDAnzz May 2, 2026
3bbdbf3
ci: use uv sync --extra cpu in test workflow
HDAnzz May 2, 2026
09b9002
merge: resolve conflicts with upstream/main
HDAnzz May 2, 2026
22c5790
refactor: establish mixed import style
HDAnzz May 2, 2026
9f8fe0c
fix: correct mock patch paths from src.cannotmax to cannotmax in tests
HDAnzz May 2, 2026
54e6873
chore: restore version 2.0.0-alpha.1 and fix pre-commit hooks to use …
HDAnzz May 2, 2026
832eb9b
fix: lazy-import torch modules for ONNX-only packaged builds
HDAnzz May 2, 2026
bdbcc9e
feat: add multi subcommand for multi-instance manager
HDAnzz May 2, 2026
39054e2
refactor: use cannotmax multi subcommand for multi-instance launcher
HDAnzz May 2, 2026
cdad75a
fix: skip terrain feature loading when FIELD_FEATURE_COUNT=0
HDAnzz May 2, 2026
ee6bc02
fix: create config/app.json from defaults when missing, include battl…
HDAnzz May 2, 2026
a4f39a2
fix: replace legacy import recognize with cannotmax.core import in da…
HDAnzz May 2, 2026
09d295e
feat: add tools and pipelines dev subcommands
HDAnzz May 2, 2026
9007144
refactor: use thin _multi.py wrapper for multi-instance exe
HDAnzz May 2, 2026
8f85876
fix: include maa package DLLs and hidden imports in PyInstaller build
HDAnzz May 2, 2026
54c1b42
fix: enable auto-fetch for PC mode, fix indentation in pc_connector
HDAnzz May 2, 2026
5818326
fix: add missing logger import in window_picker.py
HDAnzz May 2, 2026
b5bf58d
feat: log top3 template match scores when state detection fails
HDAnzz May 2, 2026
e9884b8
feat: add PC-mode state templates and multi-template matching
HDAnzz May 2, 2026
d175c45
merge: resolve conflicts with upstream/main, add admin elevation and …
HDAnzz May 2, 2026
5dc8b61
chore: bump to 2.0.0-alpha.2 and update all docs
HDAnzz May 2, 2026
3571bca
docs: update PR message per review feedback
HDAnzz May 2, 2026
3cee5b5
fix: admin elevation launches via python -m cannotmax with correct CWD
HDAnzz May 3, 2026
70d6cea
feat: add tools and pipelines as standalone CLI entry points
HDAnzz May 3, 2026
a72f2d1
docs: simplify tools/pipelines commands in docs
HDAnzz May 3, 2026
c6e8a62
fix: skip admin elevation in PyInstaller frozen builds
HDAnzz May 3, 2026
0aa8410
fix: enable admin auto-elevation for packaged exe via ShellExecuteW
HDAnzz May 3, 2026
19c80fb
fix: check file existence before loading PC state templates
HDAnzz May 3, 2026
3fdd1bd
refactor: reorganize main_window.py methods by logical group
HDAnzz May 3, 2026
bb128cc
fix: resolve adb.exe path to absolute to prevent MAA exec failures
HDAnzz May 3, 2026
79b3610
fix: check file existence before loading PC state templates
HDAnzz May 3, 2026
19990a1
chore: update lockfile
HDAnzz May 3, 2026
9fc2e48
refactor: use process path to restart PC game, remove hardcoded path …
HDAnzz May 3, 2026
0608746
refactor: centralize all hardcoded paths into config/paths.py
HDAnzz May 3, 2026
48a72ba
docs: add unreleased section to CHANGELOG.md for path table refactor …
HDAnzz May 3, 2026
46fb421
docs: add architecture and development guides for new contributors
HDAnzz May 3, 2026
b2b9439
refactor: move training constants to cannotdeeper.config, cannotmax r…
HDAnzz May 3, 2026
96c1038
fix: restore UNIT_CONFIG re-export, fix app.json path in cannotdeeper
HDAnzz May 3, 2026
0982b2e
refactor: move models/ from cannotmax to cannotdeeper
HDAnzz May 3, 2026
bfacce8
fix: update stale cannotmax.models imports to cannotdeeper.models
HDAnzz May 3, 2026
c80040c
refactor: move predict.py to cannotdeeper, cannotmax is ONNX-only
HDAnzz May 3, 2026
ecba918
refactor: move pipelines/ from cannotmax to cannotdeeper
HDAnzz May 3, 2026
dd72926
refactor: split tools/ — move ML tools to cannotdeeper, keep packagin…
HDAnzz May 3, 2026
ce444f6
refactor: extract cannotsim as independent battle simulation package
HDAnzz May 3, 2026
a4f27fd
chore: update configs for three-package split (cannotdeeper, cannotsi…
HDAnzz May 3, 2026
67b7751
test: update imports for three-package split, add new package tests
HDAnzz May 3, 2026
eeb362c
chore: final cleanup after three-package split
HDAnzz May 3, 2026
88c90c9
refactor: move PyTorch field model to cannotdeeper, cannotmax stub is…
HDAnzz May 3, 2026
5884658
refactor: split CLI into three independent entry points (cannotmax/ca…
HDAnzz May 3, 2026
6f5369c
fix: resolve monster icon paths and REVERSE_MONSTER_MAPPING name look…
HDAnzz May 3, 2026
0fc2653
refactor: rename cannotdeeper to cannotdl, fix monster icon paths and…
HDAnzz May 3, 2026
b53a5c2
fix: use centralized MONSTER_CSV from cannotmax.config.paths
HDAnzz May 3, 2026
54baf0b
refactor: move MONSTER_IMAGES/MONSTER_DATA to utils, cleanup settings…
HDAnzz May 3, 2026
891f072
chore: update .gitignore to match current project structure
HDAnzz May 3, 2026
399f99f
docs: update AGENTS.md, README.md, ARCHITECTURE.md, DEVELOPMENT.md fo…
HDAnzz May 3, 2026
43e654e
fix: replace hardcoded icon paths in cannonsim with centralized MONST…
HDAnzz May 3, 2026
5d64849
fix: use Path.with_suffix() instead of string rfind in convert_model.py
HDAnzz May 3, 2026
f116c18
fix: use Path.with_suffix() instead of string rfind in convert_model.py
HDAnzz May 3, 2026
ac2795b
fix: resolve WIN mode KeyError and NameError in process_regions, fix …
HDAnzz May 3, 2026
916de58
feat: add tools subcommand to cannotmax CLI for running dev scripts
HDAnzz May 3, 2026
22b96a6
fix: correct .agents typo in .gitignore (.agnets → .agents)
HDAnzz May 3, 2026
8d425f6
docs: add TODO.md tracking progress
HDAnzz May 3, 2026
6f9d772
fix: bundle cannotsim.exe in same output dir, fix frozen launch path
HDAnzz May 4, 2026
a42911b
refactor: remove standalone multi-instance exe; use cannotmax multi only
HDAnzz May 4, 2026
cbf87a9
feat: add 多开管理器.bat launcher for cannotmax.exe multi
HDAnzz May 4, 2026
65f69a9
fix: add dev fallback to 多开管理器.bat
HDAnzz May 4, 2026
4c93def
merge: resolve conflicts with upstream/main (PR #154)
HDAnzz May 4, 2026
e3e0792
revert: keep origin/refactor dark_mode_style_fix.py
HDAnzz May 4, 2026
596c282
fix: remove redundant set_input_method call in main_window
HDAnzz May 4, 2026
54a01cb
docs: update TODO.md
HDAnzz May 4, 2026
05d6a47
fix: WIN mode - find_monster_zone coordinate transform + roi_transfor…
HDAnzz May 4, 2026
4c86dc8
chore: update TODO.md
HDAnzz May 4, 2026
5e3b32d
docs: update CHANGELOG.md - WIN mode recognition refactor
HDAnzz May 4, 2026
0937776
fix: remove auto_fallback, fix test crop_ratio, simplify detected_zones
HDAnzz May 4, 2026
8c4cdc6
feat: auto set crop_ratio/avatar/number regions when switching ADB/PC…
HDAnzz May 4, 2026
2a26a7c
fix: rename test images screenshort->screenshot
HDAnzz May 4, 2026
1ba82d3
test: add roi_transform unit tests
HDAnzz May 5, 2026
d2fee36
fix: ADB/PC mode uses RECOGNITION_PARAMS for crop_ratio and regions
HDAnzz May 5, 2026
83211e6
fix: wait first frame in PcConnector.capture_screenshot instead of ca…
HDAnzz May 5, 2026
1511edc
fix: disable auto_fetch button in WIN mode
HDAnzz May 5, 2026
f514d83
docs: update CHANGELOG.md - PC mode and window picker
HDAnzz May 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
run: uv sync --group dev

- name: Build with PyInstaller
run: uv run tools/package.py
run: uv run python src/cannotmax/tools/package.py

- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
name: cannotmax-build
path: output/main/
path: output/cannotmax/
retention-days: 1

release:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: uv sync --extra cpu

- name: Run tests
run: uv run pytest tests/ -v --tb=short
39 changes: 12 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ venv/
.venv/
__pycache__/
.mypy_cache/
.pytest_cache/
.ruff_cache/
*.pyc
*.pyo

# ===========================
# 2. Pixi 包管理环境
Expand All @@ -21,55 +25,36 @@ __pycache__/
# ===========================
# 4. AI 辅助工具配置
# ===========================
.agents/
.claude/
.codex/
.copilot/
.codeartsdoer
docs/superpowers/

# ===========================
# 5. 模型权重与构建产物
# ===========================
# 模型文件
models/*.png
*.pth
*.onnx
*.onnx.data

models
!models/update.md
# 构建与输出目录
build/
output/
outputs/

# ===========================
# 6. 数据集与媒体资源
# ===========================
# 基础数据目录
data/images/
data/[0-9][0-9][0-9][0-9]_[0-1][0-9]_[0-3][0-9]__[0-2][0-9]_[0-5][0-9]_[0-5][0-9]/
images/nums/

arknights_package_[0-9][0-9][0-9][0-9][0-1][0-9][0-3][0-9]_[0-2][0-9][0-5][0-9][0-5][0-9].zip

# 训练相关数据
data_train/tmp/
data_train/package/*.zip
data_train/data_images/

# 单独的截图文件
screenshot.png
data/*
!data/compressed/.gitkeep
images/tmp/

# ===========================
# 7. 日志与临时文件
# ===========================
# 日志
log.txt
*.log

# 临时目录
tmp

# ===========================
# 8. 其他杂项文件
# ===========================
arknights.csv
multi_ports.txt
*.bak
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: local
hooks:
- id: ruff-lint
name: ruff (lint)
entry: ruff check
language: system
types: [python]
- id: ruff-check-imports
name: ruff (import sorting)
entry: ruff check --select I --fix
language: system
types: [python]
pass_filenames: false
- id: ruff-format
name: ruff (format)
entry: ruff format
language: system
types: [python]
pass_filenames: false
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
163 changes: 163 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# CannotMax-Greenvine Agent Instructions

## Quick Start

```bash
uv sync # Install dependencies (includes Windows-only packages)
uv sync --extra cu128 # CUDA 12.8 support (PyTorch cu128)
uv sync --extra cpu # CPU-only fallback

uv run cannotmax # Launch GUI
uv run cannotmax multi # Multi-instance manager

uv run cannotdl train # Train model
uv run cannotdl eval # Evaluate model
uv run cannotdl convert -i model.pth -o model.onnx # PyTorch → ONNX
uv run cannotdl tools <name> # Run dev tool (e.g., statistics)
uv run cannotdl pipelines <name> # Run data pipeline (e.g., merge_data)

uv run cannotsim sim # Battle simulator (PyQt6)
uv run cannotsim sim_mc # Tkinter Monte Carlo simulator

uv run pytest tests/ # Run all tests
uv run pytest tests/ -m "not e2e" # Skip e2e (needs emulator)
```

## Critical Environment Constraints

- **Windows-only**: `windows-capture` (WinRT), `pywin32`, `maafw` are not available on Linux/macOS
- **PC mode requires admin**: SendInput click operations require administrator privileges. `console.py` auto-elevates via `_ensure_admin()`.
- **PyTorch cu128**: Domestic mirrors don't host CUDA 12.8 wheels. Source must be `https://download.pytorch.org/whl/cu128/` (configured in `pyproject.toml`). Fallback: `--extra cpu`.
- **OpenCV**: `opencv-python` only. Do NOT add `opencv-python-headless` — they conflict.
- **Resolution**: Target 1920×1080 (16:9). PC mode state templates available at `images/process/pc_*.png` for non-1080p resolutions.

## Architecture

### Package Structure

```
src/cannotdl/ # 模型训练与数据处理
├── config/ # MONSTER_COUNT, FIELD_FEATURE_COUNT, MONSTER_DATA (dict)
├── core/ # PyTorch 推理(CannotModel) + TorchFieldRecognizer
│ ├── field_model.py # TorchFieldRecognizer(PyTorch 地形识别)
│ └── predict.py # CannotModel 推理
├── models/ # UnitAwareTransformer, ArknightsDataset
├── training/ # 训练器、评估器、Muon+Lion 优化器
├── pipelines/ # 数据清洗、合并、打包流水线
├── tools/ # 统计、模型转换、数据审查
└── console.py # uv run cannotdl 入口

src/cannotsim/ # 战斗模拟引擎
├── battle_field.py # 战场状态与帧模拟
├── main_sim.py # PyQt6 模拟器 GUI
├── sim_mc.py # Tkinter 多核模拟器
├── console.py # uv run cannotsim 入口
└── utils.py # MONSTER_MAPPING, REVERSE_MONSTER_MAPPING

src/cannotmax/ # 主包 (GUI + 运行时)
├── config/
│ ├── __init__.py # DEBUG_MODE, DISABLE_MAAFW (运行时配置)
│ ├── paths.py # 所有路径常量(集中管理)
│ └── settings.py # app.json 加载
├── core/ # 识别(ONNX)、自动获取、连接器
├── gui/ # PyQt6 图形界面
├── tools/ # 打包(package.py) + ROI 选取
└── utils/ # 延迟加载的图像/数据、匹配、区域检测
```

### Entry Points

- **cannotmax** (`uv run cannotmax`): GUI 运行时、多开管理
- **cannotdl** (`uv run cannotdl`): train, eval, convert, tools, pipelines
- **cannotsim** (`uv run cannotsim`): sim, sim_mc, simulate

### Path Constants

All paths are defined in `cannotmax/config/paths.py`. Rules:

1. No hardcoded path strings in code — all paths from `paths.py`
2. Directory constants end with `DIR` (e.g., `DATA_DIR`)
3. File constants end with format extension (e.g., `MONSTER_CSV`, `APP_CONFIG_JSON`)

Key constants: `DATA_DIR`, `MODELS_DIR`, `CONFIG_DIR`, `IMAGES_DIR`, `MONSTER_IMAGES_DIR`, `PROCESS_IMAGES_DIR`, `TMP_IMAGES_DIR`, `MONSTER_CSV`, `PACKAGE_OUTPUT_DIR`, `PACKAGE_FORMAT`, `OUTPUT_DIR`, `ICO_DIR`, `THIRDPARTY_DIR`, `ADB_EXE`

### Capture Modes

1. **ADB**: `AdbConnector` in `core/connector/adb_connector.py` — emulators (LDPlayer, MuMu, BlueStacks)
2. **PC**: `PcConnector` in `core/connector/pc_connector.py` — official Arknights PC client (**requires admin**)
3. **WIN**: `WinRTScreenCapture` in `core/connector/winrt_capture.py` — window/monitor capture via WinRT

### Model Loading

- `cannotmax` uses `predict_onnx.py` (ONNX only, zero `import torch` at module level)
- `cannotdl` uses `predict.py` (PyTorch, for training/evaluation)
- `cannotdl.core.field_model.TorchFieldRecognizer` contains full PyTorch field recognition
- `cannotmax.core.field_recognition.FieldRecognizer` is a zero-torch stub that delegates to `TorchFieldRecognizer` when `FIELD_FEATURE_COUNT > 0`
- Default model path: `models/predictor/` (set via `paths.MODELS_DIR`)
- Fallback: if no pattern-matching model found, picks any `.pth` file by mtime

### Data Files

- `monster_greenvine.csv` (root): Monster data indexed by `id` (78 monsters)
- `data/compressed/*.zip`: Archived training data packages
- `config/app.json`: Runtime config (auto-created from defaults if missing)
- `images/monsters/`: Monster template images (named by 原始名称)
- `images/process/{0-15}.png` + `images/process/pc_{i}.png`: State detection templates

## Conventions

### Import Rules

- **Same-package**: Use relative (`from .xxx import YYY`, `from ..xxx import YYY`)
- **Cross-package**: Use absolute with package prefix (`from cannotmax.config import MONSTER_COUNT`)
- **Tests**: Use `from src.cannotmax.xxx import YYY` (run from project root)

### Git Commit Style

Format: `type: description` (e.g., `fix:`, `refactor:`, `feat:`, `chore:`, `docs:`, `style:`)

## MAA Framework Integration

- Binaries auto-loaded from `maafw` Python package — no local copy needed
- `DISABLE_MAAFW` flag in `config/app.json` → `settings.py` for legacy ADB fallback
- `@patch` paths in tests must use `cannotmax.xxx` (not `src.cannotmax.xxx`)
- Packaged build: `hiddenimports=['maa', ...]` + `collect_dynamic_libs('maa')` in spec

## PC Mode

- **Admin required**: `console.py:_ensure_admin()` auto-elevates on startup
- **State templates**: `images/process/pc_{i}.png` added for PC UI scale; multi-template matching picks best
- **Click**: MAA Win32Controller preferred, SendInput as fallback
- **Auto-fetch**: Now works in PC mode (was restricted to ADB only)

## Testing

```bash
uv run pytest tests/ # All tests
uv run pytest tests/ -m "not e2e" # Skip e2e
uv run pytest tests/test_imports.py # Import checks only
```
- Pytest marker: `@pytest.mark.e2e` for tests requiring real ADB simulator
- CI: Windows runner only (`runs-on: windows-latest`), uses `uv sync --extra cpu`

## Pre-commit Hooks

- `ruff (lint)` — static analysis on staged Python files
- `ruff (import sorting)` — auto-sort imports
- `ruff (format)` — auto-format code
- Config uses `ruff` directly (not `uv run ruff`) to avoid `uv sync` interference

## Common Pitfalls

1. **Don't rename/delete `core/connector/winrt_capture.py`**: Imported by `pc_connector.py` and `main_window.py`
2. **OpenCV**: Only `opencv-python`, never `opencv-python-headless`
3. **cu128 network issues**: Frequent on Chinese networks; provide CPU fallback
4. **`UnitAwareTransformer` namespace**: Must be importable from `__main__` before `torch.load()`
5. **Lazy torch imports**: `field_recognition.py` imports torch inside methods — safe for ONNX-only builds
6. **Packaged build**: `cannotdl.core` excluded; `core/__init__.py` has try/except fallback to `predict_onnx`
7. **Multi-instance data**: Stop ALL instances before running data packaging
8. **`monster_greenvine.csv`**: `MONSTER_COUNT` derives from its row count (currently 78)
9. **`FIELD_FEATURE_COUNT = 0`**: Set in `config/app.json` — terrain pipeline not active
10. **PC mode state detection**: Uses `images/process/pc_{i}.png` when available, falling back to `{i}.png`
11. **MONSTER_DATA in cannotmax**: Use `cannotmax.utils.monster_data.get_monster_data()` (DataFrame), not `cannotdl.config.MONSTER_DATA` (dict)
12. **Monster avatar paths**: Use `cannotmax.utils.monster_data.get_monster_avatar_path(id)` instead of `MONSTER_IMAGES_DIR / f"{MONSTER_DATA['原始名称'][id]}.png"`
Loading