-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
199 lines (166 loc) Β· 5.17 KB
/
setup.py
File metadata and controls
199 lines (166 loc) Β· 5.17 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env python3
"""
ElixirMind Setup Script
Automated installation and configuration.
"""
import subprocess
import sys
import os
from pathlib import Path
def run_command(cmd, description):
"""Run a command and handle errors"""
print(f"π§ {description}...")
try:
result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
print(f"β
{description} completed")
return True
except subprocess.CalledProcessError as e:
print(f"β {description} failed: {e}")
print(f"Output: {e.output}")
return False
def install_dependencies():
"""Install Python dependencies"""
print("π¦ Installing dependencies...")
# Upgrade pip first
if not run_command("python -m pip install --upgrade pip", "Upgrading pip"):
return False
# Install core dependencies
core_deps = [
"opencv-python",
"numpy",
"pyautogui",
"mss",
"pillow",
"streamlit",
"plotly",
"pandas"
]
for dep in core_deps:
if not run_command(f"pip install {dep}", f"Installing {dep}"):
return False
# Optional dependencies
optional_deps = [
"torch",
"torchvision",
"stable-baselines3",
"psutil",
"gputil"
]
print("π¦ Installing optional dependencies...")
for dep in optional_deps:
run_command(f"pip install {dep}", f"Installing {dep} (optional)")
return True
def create_directories():
"""Create necessary directories"""
print("π Creating directories...")
dirs = [
"models",
"data",
"data/logs",
"data/screenshots",
"data/templates",
"tests",
"vision/cache",
"strategy/models"
]
for dir_path in dirs:
Path(dir_path).mkdir(parents=True, exist_ok=True)
print(f"β
Created {dir_path}/")
return True
def download_models():
"""Download pre-trained models"""
print("π€ Downloading AI models...")
# This would normally download YOLOv5 models
# For now, just create placeholder
models_dir = Path("models")
placeholder = models_dir / "yolov5s.pt"
if not placeholder.exists():
placeholder.write_text("# Placeholder - Download real model from ultralytics.com")
print("β
Created models placeholder")
print(" Note: Download actual YOLOv5 weights from https://github.com/ultralytics/yolov5")
return True
def create_config():
"""Create default configuration"""
print("βοΈ Creating configuration...")
config_content = '''# ElixirMind Configuration
REAL_MODE = True
EMULATOR_TYPE = "memu"
USE_RL_STRATEGY = False
AGGRESSION_LEVEL = 0.6
TARGET_FPS = 10
SAFE_MODE = True
# Emulator settings
EMULATOR_PORT = 21503
SCREEN_REGION = (0, 0, 1920, 1080)
# AI settings
YOLO_MODEL = "models/yolov5s.pt"
RL_MODEL = "strategy/models/ppo_clash"
# Performance settings
MAX_MEMORY_USAGE = 80 # percent
CPU_THREADS = 4
'''
config_file = Path("config.py")
if not config_file.exists():
config_file.write_text(config_content)
print("β
Created config.py")
return True
def run_tests():
"""Run basic functionality tests"""
print("π§ͺ Running basic tests...")
# Simple import test
test_code = """
import sys
try:
import cv2
import numpy as np
import pyautogui
import mss
print("β
Core imports successful")
except ImportError as e:
print(f"β Import failed: {e}")
sys.exit(1)
"""
try:
result = subprocess.run([sys.executable, "-c", test_code],
capture_output=True, text=True, check=True)
print(result.stdout.strip())
return True
except subprocess.CalledProcessError as e:
print(f"β Tests failed: {e}")
print(e.output)
return False
def main():
print("π ElixirMind Setup")
print("=" * 50)
print("This will install all dependencies and configure the system.")
print()
steps = [
("Installing Python dependencies", install_dependencies),
("Creating directory structure", create_directories),
("Downloading AI models", download_models),
("Creating configuration files", create_config),
("Running basic tests", run_tests),
]
success_count = 0
for step_name, step_func in steps:
print(f"\n{step_name}...")
if step_func():
success_count += 1
print(f"β
{step_name} completed")
else:
print(f"β {step_name} failed")
break
print(f"\nπ Setup Results: {success_count}/{len(steps)} steps completed")
if success_count == len(steps):
print("\nπ Setup completed successfully!")
print("\nπ Next steps:")
print("1. Run: python auto_configurator.py")
print("2. Run: python run_bot.bat")
print("3. Run: python run_dashboard.bat (in new terminal)")
print("\nπ For detailed instructions, see README.md")
else:
print("\nβ Setup failed. Please check the errors above.")
print("You can try running individual steps manually.")
input("\nPress Enter to exit...")
if __name__ == "__main__":
main()