This is a refined version of the original 《T-detector: A Trajectory based Pretrained Model for Game Bot Detection in MMORPGs》, adapted for modern macOS (ARM64) development environments and extended with an offline cluster radar workflow for latent-space behavioral analysis.
Base Repository: aker218/T-Detector
The original codebase (designed for Python 3.6/3.7) has been upgraded and patched to support macOS ARM64 (M1/M2/M3) and Python 3.12+:
- Gensim 4.0+ Integration:
- Updated
Word2Vecparameters:size→vector_size. - Updated
iter→epochs. - Fixed vocabulary access for modern Gensim API.
- Updated
- Transformer & PyTorch Upgrades:
- Migrated
AdamWandBertLayerNormimports to standardtorch.optimandtorch.nnfor compatibility withtransformers 4.x.
- Migrated
- Dependency Cleanup:
- Removed
DGLlibrary dependencies to bypass C++ compilation errors on ARM64 macOS. - Replaced deprecated NumPy aliases (e.g.,
np.int,np.float) with standard Python types to prevent runtime crashes.
- Removed
- Stability Fixes:
- Resolved directory creation typos (
makedirs(exists_ok=True)). - Patched
trainer.pyto handle zero-loss batches during initial pre-training phases. - Fixed sequence length calculation logic in
models.py.
- Resolved directory creation typos (
The repo now includes an offline analysis layer on top of the original supervised T-Detector pipeline:
- Feature Extraction: Extract session-level latent vectors from the trained encoders.
- High-Dimensional Clustering: Cluster embeddings in normalized high-dimensional space with HDBSCAN.
- 2D Radar Visualization: Project latent vectors to 2D with UMAP and render them with Plotly WebGL.
- Map-Level Analysis: Analyze one map at a time to avoid cross-map behavior mixing.
- Interactive Review:
- Search by AccID/UserID
- Highlight clusters and outliers
- Open session trajectory plots
- Generate latent profile summaries
This layer is meant for offline investigation and presentation. It does not replace the original supervised classifier.
Recommended Environment: Python 3.12+
# Core Dependencies
pip install numpy pandas scipy scikit-learn tqdm torch transformers gensim
# Visualization Dependencies
pip install umap-learn hdbscan plotly matplotlibT-Detector
├── train_data/ # Full raw session data (move / mouse)
├── train_data_sampled/ # Sampled session data
├── train_data_sampled_processed/ # Processed sampled features / vocab / merge-split
├── trajectory_detector/
│ ├── angle_pretrain.py # Angle pretraining
│ ├── train_and_evaluate.py # Supervised training / evaluation
│ ├── extract_features.py # Extract latent features for clustering
│ ├── visualize_2d.py # Generic radar visualization
│ ├── explain_behavior.py # Latent profile summary
│ ├── dataset.py # Torch dataset logic
│ ├── models.py # T-Detector model architecture
│ ├── trainer.py # Training utilities
│ └── run.sh # Original pipeline entry
├── map_analyzer.py # Map-level offline clustering + radar HTML
├── player_trajectory_viewer.py # Render move / mouse session plots
├── bridge_server.py # Local HTTP bridge for HTML tool buttons
└── analysis_results/ # Generated reports / radar pages / logsIf you need sampled latent features:
python3 trajectory_detector/extract_features.py \
-D ./train_data_sampled_processed \
-C ./trajectory_detector/models/train_data_sampled_processed_script_data_model/merge_split_embedding_ConvGRU_mutual_attention_residual(rnn_input)_fusion_without_fre_100_trainset(ptretrain)/checkpoint-1248/model.pt \
-O extracted_sampled \
--feature_mode encoder_concatpython3 trajectory_detector/visualize_2d.py \
--features ./train_data_sampled_processed/extracted_sampled_features.npy \
--meta ./train_data_sampled_processed/extracted_sampled_meta.json \
--output ./train_data_sampled_radar_vision.html \
--min_cluster_size 30 \
--min_samples 10 \
--pca_dim 32For a real map-level radar page, prefer map_analyzer.py.
If map-specific full features already exist:
python3 map_analyzer.py \
--mapid 338 \
--train_data ./train_data \
--output ./analysis_results \
--min_cluster_size 30 \
--min_samples 10 \
--pca_dim 32If full map features do not exist yet, build them directly from raw sessions and then cluster:
python3 map_analyzer.py \
--mapid 338 \
--train_data ./train_data \
--output ./analysis_results \
--build_from_raw \
--processed_dir ./train_data_sampled_processed \
--min_cluster_size 30 \
--min_samples 10 \
--pca_dim 32 \
--feature_batch_size 32This generates:
analysis_results/map_338/train_data_338_radar_vision.htmlanalysis_results/map_338/train_data_338_cluster_report.mdanalysis_results/map_338/filtered_features.npyanalysis_results/map_338/filtered_meta.json
To make PLOT TRAJECTORY and EXPLAIN LATENT PROFILE buttons work from the generated HTML:
python3 bridge_server.pyKeep that process running while you open the radar HTML.
visualize_2d.pyis the generic feature viewer.map_analyzer.pyis the recommended entry point for offline map investigation.- Clustering is performed in high-dimensional embedding space; UMAP is used only for visualization.
- The current offline radar is an analysis tool built on top of the supervised T-Detector model. It is not yet a fully unsupervised binary classifier.
Maintained by williammuji. Original research by the T-Detector authors.