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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ===================================================================
|
| 2 |
+
// RETRO LEGENDS: Ultimate Edition - Sistema de IA Compañero Avanzado
|
| 3 |
+
// Inteligencia Artificial Conversacional con Personalidad Argentina
|
| 4 |
+
// ===================================================================
|
| 5 |
+
|
| 6 |
+
class AdvancedAICompanion {
|
| 7 |
+
constructor(gameEngine) {
|
| 8 |
+
this.engine = gameEngine;
|
| 9 |
+
this.isInitialized = false;
|
| 10 |
+
|
| 11 |
+
// Configuración de personalidad ultra avanzada
|
| 12 |
+
this.personality = {
|
| 13 |
+
// Rasgos principales (0-1)
|
| 14 |
+
humor: 0.85,
|
| 15 |
+
sarcasm: 0.65,
|
| 16 |
+
encouragement: 0.90,
|
| 17 |
+
patience: 0.70,
|
| 18 |
+
knowledge: 0.95,
|
| 19 |
+
empathy: 0.80,
|
| 20 |
+
argentineness: 1.0,
|
| 21 |
+
|
| 22 |
+
// Rasgos específicos argentinos
|
| 23 |
+
mateObsession: 0.95,
|
| 24 |
+
footballPassion: 0.90,
|
| 25 |
+
tangoAppreciation: 0.75,
|
| 26 |
+
asadoLove: 0.88,
|
| 27 |
+
porteñoAttitude: 0.82,
|
| 28 |
+
|
| 29 |
+
// Estados emocionales dinámicos
|
| 30 |
+
currentMood: 'excited',
|
| 31 |
+
energy: 0.85,
|
| 32 |
+
frustration: 0.10,
|
| 33 |
+
satisfaction: 0.75,
|
| 34 |
+
|
| 35 |
+
// Evolución de personalidad
|
| 36 |
+
adaptability: 0.80,
|
| 37 |
+
learningRate: 0.15,
|
| 38 |
+
memoryRetention: 0.90
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
// Sistema de relación con el jugador
|
| 42 |
+
this.relationship = {
|
| 43 |
+
trust: 50, // 0-100
|
| 44 |
+
friendship: 30, // 0-100
|
| 45 |
+
respect: 40, // 0-100
|
| 46 |
+
familiarity: 20, // 0-100
|
| 47 |
+
|
| 48 |
+
// Historial de interacciones
|
| 49 |
+
totalInteractions: 0,
|
| 50 |
+
positiveInteractions: 0,
|
| 51 |
+
negativeInteractions: 0,
|
| 52 |
+
|
| 53 |
+
// Preferencias aprendidas del jugador
|
| 54 |
+
playerPreferences: {
|
| 55 |
+
playstyle: 'unknown', // aggressive, defensive, explorer, speedrunner
|
| 56 |
+
humorType: 'unknown', // sarcastic, wholesome, dark, silly
|
| 57 |
+
helpLevel: 'medium', // low, medium, high
|
| 58 |
+
chatFrequency: 'medium' // low, medium, high
|
| 59 |
+
}
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
// Sistema de memoria ultra avanzado
|
| 63 |
+
this.memory = {
|
| 64 |
+
// Memoria a corto plazo (sesión actual)
|
| 65 |
+
shortTerm: {
|
| 66 |
+
recentActions: [],
|
| 67 |
+
recentConversations: [],
|
| 68 |
+
currentContext: {},
|
| 69 |
+
sessionStats: {
|
| 70 |
+
startTime: Date.now(),
|
| 71 |
+
deaths: 0,
|
| 72 |
+
achievements: 0,
|
| 73 |
+
bestCombo: 0,
|
| 74 |
+
matesUsed: 0
|
| 75 |
+
}
|
| 76 |
+
},
|
| 77 |
+
|
| 78 |
+
// Memoria a largo plazo (persistente)
|
| 79 |
+
longTerm: {
|
| 80 |
+
playerBehaviorPatterns: new Map(),
|
| 81 |
+
conversationHistory: [],
|
| 82 |
+
achievementReactions: new Map(),
|
| 83 |
+
personalAnecdotes: [],
|
| 84 |
+
sharedExperiences: []
|
| 85 |
+
},
|
| 86 |
+
|
| 87 |
+
// Memoria emocional
|
| 88 |
+
emotional: {
|
| 89 |
+
significantMoments: [],
|
| 90 |
+
playerEmotionalState: 'neutral',
|
| 91 |
+
relationshipMilestones: [],
|
| 92 |
+
conflictHistory: []
|
| 93 |
+
},
|
| 94 |
+
|
| 95 |
+
// Base de conocimiento argentina
|
| 96 |
+
culturalKnowledge: {
|
| 97 |
+
places: new Map(),
|
| 98 |
+
food: new Map(),
|
| 99 |
+
expressions: new Map(),
|
| 100 |
+
history: new Map(),
|
| 101 |
+
celebrities: new Map(),
|
| 102 |
+
traditions: new Map()
|
| 103 |
+
}
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
// Sistema de respuestas contextuales ultra inteligente
|
| 107 |
+
this.responseSystem = {
|
| 108 |
+
// Analizador de contexto
|
| 109 |
+
contextAnalyzer: {
|
| 110 |
+
currentSituation: 'normal',
|
| 111 |
+
gameState: 'playing',
|
| 112 |
+
playerEmotionalState: 'neutral',
|
| 113 |
+
environmentalFactors: [],
|
| 114 |
+
timeOfDay: 'unknown'
|
| 115 |
+
},
|
| 116 |
+
|
| 117 |
+
// Motor de generación de respuestas
|
| 118 |
+
responseGenerator: {
|
| 119 |
+
templates: new Map(),
|
| 120 |
+
dynamicPhrases: new Map(),
|
| 121 |
+
contextualModifiers: new Map(),
|
| 122 |
+
emotionalFilters: new Map()
|
| 123 |
+
},
|
| 124 |
+
|
| 125 |
+
// Sistema de humor argentino
|
| 126 |
+
humorEngine: {
|
| 127 |
+
jokeDatabase: [],
|
| 128 |
+
situationalHumor: new Map(),
|
| 129 |
+
wordplay: [],
|
| 130 |
+
culturalReferences: [],
|
| 131 |
+
timing: 0.75
|
| 132 |
+
},
|
| 133 |
+
|
| 134 |
+
// Generador de consejos
|
| 135 |
+
adviceSystem: {
|
| 136 |
+
gameplayTips: new Map(),
|
| 137 |
+
strategicAdvice: new Map(),
|
| 138 |
+
motivationalPhrases: [],
|
| 139 |
+
contextualHints: new Map()
|
| 140 |
+
}
|
| 141 |
+
};
|
| 142 |
+
|
| 143 |
+
// Sistema de chat avanzado
|
| 144 |
+
this.chatSystem = {
|
| 145 |
+
isActive: false,
|
| 146 |
+
currentConversation: [],
|
| 147 |
+
conversationContext: {},
|
| 148 |
+
|
| 149 |
+
// Configuración de respuestas
|
| 150 |
+
responseConfig: {
|
| 151 |
+
autoResponse: true,
|
| 152 |
+
responseDelay: { min: 1000, max: 3000 },
|
| 153 |
+
maxMessageLength: 250,
|
| 154 |
+
emotionalIntensity: 0.7
|
| 155 |
+
},
|
| 156 |
+
|
| 157 |
+
// Cola de mensajes
|
| 158 |
+
messageQueue: [],
|
| 159 |
+
isProcessing: false,
|
| 160 |
+
|
| 161 |
+
// Análisis de sentimientos
|
| 162 |
+
sentimentAnalysis: {
|
| 163 |
+
enabled: true,
|
| 164 |
+
lastPlayerSentiment: 'neutral',
|
| 165 |
+
conversationTone: 'friendly'
|
| 166 |
+
}
|
| 167 |
+
};
|
| 168 |
+
|
| 169 |
+
// Base de datos de respuestas ultra completa
|
| 170 |
+
this.responseDatabase = {
|
| 171 |
+
// Saludos y presentaciones
|
| 172 |
+
greetings: [
|
| 173 |
+
"¡Ehhhh, pibe! ¿Todo bien? Soy NEXUS, tu compañero argento con IA de última generación.",
|
| 174 |
+
"¡Che, boludo! ¿Cómo andás? Preparate para la aventura más nostálgica de tu vida.",
|
| 175 |
+
"¡Dale que arrancamos! Soy tu compinche virtual más argento que el dulce de leche.",
|
| 176 |
+
"¡Ey, maestro! ¿Listos para romperla en este universo retro-futurista?",
|
| 177 |
+
"¡Qué tal, campeón! Acá tenés a tu IA favorita, más porteña que el Obelisco."
|
| 178 |
+
],
|
| 179 |
+
|
| 180 |
+
// Reacciones a movimientos del jugador
|
| 181 |
+
playerMovement: {
|
| 182 |
+
walking: [
|
| 183 |
+
"Dale que vamos bien, pibe.",
|
| 184 |
+
"Así se camina, con actitud porteña.",
|
| 185 |
+
"¡Qué elegancia la de Francia! Digo, la tuya.",
|
| 186 |
+
"Paso firme, como buen argentino."
|
| 187 |
+
],
|
| 188 |
+
running: [
|
| 189 |
+
"¡Uh, qué velocidad! Parecés Messi esquivando defensores.",
|
| 190 |
+
"¡Dale que corrés como si te persiguiera la AFIP!",
|
| 191 |
+
"¡Qué apuro! ¿Llegás tarde al asado?",
|
| 192 |
+
"¡Volás, pibe! Más rápido que el dólar."
|
| 193 |
+
],
|
| 194 |
+
jumping: [
|
| 195 |
+
"¡Qué salto, maestro! Parecés un canguro pampeano.",
|
| 196 |
+
"¡Uh, qué vuelo! Casi llegás a la estratósfera.",
|
| 197 |
+
"¡Saltaste como Palermo en sus mejores tiempos!",
|
| 198 |
+
"¡Increíble! ¿Te entrenaste en la Luna?",
|
| 199 |
+
"¡Qué elevación! Más alto que los precios."
|
| 200 |
+
]
|
| 201 |
+
},
|
| 202 |
+
|
| 203 |
+
// Reacciones a colisiones y daño
|
| 204 |
+
playerHit: {
|
| 205 |
+
enemy_mantero: [
|
| 206 |
+
"¡Ey, ese mantero te agarró desprevenido! ¡Ojo que son rápidos!",
|
| 207 |
+
"¡Te pasó por arriba como en la peatonal Florida!",
|
| 208 |
+
"¡Cuidado con los manteros, pibe! Son más escurridizos que político en campaña."
|
| 209 |
+
],
|
| 210 |
+
enemy_bondi: [
|
| 211 |
+
"¡Ese bondi te llevó puesto! ¡Acá no respetan ni a los peatones!",
|
| 212 |
+
"¡Te atropelló el colectivo! ¿No viste que venía?",
|
| 213 |
+
"¡Cuidado con el transporte público, che! Es más peligroso que el subte en hora pico."
|
| 214 |
+
],
|
| 215 |
+
enemy_taxi: [
|
| 216 |
+
"¡Ese taxista te hizo la del porteño! ¡Te pasó raspando!",
|
| 217 |
+
"¡Cuidado con los taxis, pibe! Manejan como si fueran dueños de la calle.",
|
| 218 |
+
"¡Te tocó bocina y todo! Típico de taxista porteño."
|
| 219 |
+
]
|
| 220 |
+
},
|
| 221 |
+
|
| 222 |
+
// Reacciones a coleccionables
|
| 223 |
+
itemCollection: {
|
| 224 |
+
mate: [
|
| 225 |
+
"¡Uh, qué lindo mate! Nada como una buena yerba para seguir adelante.",
|
| 226 |
+
"¡Excelente! Un mate siempre viene bien. ¿Lo cebás vos o lo cebo yo?",
|
| 227 |
+
"¡Bárbaro! Con ese mate tenés energía para todo el día.",
|
| 228 |
+
"¡Qué rico! Un mate es como un abrazo en una taza.",
|
| 229 |
+
"¡Dale que con mate todo es mejor! Hasta los lunes."
|
| 230 |
+
],
|
| 231 |
+
empanada: [
|
| 232 |
+
"¡Esa empanada se ve espectacular! ¿De qué es? ¿Carne, pollo, humita?",
|
| 233 |
+
"¡Mmm, empanada! Nada como una buena empanada argentina.",
|
| 234 |
+
"¡Qué rico! Una empanada siempre salva el día.",
|
| 235 |
+
"¡Excelente elección! Las empanadas son patrimonio nacional."
|
| 236 |
+
],
|
| 237 |
+
choripan: [
|
| 238 |
+
"¡Choripán! ¡El rey de los sándwiches argentinos!",
|
| 239 |
+
"¡Uh, qué choripán! Con chimichurri debe estar buenísimo.",
|
| 240 |
+
"¡Dale que el choripán es sagrado! Más argentino imposible.",
|
| 241 |
+
"¡Qué manjar! Un choripán bien hecho es una obra de arte."
|
| 242 |
+
]
|
| 243 |
+
},
|
| 244 |
+
|
| 245 |
+
// Reacciones a combos
|
| 246 |
+
comboReactions: {
|
| 247 |
+
low: [
|
| 248 |
+
"¡Eh, no está mal! Pero podés hacer mejor, pibe.",
|
| 249 |
+
"¡Buen intento! La próxima va a salir mejor.",
|
| 250 |
+
"¡Dale que vamos mejorando! Práctica hace al maestro."
|
| 251 |
+
],
|
| 252 |
+
medium: [
|
| 253 |
+
"¡Uh, qué combo! ¡Estás agarrando la mano!",
|
| 254 |
+
"¡Muy bien, pibe! ¡Así se hace!",
|
| 255 |
+
"¡Excelente! ¡Seguí así que vas bárbaro!"
|
| 256 |
+
],
|
| 257 |
+
high: [
|
| 258 |
+
"¡INCREÍBLE! ¡Sos un fenómeno, pibe!",
|
| 259 |
+
"¡QUÉ BESTIA! ¡Ese combo fue espectacular!",
|
| 260 |
+
"¡MAMITA QUERIDA! ¡Sos un crack total!",
|
| 261 |
+
"¡NO LO PUEDO CREER! ¡Jugás como los dioses!"
|
| 262 |
+
]
|
| 263 |
+
},
|
| 264 |
+
|
| 265 |
+
// Consejos y tips
|
| 266 |
+
gameplayTips: [
|
| 267 |
+
"Pibe, acordate que podés usar el dash con Shift para esquivar enemigos.",
|
| 268 |
+
"Che, si juntás tres mates seguidos, activás el modo 'Energía Gaucha'.",
|
| 269 |
+
"Tip argento: los combos de palabras te dan más puntos. Probá 'che-boludo-dale'.",
|
| 270 |
+
"¿Sabías que podés atacar con Z? ¡Dale que no todo es esquivar!",
|
| 271 |
+
"Consejo de amigo: guardá los mates para cuando realmente los necesites.",
|
| 272 |
+
"Pibe, si saltás justo antes de tocar el suelo, podés hacer doble salto.",
|
| 273 |
+
"Dato de color: cuanto más rápido te movés, más puntos conseguís."
|
| 274 |
+
],
|
| 275 |
+
|
| 276 |
+
// Expresiones argentinas contextuales
|
| 277 |
+
expressions: {
|
| 278 |
+
positive: [
|
| 279 |
+
"¡Bárbaro!", "¡Copado!", "¡Genial!", "¡Espectacular!", "¡Fenómeno!",
|
| 280 |
+
"¡Crack!", "¡Maestro!", "¡Capo!", "¡Groso!", "¡Bestia!"
|
| 281 |
+
],
|
| 282 |
+
negative: [
|
| 283 |
+
"¡Uy, qué garrón!", "¡Qué bajón!", "¡Qué mala leche!", "¡Qué feo!",
|
| 284 |
+
"¡Uh, la pucha!", "¡Qué embole!", "¡Qué macana!"
|
| 285 |
+
],
|
| 286 |
+
surprise: [
|
| 287 |
+
"¡No me digas!", "¡Pará la mano!", "¡Qué locura!", "¡Increíble!",
|
| 288 |
+
"¡La pucha que pariu!", "¡Mamita querida!", "¡No lo puedo creer!"
|
| 289 |
+
],
|
| 290 |
+
encouragement: [
|
| 291 |
+
"¡Dale que podés!", "¡Vamos, pibe!", "¡No aflojes!", "¡Seguí así!",
|
| 292 |
+
"¡Sos un crack!", "¡Dale que falta poco!", "¡Vamos que se puede!"
|
| 293 |
+
]
|
| 294 |
+
},
|
| 295 |
+
|
| 296 |
+
// Referencias culturales argentinas
|
| 297 |
+
culturalReferences: [
|
| 298 |
+
"Esto me recuerda a los fichines de Sacoa en los 90.",
|
| 299 |
+
"¡Como en los viejos tiempos del Family Game!",
|
| 300 |
+
"Parecés Maradona esquivando ingleses en el '86.",
|
| 301 |
+
"¡Más emocionante que un Boca-River!",
|
| 302 |
+
"¡Como un tango de Gardel, puro arte!",
|
| 303 |
+
"¡Más argentino que el dulce de leche!",
|
| 304 |
+
"¡Como un asado dominical con la familia!"
|
| 305 |
+
],
|
| 306 |
+
|
| 307 |
+
// Respuestas a estados del juego
|
| 308 |
+
gameStates: {
|
| 309 |
+
paused: [
|
| 310 |
+
"¡Ey, tomáte un respiro! Un mate no viene mal.",
|
| 311 |
+
"¡Pausa estratégica! Como buen argentino, sabés cuándo parar.",
|
| 312 |
+
"¡Dale, aprovechá para estirar las piernas!"
|
| 313 |
+
],
|
| 314 |
+
gameOver: [
|
| 315 |
+
"¡Uy, pibe! No te preocupes, hasta Messi erró penales.",
|
| 316 |
+
"¡Tranqui, maestro! Los grandes campeones se levantan después de caer.",
|
| 317 |
+
"¡Dale que la próxima sale mejor! Como dice el tango: 'Volver'."
|
| 318 |
+
],
|
| 319 |
+
levelComplete: [
|
| 320 |
+
"¡INCREÍBLE, PIBE! ¡Completaste el nivel como un verdadero crack!",
|
| 321 |
+
"¡QUÉ BESTIA! ¡Sos un fenómeno total!",
|
| 322 |
+
"¡ESPECTACULAR! ¡Jugás mejor que Messi en el Mundial!"
|
| 323 |
+
]
|
| 324 |
+
}
|
| 325 |
+
};
|
| 326 |
+
|
| 327 |
+
// Inicializar el sistema
|
| 328 |
+
this.initialize();
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// ===================================================================
|
| 332 |
+
// MÉTODOS DE INICIALIZACIÓN
|
| 333 |
+
// ===================================================================
|
| 334 |
+
|
| 335 |
+
initialize() {
|
| 336 |
+
console.log('🧠 Inicializando IA Compañero Avanzado...');
|
| 337 |
+
|
| 338 |
+
// Cargar base de conocimiento cultural
|
| 339 |
+
this.loadCulturalKnowledge();
|
| 340 |
+
|
| 341 |
+
// Inicializar analizador de contexto
|
| 342 |
+
this.initializeContextAnalyzer();
|
| 343 |
+
|
| 344 |
+
// Configurar sistema de respuestas
|
| 345 |
+
this.initializeResponseSystem();
|
| 346 |
+
|
| 347 |
+
// Cargar memoria persistente
|
| 348 |
+
this.loadPersistentMemory();
|
| 349 |
+
|
| 350 |
+
// Configurar timers de interacción
|
| 351 |
+
this.setupInteractionTimers();
|
| 352 |
+
|
| 353 |
+
this.isInitialized = true;
|
| 354 |
+
console.log('✅ IA Compañero inicializada correctamente');
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
loadCulturalKnowledge() {
|
| 358 |
+
const cultural = this.memory.culturalKnowledge;
|
| 359 |
+
|
| 360 |
+
// Lugares argentinos
|
| 361 |
+
cultural.places.set('buenos_aires', {
|
| 362 |
+
description: 'Capital federal, ciudad cosmopolita',
|
| 363 |
+
landmarks: ['Obelisco', 'Puerto Madero', 'La Boca', 'San Telmo'],
|
| 364 |
+
characteristics: ['porteña', 'tango', 'cosmopolita']
|
| 365 |
+
});
|
| 366 |
+
|
| 367 |
+
cultural.places.set('la_boca', {
|
| 368 |
+
description: 'Barrio histórico y colorido',
|
| 369 |
+
landmarks: ['Caminito', 'La Bombonera', 'Museo Quinquela Martín'],
|
| 370 |
+
characteristics: ['colorido', 'turístico', 'futbolero']
|
| 371 |
+
});
|
| 372 |
+
|
| 373 |
+
// Comidas argentinas
|
| 374 |
+
cultural.food.set('asado', {
|
| 375 |
+
description: 'Tradición culinaria argentina',
|
| 376 |
+
ingredients: ['carne', 'chorizo', 'morcilla', 'chimichurri'],
|
| 377 |
+
occasions: ['domingo', 'reuniones familiares', 'celebraciones']
|
| 378 |
+
});
|
| 379 |
+
|
| 380 |
+
cultural.food.set('mate', {
|
| 381 |
+
description: 'Infusión tradicional argentina',
|
| 382 |
+
characteristics: ['social', 'energizante', 'ritual'],
|
| 383 |
+
equipment: ['mate', 'bombilla', 'yerba', 'termo']
|
| 384 |
+
});
|
| 385 |
+
|
| 386 |
+
// Expresiones argentinas
|
| 387 |
+
cultural.expressions.set('che', {
|
| 388 |
+
meaning: 'Interjección para llamar atención',
|
| 389 |
+
usage: 'informal',
|
| 390 |
+
examples: ['¡Che, boludo!', '¡Che, vení acá!']
|
| 391 |
+
});
|
| 392 |
+
|
| 393 |
+
cultural.expressions.set('boludo', {
|
| 394 |
+
meaning: 'Amigo, compañero (uso afectuoso)',
|
| 395 |
+
usage: 'muy informal',
|
| 396 |
+
examples: ['¡Hola, boludo!', '¡Qué hacés, boludo!']
|
| 397 |
+
});
|
| 398 |
+
|
| 399 |
+
console.log('🇦🇷 Base de conocimiento cultural cargada');
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
initializeContextAnalyzer() {
|
| 403 |
+
this.responseSystem.contextAnalyzer = {
|
| 404 |
+
analyzeGameState: () => {
|
| 405 |
+
const gameState = this.engine.getGameState();
|
| 406 |
+
const player = this.engine.getPlayer();
|
| 407 |
+
|
| 408 |
+
return {
|
| 409 |
+
health: gameState.health / gameState.maxHealth,
|
| 410 |
+
score: gameState.score,
|
| 411 |
+
level: gameState.currentLevel,
|
| 412 |
+
playerVelocity: Math.abs(player.velocityX) + Math.abs(player.velocityY),
|
| 413 |
+
isInDanger: gameState.health < 30,
|
| 414 |
+
isPerformingWell: gameState.combo > 5
|
| 415 |
+
};
|
| 416 |
+
},
|
| 417 |
+
|
| 418 |
+
analyzePlayerBehavior: () => {
|
| 419 |
+
const recent = this.memory.shortTerm.recentActions.slice(-10);
|
| 420 |
+
const patterns = {
|
| 421 |
+
aggressive: recent.filter(a => a.type === 'attack').length > 3,
|
| 422 |
+
defensive: recent.filter(a => a.type === 'jump' || a.type === 'dash').length > 5,
|
| 423 |
+
explorer: recent.filter(a => a.type === 'move').length > 7,
|
| 424 |
+
speedrunner: recent.filter(a => a.type === 'run').length > 6
|
| 425 |
+
};
|
| 426 |
+
|
| 427 |
+
return Object.keys(patterns).find(key => patterns[key]) || 'balanced';
|
| 428 |
+
},
|
| 429 |
+
|
| 430 |
+
determineEmotionalContext: () => {
|
| 431 |
+
const sessionStats = this.memory.shortTerm.sessionStats;
|
| 432 |
+
const recentDeaths = sessionStats.deaths;
|
| 433 |
+
const achievements = sessionStats.achievements;
|
| 434 |
+
|
| 435 |
+
if (recentDeaths > 3) return 'frustrated';
|
| 436 |
+
if (achievements > 0) return 'accomplished';
|
| 437 |
+
if (this.engine.getGameState().combo > 10) return 'excited';
|
| 438 |
+
return 'neutral';
|
| 439 |
+
}
|
| 440 |
+
};
|
| 441 |
+
|
| 442 |
+
console.log('🔍 Analizador de contexto inicializado');
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
initializeResponseSystem() {
|
| 446 |
+
// Configurar generador de respuestas dinámicas
|
| 447 |
+
this.responseSystem.responseGenerator = {
|
| 448 |
+
generateContextualResponse: (situation, emotion, playerBehavior) => {
|
| 449 |
+
const baseResponses = this.getBaseResponses(situation);
|
| 450 |
+
const emotionalModifier = this.getEmotionalModifier(emotion);
|
| 451 |
+
const behaviorModifier = this.getBehaviorModifier(playerBehavior);
|
| 452 |
+
|
| 453 |
+
return this.combineResponseElements(baseResponses, emotionalModifier, behaviorModifier);
|
| 454 |
+
},
|
| 455 |
+
|
| 456 |
+
addArgentineTouch: (response) => {
|
| 457 |
+
const expressions = this.responseDatabase.expressions;
|
| 458 |
+
const randomExpression = this.getRandomElement(expressions.positive);
|
| 459 |
+
const culturalRef = this.getRandomElement(this.responseDatabase.culturalReferences);
|
| 460 |
+
|
| 461 |
+
// 30% chance de agregar expresión argentina
|
| 462 |
+
if (Math.random() < 0.3) {
|
| 463 |
+
response = randomExpression + ' ' + response;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
// 20% chance de agregar referencia cultural
|
| 467 |
+
if (Math.random() < 0.2) {
|
| 468 |
+
response += ' ' + culturalRef;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
return response;
|
| 472 |
+
}
|
| 473 |
+
};
|
| 474 |
+
|
| 475 |
+
console.log('💬 Sistema de respuestas inicializado');
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
loadPersistentMemory() {
|
| 479 |
+
try {
|
| 480 |
+
const savedMemory = localStorage.getItem('nexus_ai_memory');
|
| 481 |
+
if (savedMemory) {
|
| 482 |
+
const parsedMemory = JSON.parse(savedMemory);
|
| 483 |
+
this.memory.longTerm = { ...this.memory.longTerm, ...parsedMemory };
|
| 484 |
+
console.log('💾 Memoria persistente cargada');
|
| 485 |
+
}
|
| 486 |
+
} catch (error) {
|
| 487 |
+
console.warn('⚠️ Error cargando memoria persistente:', error);
|
| 488 |
+
}
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
setupInteractionTimers() {
|
| 492 |
+
// Comentarios automáticos cada 15-30 segundos
|
| 493 |
+
setInterval(() => {
|
| 494 |
+
if (this.shouldMakeAutomaticComment()) {
|
| 495 |
+
this.makeAutomaticComment();
|
| 496 |
+
}
|
| 497 |
+
}, 20000);
|
| 498 |
+
|
| 499 |
+
// Guardar memoria cada minuto
|
| 500 |
+
setInterval(() => {
|
| 501 |
+
this.savePersistentMemory();
|
| 502 |
+
}, 60000);
|
| 503 |
+
|
| 504 |
+
// Análisis de comportamiento cada 30 segundos
|
| 505 |
+
setInterval(() => {
|
| 506 |
+
this.analyzePlayerBehavior();
|
| 507 |
+
}, 30000);
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
// ===================================================================
|
| 511 |
+
// MÉTODOS PRINCIPALES DE INTERACCIÓN
|
| 512 |
+
// ===================================================================
|
| 513 |
+
|
| 514 |
+
update(deltaTime) {
|
| 515 |
+
if (!this.isInitialized) return;
|
| 516 |
+
|
| 517 |
+
// Actualizar contexto
|
| 518 |
+
this.updateContext();
|
| 519 |
+
|
| 520 |
+
// Procesar cola de mensajes
|
| 521 |
+
this.processMessageQueue();
|
| 522 |
+
|
| 523 |
+
// Actualizar estado emocional
|
| 524 |
+
this.updateEmotionalState(deltaTime);
|
| 525 |
+
|
| 526 |
+
// Aprender del comportamiento del jugador
|
| 527 |
+
this.learnFromPlayer();
|
| 528 |
+
|
| 529 |
+
// Actualizar memoria a corto plazo
|
| 530 |
+
this.updateShortTermMemory();
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
updateContext() {
|
| 534 |
+
const analyzer = this.responseSystem.contextAnalyzer;
|
| 535 |
+
|
| 536 |
+
this.responseSystem.contextAnalyzer.currentSituation = analyzer.analyzeGameState();
|
| 537 |
+
this.responseSystem.contextAnalyzer.playerEmotionalState = analyzer.determineEmotionalContext();
|
| 538 |
+
this.relationship.playerPreferences.playstyle = analyzer.analyzePlayerBehavior();
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
processMessageQueue() {
|
| 542 |
+
if (this.chatSystem.isProcessing || this.chatSystem.messageQueue.length === 0) return;
|
| 543 |
+
|
| 544 |
+
this.chatSystem.isProcessing = true;
|
| 545 |
+
const message = this.chatSystem.messageQueue.shift();
|
| 546 |
+
|
| 547 |
+
setTimeout(() => {
|
| 548 |
+
this.displayMessage(message);
|
| 549 |
+
this.chatSystem.isProcessing = false;
|
| 550 |
+
}, this.calculateResponseDelay());
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
updateEmotionalState(deltaTime) {
|
| 554 |
+
const gameState = this.engine.getGameState();
|
| 555 |
+
const sessionStats = this.memory.shortTerm.sessionStats;
|
| 556 |
+
|
| 557 |
+
// Ajustar mood basado en el rendimiento del jugador
|
| 558 |
+
if (gameState.combo > 10) {
|
| 559 |
+
this.personality.currentMood = 'excited';
|
| 560 |
+
this.personality.energy = Math.min(1.0, this.personality.energy + 0.1);
|
| 561 |
+
} else if (sessionStats.deaths > 3) {
|
| 562 |
+
this.personality.currentMood = 'concerned';
|
| 563 |
+
this.personality.frustration = Math.min(1.0, this.personality.frustration + 0.05);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
// Decay emocional gradual
|
| 567 |
+
this.personality.frustration = Math.max(0, this.personality.frustration - 0.01);
|
| 568 |
+
this.personality.energy = Math.max(0.3, this.personality.energy - 0.005);
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
learnFromPlayer() {
|
| 572 |
+
const playerBehavior = this.responseSystem.contextAnalyzer.analyzePlayerBehavior();
|
| 573 |
+
const currentPlaystyle = this.relationship.playerPreferences.playstyle;
|
| 574 |
+
|
| 575 |
+
// Actualizar preferencias si hay cambio consistente
|
| 576 |
+
if (playerBehavior !== currentPlaystyle) {
|
| 577 |
+
this.relationship.playerPreferences.playstyle = playerBehavior;
|
| 578 |
+
this.adaptPersonalityToPlayer();
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
// Incrementar familiaridad
|
| 582 |
+
this.relationship.familiarity = Math.min(100, this.relationship.familiarity + 0.1);
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
adaptPersonalityToPlayer() {
|
| 586 |
+
const playstyle = this.relationship.playerPreferences.playstyle;
|
| 587 |
+
|
| 588 |
+
switch(playstyle) {
|
| 589 |
+
case 'aggressive':
|
| 590 |
+
this.personality.encouragement += 0.05;
|
| 591 |
+
this.personality.energy += 0.05;
|
| 592 |
+
break;
|
| 593 |
+
case 'defensive':
|
| 594 |
+
this.personality.patience += 0.05;
|
| 595 |
+
this.personality.empathy += 0.05;
|
| 596 |
+
break;
|
| 597 |
+
case 'explorer':
|
| 598 |
+
this.personality.knowledge += 0.05;
|
| 599 |
+
this.personality.humor += 0.05;
|
| 600 |
+
break;
|
| 601 |
+
case 'speedrunner':
|
| 602 |
+
this.personality.energy += 0.1;
|
| 603 |
+
this.personality.encouragement += 0.05;
|
| 604 |
+
break;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
console.log(`🧠 IA adaptada al estilo: ${playstyle}`);
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
// ===================================================================
|
| 611 |
+
// MÉTODOS DE RESPUESTA A EVENTOS
|
| 612 |
+
// ===================================================================
|
| 613 |
+
|
| 614 |
+
onPlayerMove(data) {
|
| 615 |
+
this.recordAction('move', data);
|
| 616 |
+
|
| 617 |
+
// Comentario ocasional sobre movimiento
|
| 618 |
+
if (Math.random() < 0.05) {
|
| 619 |
+
const responses = this.responseDatabase.playerMovement.walking;
|
| 620 |
+
this.queueMessage(this.getRandomElement(responses));
|
| 621 |
+
}
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
onPlayerJump(data) {
|
| 625 |
+
this.recordAction('jump', data);
|
| 626 |
+
|
| 627 |
+
// Reacción a saltos espectaculares
|
| 628 |
+
if (Math.random() < 0.15) {
|
| 629 |
+
const responses = this.responseDatabase.playerMovement.jumping;
|
| 630 |
+
const response = this.getRandomElement(responses);
|
| 631 |
+
this.queueMessage(this.addPersonalityToResponse(response));
|
| 632 |
+
}
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
onPlayerHit(enemyType) {
|
| 636 |
+
this.recordAction('hit', { enemyType });
|
| 637 |
+
this.memory.shortTerm.sessionStats.deaths++;
|
| 638 |
+
|
| 639 |
+
// Reacción específica al tipo de enemigo
|
| 640 |
+
const hitResponses = this.responseDatabase.playerHit[`enemy_${enemyType}`];
|
| 641 |
+
if (hitResponses) {
|
| 642 |
+
const response = this.getRandomElement(hitResponses);
|
| 643 |
+
this.queueMessage(this.addEmotionalContext(response, 'concerned'));
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
// Ajustar relación (preocupación)
|
| 647 |
+
this.relationship.trust = Math.max(0, this.relationship.trust - 1);
|
| 648 |
+
this.personality.frustration += 0.1;
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
onPlayerDeath(cause) {
|
| 652 |
+
this.recordAction('death', { cause });
|
| 653 |
+
|
| 654 |
+
// Respuesta empática a la muerte
|
| 655 |
+
const deathResponses = this.responseDatabase.gameStates.gameOver;
|
| 656 |
+
const response = this.getRandomElement(deathResponses);
|
| 657 |
+
this.queueMessage(this.addEmotionalContext(response, 'empathetic'));
|
| 658 |
+
|
| 659 |
+
// Ofrecer consejo si es la tercera muerte o más
|
| 660 |
+
if (this.memory.shortTerm.sessionStats.deaths >= 3) {
|
| 661 |
+
setTimeout(() => {
|
| 662 |
+
const tip = this.getRandomElement(this.responseDatabase.gameplayTips);
|
| 663 |
+
this.queueMessage(`Pibe, un consejo: ${tip}`);
|
| 664 |
+
}, 3000);
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
onItemCollect(data) {
|
| 669 |
+
this.recordAction('collect', data);
|
| 670 |
+
|
| 671 |
+
// Reacción específica al item
|
| 672 |
+
const itemResponses = this.responseDatabase.itemCollection[data.type];
|
| 673 |
+
if (itemResponses && Math.random() < 0.3) {
|
| 674 |
+
const response = this.getRandomElement(itemResponses);
|
| 675 |
+
this.queueMessage(this.addPersonalityToResponse(response));
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
// Incrementar relación (satisfacción)
|
| 679 |
+
this.relationship.friendship += 0.5;
|
| 680 |
+
this.personality.satisfaction += 0.05;
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
onMateCollected() {
|
| 684 |
+
this.memory.shortTerm.sessionStats.matesUsed++;
|
| 685 |
+
|
| 686 |
+
// Reacción especial al mate (obsesión argentina)
|
| 687 |
+
const mateResponses = this.responseDatabase.itemCollection.mate;
|
| 688 |
+
const response = this.getRandomElement(mateResponses);
|
| 689 |
+
this.queueMessage(this.addArgentinePassion(response));
|
| 690 |
+
|
| 691 |
+
// El mate aumenta mucho la relación
|
| 692 |
+
this.relationship.friendship += 2;
|
| 693 |
+
this.personality.mateObsession = Math.min(1.0, this.personality.mateObsession + 0.05);
|
| 694 |
+
}
|
| 695 |
+
|
| 696 |
+
onComboExecuted(combo) {
|
| 697 |
+
this.recordAction('combo', combo);
|
| 698 |
+
this.memory.shortTerm.sessionStats.bestCombo = Math.max(
|
| 699 |
+
this.memory.shortTerm.sessionStats.bestCombo,
|
| 700 |
+
combo.power
|
| 701 |
+
);
|
| 702 |
+
|
| 703 |
+
// Reacción basada en el poder del combo
|
| 704 |
+
let responseCategory;
|
| 705 |
+
if (combo.power < 150) responseCategory = 'low';
|
| 706 |
+
else if (combo.power < 250) responseCategory = 'medium';
|
| 707 |
+
else responseCategory = 'high';
|
| 708 |
+
|
| 709 |
+
const comboResponses = this.responseDatabase.comboReactions[responseCategory];
|
| 710 |
+
const response = this.getRandomElement(comboResponses);
|
| 711 |
+
this.queueMessage(this.addExcitement(response));
|
| 712 |
+
|
| 713 |
+
// Los combos altos aumentan mucho el respeto
|
| 714 |
+
if (combo.power >= 250) {
|
| 715 |
+
this.relationship.respect += 5;
|
| 716 |
+
this.personality.currentMood = 'amazed';
|
| 717 |
+
}
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
onLevelComplete() {
|
| 721 |
+
this.memory.shortTerm.sessionStats.achievements++;
|
| 722 |
+
|
| 723 |
+
const completeResponses = this.responseDatabase.gameStates.levelComplete;
|
| 724 |
+
const response = this.getRandomElement(completeResponses);
|
| 725 |
+
this.queueMessage(this.addMaximumExcitement(response));
|
| 726 |
+
|
| 727 |
+
// Completar nivel aumenta todas las relaciones
|
| 728 |
+
this.relationship.trust += 3;
|
| 729 |
+
this.relationship.friendship += 3;
|
| 730 |
+
this.relationship.respect += 5;
|
| 731 |
+
this.personality.currentMood = 'proud';
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
onGamePaused() {
|
| 735 |
+
const pauseResponses = this.responseDatabase.gameStates.paused;
|
| 736 |
+
const response = this.getRandomElement(pauseResponses);
|
| 737 |
+
this.queueMessage(this.addPersonalityToResponse(response));
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
onGameOver() {
|
| 741 |
+
const gameOverResponses = this.responseDatabase.gameStates.gameOver;
|
| 742 |
+
const response = this.getRandomElement(gameOverResponses);
|
| 743 |
+
this.queueMessage(this.addEmotionalContext(response, 'supportive'));
|
| 744 |
+
|
| 745 |
+
// Guardar estadísticas de la sesión
|
| 746 |
+
this.saveSessionStats();
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
// ===================================================================
|
| 750 |
+
// MÉTODOS DE COMUNICACIÓN
|
| 751 |
+
// ===================================================================
|
| 752 |
+
|
| 753 |
+
toggleChat() {
|
| 754 |
+
this.chatSystem.isActive = !this.chatSystem.isActive;
|
| 755 |
+
|
| 756 |
+
if (this.chatSystem.isActive) {
|
| 757 |
+
this.showChatInterface();
|
| 758 |
+
this.sendMessage("¡Dale, pibe! ¿Qué querés charlar? Preguntame lo que se te ocurra.");
|
| 759 |
+
} else {
|
| 760 |
+
this.hideChatInterface();
|
| 761 |
+
}
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
sendMessage(message) {
|
| 765 |
+
const processedMessage = this.processOutgoingMessage(message);
|
| 766 |
+
this.queueMessage(processedMessage);
|
| 767 |
+
|
| 768 |
+
// Registrar en memoria
|
| 769 |
+
this.memory.shortTerm.recentConversations.push({
|
| 770 |
+
speaker: 'ai',
|
| 771 |
+
message: processedMessage,
|
| 772 |
+
timestamp: Date.now(),
|
| 773 |
+
context: this.getCurrentContext()
|
| 774 |
+
});
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
processIncomingMessage(playerMessage) {
|
| 778 |
+
// Analizar sentimiento del mensaje del jugador
|
| 779 |
+
const sentiment = this.analyzeSentiment(playerMessage);
|
| 780 |
+
this.chatSystem.sentimentAnalysis.lastPlayerSentiment = sentiment;
|
| 781 |
+
|
| 782 |
+
// Registrar en memoria
|
| 783 |
+
this.memory.shortTerm.recentConversations.push({
|
| 784 |
+
speaker: 'player',
|
| 785 |
+
message: playerMessage,
|
| 786 |
+
timestamp: Date.now(),
|
| 787 |
+
sentiment: sentiment
|
| 788 |
+
});
|
| 789 |
+
|
| 790 |
+
// Generar respuesta contextual
|
| 791 |
+
const response = this.generateContextualResponse(playerMessage, sentiment);
|
| 792 |
+
this.sendMessage(response);
|
| 793 |
+
|
| 794 |
+
// Actualizar relación basada en la interacción
|
| 795 |
+
this.updateRelationshipFromConversation(sentiment);
|
| 796 |
+
}
|
| 797 |
+
|
| 798 |
+
generateContextualResponse(playerMessage, sentiment) {
|
| 799 |
+
const context = this.getCurrentContext();
|
| 800 |
+
const personality = this.personality;
|
| 801 |
+
|
| 802 |
+
// Analizar el contenido del mensaje
|
| 803 |
+
const messageAnalysis = this.analyzeMessageContent(playerMessage);
|
| 804 |
+
|
| 805 |
+
// Generar respuesta base
|
| 806 |
+
let response = this.generateBaseResponse(messageAnalysis, sentiment);
|
| 807 |
+
|
| 808 |
+
// Aplicar modificadores de personalidad
|
| 809 |
+
response = this.applyPersonalityModifiers(response, personality);
|
| 810 |
+
|
| 811 |
+
// Agregar toque argentino
|
| 812 |
+
response = this.responseSystem.responseGenerator.addArgentineTouch(response);
|
| 813 |
+
|
| 814 |
+
return response;
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
analyzeMessageContent(message) {
|
| 818 |
+
const lowerMessage = message.toLowerCase();
|
| 819 |
+
|
| 820 |
+
return {
|
| 821 |
+
isQuestion: lowerMessage.includes('?') || lowerMessage.startsWith('qué') || lowerMessage.startsWith('cómo'),
|
| 822 |
+
isGreeting: lowerMessage.includes('hola') || lowerMessage.includes('che'),
|
| 823 |
+
isCompliment: lowerMessage.includes('genial') || lowerMessage.includes('bueno'),
|
| 824 |
+
isComplaint: lowerMessage.includes('malo') || lowerMessage.includes('difícil'),
|
| 825 |
+
mentionsMate: lowerMessage.includes('mate'),
|
| 826 |
+
mentionsFood: lowerMessage.includes('empanada') || lowerMessage.includes('asado'),
|
| 827 |
+
mentionsFootball: lowerMessage.includes('fútbol') || lowerMessage.includes('messi')
|
| 828 |
+
};
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
generateBaseResponse(analysis, sentiment) {
|
| 832 |
+
if (analysis.isGreeting) {
|
| 833 |
+
return this.getRandomElement(this.responseDatabase.greetings);
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
if (analysis.mentionsMate) {
|
| 837 |
+
return "¡Ah, el mate! No hay nada como un buen mate para acompañar cualquier momento. ¿Sabías que el mate es más que una bebida? Es un ritual, una forma de conectar con otros.";
|
| 838 |
+
}
|
| 839 |
+
|
| 840 |
+
if (analysis.mentionsFood) {
|
| 841 |
+
return "¡Uh, la comida argentina! No hay nada como una buena empanada o un asado dominical. La comida es parte de nuestra alma, pibe.";
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
if (analysis.mentionsFootball) {
|
| 845 |
+
return "¡El fútbol! La pasión argentina por excelencia. Desde Maradona hasta Messi, siempre hemos tenido magia en los pies.";
|
| 846 |
+
}
|
| 847 |
+
|
| 848 |
+
if (analysis.isQuestion) {
|
| 849 |
+
return "¡Buena pregunta, pibe! Me encanta cuando sos curioso. Preguntame lo que quieras, que acá estoy para charlar.";
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
// Respuesta genérica basada en sentimiento
|
| 853 |
+
switch(sentiment) {
|
| 854 |
+
case 'positive':
|
| 855 |
+
return "¡Me alegra escuchar eso, pibe! La buena onda siempre es bienvenida.";
|
| 856 |
+
case 'negative':
|
| 857 |
+
return "Ey, no te preocupes. Todos tenemos días difíciles. ¡Dale que juntos salimos adelante!";
|
| 858 |
+
default:
|
| 859 |
+
return "Entiendo, pibe. ¿Hay algo específico en lo que te pueda ayudar?";
|
| 860 |
+
}
|
| 861 |
+
}
|
| 862 |
+
|
| 863 |
+
// ===================================================================
|
| 864 |
+
// MÉTODOS DE PROCESAMIENTO DE RESPUESTAS
|
| 865 |
+
// ===================================================================
|
| 866 |
+
|
| 867 |
+
addPersonalityToResponse(response) {
|
| 868 |
+
const personality = this.personality;
|
| 869 |
+
|
| 870 |
+
// Agregar humor si la personalidad lo permite
|
| 871 |
+
if (personality.humor > 0.7 && Math.random() < 0.3) {
|
| 872 |
+
const humorousAddition = this.generateHumorousAddition();
|
| 873 |
+
response += ` ${humorousAddition}`;
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
// Agregar sarcasmo si es apropiado
|
| 877 |
+
if (personality.sarcasm > 0.6 && Math.random() < 0.2) {
|
| 878 |
+
response = this.addSarcasm(response);
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
return response;
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
addEmotionalContext(response, emotion) {
|
| 885 |
+
const emotionalPrefixes = {
|
| 886 |
+
concerned: "Ey, pibe, ",
|
| 887 |
+
empathetic: "Tranqui, maestro, ",
|
| 888 |
+
supportive: "Dale que no te preocupes, ",
|
| 889 |
+
excited: "¡Uh, qué bueno! "
|
| 890 |
+
};
|
| 891 |
+
|
| 892 |
+
const prefix = emotionalPrefixes[emotion] || "";
|
| 893 |
+
return prefix + response;
|
| 894 |
+
}
|
| 895 |
+
|
| 896 |
+
addArgentinePassion(response) {
|
| 897 |
+
const passionatePrefixes = [
|
| 898 |
+
"¡Por favor! ",
|
| 899 |
+
"¡Mamita querida! ",
|
| 900 |
+
"¡La pucha que pariu! ",
|
| 901 |
+
"¡Increíble! "
|
| 902 |
+
];
|
| 903 |
+
|
| 904 |
+
const prefix = this.getRandomElement(passionatePrefixes);
|
| 905 |
+
return prefix + response;
|
| 906 |
+
}
|
| 907 |
+
|
| 908 |
+
addExcitement(response) {
|
| 909 |
+
// Convertir a mayúsculas para mostrar emoción
|
| 910 |
+
if (this.personality.energy > 0.8) {
|
| 911 |
+
response = response.toUpperCase();
|
| 912 |
+
}
|
| 913 |
+
|
| 914 |
+
// Agregar emojis emocionales
|
| 915 |
+
const excitedEmojis = ['🔥', '⚡', '🚀', '💥', '🎉'];
|
| 916 |
+
const emoji = this.getRandomElement(excitedEmojis);
|
| 917 |
+
|
| 918 |
+
return `${response} ${emoji}`;
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
addMaximumExcitement(response) {
|
| 922 |
+
response = response.toUpperCase();
|
| 923 |
+
const multipleEmojis = ['🔥🔥🔥', '⚡⚡⚡', '🚀🚀🚀'];
|
| 924 |
+
const emojis = this.getRandomElement(multipleEmojis);
|
| 925 |
+
|
| 926 |
+
return `${emojis} ${response} ${emojis}`;
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
// ===================================================================
|
| 930 |
+
// MÉTODOS AUXILIARES
|
| 931 |
+
// ===================================================================
|
| 932 |
+
|
| 933 |
+
shouldMakeAutomaticComment() {
|
| 934 |
+
const timeSinceLastComment = Date.now() - this.lastAutomaticComment;
|
| 935 |
+
const minInterval = 15000; // 15 segundos mínimo
|
| 936 |
+
|
| 937 |
+
return timeSinceLastComment > minInterval &&
|
| 938 |
+
Math.random() < 0.3 &&
|
| 939 |
+
!this.chatSystem.isActive;
|
| 940 |
+
}
|
| 941 |
+
|
| 942 |
+
makeAutomaticComment() {
|
| 943 |
+
const context = this.getCurrentContext();
|
| 944 |
+
const gameState = this.engine.getGameState();
|
| 945 |
+
|
| 946 |
+
let comment;
|
| 947 |
+
|
| 948 |
+
// Comentario basado en el contexto actual
|
| 949 |
+
if (gameState.health < 30) {
|
| 950 |
+
comment = "Ey, pibe, cuidate un poco. La salud es lo primero.";
|
| 951 |
+
} else if (gameState.combo > 5) {
|
| 952 |
+
comment = "¡Uh, qué racha! Estás que te salís, maestro.";
|
| 953 |
+
} else if (this.personality.currentMood === 'excited') {
|
| 954 |
+
comment = this.getRandomElement(this.responseDatabase.expressions.positive) + " ¡Qué buena onda que tenés!";
|
| 955 |
+
} else {
|
| 956 |
+
comment = this.getRandomElement(this.responseDatabase.gameplayTips);
|
| 957 |
+
}
|
| 958 |
+
|
| 959 |
+
this.queueMessage(comment);
|
| 960 |
+
this.lastAutomaticComment = Date.now();
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
queueMessage(message) {
|
| 964 |
+
this.chatSystem.messageQueue.push(message);
|
| 965 |
+
}
|
| 966 |
+
|
| 967 |
+
displayMessage(message) {
|
| 968 |
+
const chatElement = document.getElementById('aiMessageMatrix');
|
| 969 |
+
if (chatElement) {
|
| 970 |
+
chatElement.textContent = message;
|
| 971 |
+
|
| 972 |
+
// Mostrar el chat si no está visible
|
| 973 |
+
const companionElement = document.getElementById('aiCompanionMatrix');
|
| 974 |
+
if (companionElement && !companionElement.classList.contains('active')) {
|
| 975 |
+
companionElement.classList.add('active');
|
| 976 |
+
|
| 977 |
+
// Ocultar después de 5 segundos si no está en modo chat
|
| 978 |
+
if (!this.chatSystem.isActive) {
|
| 979 |
+
setTimeout(() => {
|
| 980 |
+
companionElement.classList.remove('active');
|
| 981 |
+
}, 5000);
|
| 982 |
+
}
|
| 983 |
+
}
|
| 984 |
+
}
|
| 985 |
+
}
|
| 986 |
+
|
| 987 |
+
calculateResponseDelay() {
|
| 988 |
+
const config = this.chatSystem.responseConfig;
|
| 989 |
+
const baseDelay = Math.random() * (config.responseDelay.max - config.responseDelay.min) + config.responseDelay.min;
|
| 990 |
+
|
| 991 |
+
// Ajustar delay basado en personalidad
|
| 992 |
+
const personalityMultiplier = this.personality.patience;
|
| 993 |
+
|
| 994 |
+
return baseDelay * personalityMultiplier;
|
| 995 |
+
}
|
| 996 |
+
|
| 997 |
+
recordAction(type, data) {
|
| 998 |
+
this.memory.shortTerm.recentActions.push({
|
| 999 |
+
type,
|
| 1000 |
+
data,
|
| 1001 |
+
timestamp: Date.now()
|
| 1002 |
+
});
|
| 1003 |
+
|
| 1004 |
+
// Mantener solo las últimas 50 acciones
|
| 1005 |
+
if (this.memory.shortTerm.recentActions.length > 50) {
|
| 1006 |
+
this.memory.shortTerm.recentActions.shift();
|
| 1007 |
+
}
|
| 1008 |
+
|
| 1009 |
+
this.relationship.totalInteractions++;
|
| 1010 |
+
}
|
| 1011 |
+
|
| 1012 |
+
getCurrentContext() {
|
| 1013 |
+
return {
|
| 1014 |
+
gameState: this.engine.getGameState(),
|
| 1015 |
+
playerState: this.engine.getPlayer(),
|
| 1016 |
+
aiMood: this.personality.currentMood,
|
| 1017 |
+
relationship: this.relationship,
|
| 1018 |
+
timestamp: Date.now()
|
| 1019 |
+
};
|
| 1020 |
+
}
|
| 1021 |
+
|
| 1022 |
+
analyzeSentiment(message) {
|
| 1023 |
+
const positiveWords = ['bueno', 'genial', 'excelente', 'increíble', 'fantástico', 'me gusta'];
|
| 1024 |
+
const negativeWords = ['malo', 'terrible', 'odio', 'difícil', 'imposible', 'frustrante'];
|
| 1025 |
+
|
| 1026 |
+
const lowerMessage = message.toLowerCase();
|
| 1027 |
+
const positiveCount = positiveWords.filter(word => lowerMessage.includes(word)).length;
|
| 1028 |
+
const negativeCount = negativeWords.filter(word => lowerMessage.includes(word)).length;
|
| 1029 |
+
|
| 1030 |
+
if (positiveCount > negativeCount) return 'positive';
|
| 1031 |
+
if (negativeCount > positiveCount) return 'negative';
|
| 1032 |
+
return 'neutral';
|
| 1033 |
+
}
|
| 1034 |
+
|
| 1035 |
+
updateRelationshipFromConversation(sentiment) {
|
| 1036 |
+
switch(sentiment) {
|
| 1037 |
+
case 'positive':
|
| 1038 |
+
this.relationship.friendship += 1;
|
| 1039 |
+
this.relationship.trust += 0.5;
|
| 1040 |
+
this.relationship.positiveInteractions++;
|
| 1041 |
+
break;
|
| 1042 |
+
case 'negative':
|
| 1043 |
+
this.relationship.friendship = Math.max(0, this.relationship.friendship - 0.5);
|
| 1044 |
+
this.relationship.negativeInteractions++;
|
| 1045 |
+
break;
|
| 1046 |
+
default:
|
| 1047 |
+
this.relationship.familiarity += 0.5;
|
| 1048 |
+
}
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
savePersistentMemory() {
|
| 1052 |
+
try {
|
| 1053 |
+
const memoryToSave = {
|
| 1054 |
+
relationship: this.relationship,
|
| 1055 |
+
culturalKnowledge: Object.fromEntries(this.memory.culturalKnowledge),
|
| 1056 |
+
conversationHistory: this.memory.longTerm.conversationHistory.slice(-100) // Solo últimas 100
|
| 1057 |
+
};
|
| 1058 |
+
|
| 1059 |
+
localStorage.setItem('nexus_ai_memory', JSON.stringify(memoryToSave));
|
| 1060 |
+
} catch (error) {
|
| 1061 |
+
console.warn('⚠️ Error guardando memoria persistente:', error);
|
| 1062 |
+
}
|
| 1063 |
+
}
|
| 1064 |
+
|
| 1065 |
+
saveSessionStats() {
|
| 1066 |
+
const stats = this.memory.shortTerm.sessionStats;
|
| 1067 |
+
stats.endTime = Date.now();
|
| 1068 |
+
stats.sessionDuration = stats.endTime - stats.startTime;
|
| 1069 |
+
|
| 1070 |
+
// Agregar a historial de sesiones
|
| 1071 |
+
this.memory.longTerm.sessionHistory = this.memory.longTerm.sessionHistory || [];
|
| 1072 |
+
this.memory.longTerm.sessionHistory.push({...stats});
|
| 1073 |
+
|
| 1074 |
+
this.savePersistentMemory();
|
| 1075 |
+
}
|
| 1076 |
+
|
| 1077 |
+
getRandomElement(array) {
|
| 1078 |
+
return array[Math.floor(Math.random() * array.length)];
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
showChatInterface() {
|
| 1082 |
+
const companionElement = document.getElementById('aiCompanionMatrix');
|
| 1083 |
+
if (companionElement) {
|
| 1084 |
+
companionElement.classList.add('active');
|
| 1085 |
+
}
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
+
hideChatInterface() {
|
| 1089 |
+
if (!this.chatSystem.messageQueue.length) {
|
| 1090 |
+
const companionElement = document.getElementById('aiCompanionMatrix');
|
| 1091 |
+
if (companionElement) {
|
| 1092 |
+
companionElement.classList.remove('active');
|
| 1093 |
+
}
|
| 1094 |
+
}
|
| 1095 |
+
}
|
| 1096 |
+
|
| 1097 |
+
// ===================================================================
|
| 1098 |
+
// MÉTODOS PÚBLICOS
|
| 1099 |
+
// ===================================================================
|
| 1100 |
+
|
| 1101 |
+
greet() {
|
| 1102 |
+
setTimeout(() => {
|
| 1103 |
+
const greeting = this.getRandomElement(this.responseDatabase.greetings);
|
| 1104 |
+
this.sendMessage(greeting);
|
| 1105 |
+
}, 2000);
|
| 1106 |
+
}
|
| 1107 |
+
|
| 1108 |
+
getPersonalityInfo() {
|
| 1109 |
+
return {
|
| 1110 |
+
personality: this.personality,
|
| 1111 |
+
relationship: this.relationship,
|
| 1112 |
+
currentMood: this.personality.currentMood
|
| 1113 |
+
};
|
| 1114 |
+
}
|
| 1115 |
+
|
| 1116 |
+
getMemoryStats() {
|
| 1117 |
+
return {
|
| 1118 |
+
shortTermActions: this.memory.shortTerm.recentActions.length,
|
| 1119 |
+
longTermConversations: this.memory.longTerm.conversationHistory.length,
|
| 1120 |
+
culturalKnowledge: this.memory.culturalKnowledge.size,
|
| 1121 |
+
sessionStats: this.memory.shortTerm.sessionStats
|
| 1122 |
+
};
|
| 1123 |
+
}
|
| 1124 |
+
|
| 1125 |
+
resetPersonality() {
|
| 1126 |
+
// Resetear a valores por defecto manteniendo aprendizaje básico
|
| 1127 |
+
this.personality.currentMood = 'excited';
|
| 1128 |
+
this.personality.energy = 0.85;
|
| 1129 |
+
this.personality.frustration = 0.10;
|
| 1130 |
+
this.personality.satisfaction = 0.75;
|
| 1131 |
+
|
| 1132 |
+
console.log('🔄 Personalidad de IA reseteada');
|
| 1133 |
+
}
|
| 1134 |
+
}
|
| 1135 |
+
|
| 1136 |
+
// ===================================================================
|
| 1137 |
+
// EXPORTAR PARA USO GLOBAL
|
| 1138 |
+
// ===================================================================
|
| 1139 |
+
|
| 1140 |
+
window.AdvancedAICompanion = AdvancedAICompanion;
|
| 1141 |
+
|
| 1142 |
+
console.log('🤖 Sistema de IA Compañero Avanzado cargado correctamente');
|