forked from Darkest-Teddy/DynamicMarioBros
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_generator.py
More file actions
42 lines (35 loc) · 1.52 KB
/
test_generator.py
File metadata and controls
42 lines (35 loc) · 1.52 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
from generate_level import MarioLevelGenerator
# Put your API key here
API_KEY = "AIzaSyAxlfwHUMQ5cxlfW2EiLpznh1QBf4BgsfY"
# Initialize the generator (now using "Maps" folder)
print("🎮 Initializing Mario Level Generator...")
generator = MarioLevelGenerator(API_KEY) # Will automatically use "Maps" folder
# Load existing levels (for training)
print("📚 Loading existing levels from Maps folder...")
generator.load_all_maps()
print(f"✅ Loaded {len(generator.all_maps)} levels")
# Generate your first level!
print("\n🎨 Generating a new level...")
try:
result = generator.generate_and_validate_level(
difficulty="medium",
theme="Overworld",
special_features=["pipes", "coins"]
)
# Save the level (will save to Maps folder)
filepath = generator.save_generated_level(result['code'])
print(f"\n🎉 SUCCESS! Your new level is ready!")
print(f"📁 Saved to: {filepath}")
print(f"\n📊 Stats:")
print(f" - Difficulty: {result['difficulty']}")
print(f" - Theme: {result['theme']}")
print(f" - Warnings: {len(result['validation']['warnings'])}")
if result['validation']['warnings']:
for warning in result['validation']['warnings']:
print(f" ⚠️ {warning}")
except Exception as e:
print(f"\n❌ Generation failed: {e}")
print("\nTips:")
print("- Make sure your API key is correct")
print("- Check that Maps folder exists with World*.js files")
print("- Try running again (sometimes it needs multiple attempts)")