File size: 3,756 Bytes
1256289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# puzzle_generator.py
import random
from typing import Dict, List, Tuple

class CulturalPuzzleEngine:
    """Generador de acertijos basados en cultura argentina"""
    def __init__(self):
        self.puzzle_db = self._load_cultural_database()
        self.quantum_entanglements = {}
    
    def _load_cultural_database(self) -> Dict[str, dict]:
        return {
            'refranes': {
                'source': 'Dichos populares argentinos',
                'data': [
                    ('Más perdido que', 'un perro en una cancha de bochas'),
                    ('Al que madruga...', 'Dios lo ayuda'),
                    ('Cuando el río suena...', 'piedras trae')
                ]
            },
            'historia': {
                'source': 'Eventos históricos clave',
                'data': [
                    ('Año de la Revolución de Mayo', '1810'),
                    ('Batalla de Tucumán', '1812'),
                    ('Ley de Educación Común', '1884')
                ]
            },
            'geografia': {
                'source': 'Geografía argentina',
                'data': [
                    ('Provincia del fin del mundo', 'Tierra del Fuego'),
                    ('Río que separa Buenos Aires de Uruguay', 'Uruguay'),
                    ('Cumbre más alta de América', 'Aconcagua')
                ]
            }
        }
    
    def generate_dynamic_puzzle(self, puzzle_type: str) -> Tuple[str, str]:
        """Genera un acertijo cultural con solución entrelazada"""
        category = self.puzzle_db.get(puzzle_type)
        if not category:
            raise ValueError("Categoría de acertijo no válida")
        
        puzzle, solution = random.choice(category['data'])
        puzzle_id = f"{puzzle_type}_{hash(puzzle)}"
        self.quantum_entanglements[puzzle_id] = solution
        
        return (
            f"{puzzle} (Responde con la solución culturalmente apropiada)",
            puzzle_id
        )
    
    def verify_solution(self, puzzle_id: str, attempt: str) -> bool:
        """Verifica la solución usando entrelazamiento cuántico"""
        return self.quantum_entanglements.get(puzzle_id, "").lower() == attempt.lower()

class DynamicWorldPuzzle:
    """Sistema de acertijos integrados en el mundo del juego"""
    def __init__(self):
        self.puzzle_engine = CulturalPuzzleEngine()
        self.active_puzzles = {}
    
    def spawn_puzzle(self, biome: str, difficulty: int) -> dict:
        """Genera un acertijo contextual al bioma actual"""
        puzzle_types = {
            'pampa': ['refranes', 'historia'],
            'patagonia': ['geografia', 'historia'],
            'quebrada': ['refranes', 'geografia']
        }
        selected_type = random.choice(puzzle_types[biome])
        puzzle_text, puzzle_id = self.puzzle_engine.generate_dynamic_puzzle(selected_type)
        
        self.active_puzzles[puzzle_id] = {
            'biome': biome,
            'difficulty': difficulty,
            'solved': False,
            'timestamp': time.time()
        }
        
        return {
            'puzzle_id': puzzle_id,
            'text': puzzle_text,
            'hints': self._generate_hints(selected_type, puzzle_id)
        }
    
    def _generate_hints(self, category: str, puzzle_id: str) -> List[str]:
        """Genera pistas contextuales basadas en cultura argentina"""
        hints = []
        solution = self.puzzle_engine.quantum_entanglements[puzzle_id]
        
        if category == 'refranes':
            hints.append("Piensa en sabiduría popular transmitida oralmente")
        elif category == 'historia':
            hints.append("Consulta fechas clave de la historia argentina")
        
        return hints[:2]