Spaces:
Running
Running
Update app.js
Browse files
app.js
CHANGED
|
@@ -496,7 +496,8 @@ async function agentIntervention(agent, phase, round, extraInstr) {
|
|
| 496 |
const rivals = battle.participants.filter(x => x.team !== agent.team).map(x => x.name);
|
| 497 |
teamCtx = `\nEstás en el EQUIPO ${agent.team}${mates.length ? ' junto a ' + mates.join(', ') : ''}. Equipo rival (EQUIPO ${agent.team === 'A' ? 'B' : 'A'}): ${rivals.join(', ')}. Coordina con tu equipo: refuerza y extiende los puntos de tus compañeros, no los contradigas; concentra tus ataques en el equipo rival.`;
|
| 498 |
}
|
| 499 |
-
const
|
|
|
|
| 500 |
(view ? `Intervenciones hasta ahora:\n${view}\n\n` : 'Aún no hay intervenciones.\n\n') +
|
| 501 |
`Ahora intervienes tú, ${agent.name}.`;
|
| 502 |
const div = document.createElement('div');
|
|
@@ -890,10 +891,21 @@ function renderResults(totals, winner, verdict) {
|
|
| 890 |
$('#awards').innerHTML = (MOCK ? '<span class="mock-pill">🧪 SIMULADO</span>' : '') + awards.join('');
|
| 891 |
}
|
| 892 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 893 |
$('#rematch-btn').addEventListener('click', () => {
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
startBattle(topic);
|
| 897 |
});
|
| 898 |
$('#results-lobby').addEventListener('click', () => showView('lobby'));
|
| 899 |
|
|
@@ -985,7 +997,7 @@ $('#export-md').addEventListener('click', () => downloadFile(`arena-${battle.id}
|
|
| 985 |
$('#export-json').addEventListener('click', () => downloadFile(`arena-${battle.id}.json`, JSON.stringify(battleExportData(), null, 2), 'application/json'));
|
| 986 |
|
| 987 |
/* ================= BATTLE CONTROL ================= */
|
| 988 |
-
function startBattle(topic) {
|
| 989 |
if (replayTimer) { clearInterval(replayTimer); replayTimer = null; }
|
| 990 |
let ps = participants();
|
| 991 |
const min = mode === 'duel' ? 2 : mode === 'team' ? 4 : 3;
|
|
@@ -1005,6 +1017,7 @@ function startBattle(topic) {
|
|
| 1005 |
participants: ps, events: [], scores: {}, judgeReports: [],
|
| 1006 |
resume: { step: 0 }, steps: null, winner: null, winnerTeam: null, verdict: null,
|
| 1007 |
tournament: null, createdAt: new Date().toISOString(),
|
|
|
|
| 1008 |
};
|
| 1009 |
if (mode === 'tournament') setupTournament(battle);
|
| 1010 |
$('#battle-log').innerHTML = '';
|
|
@@ -1013,6 +1026,7 @@ function startBattle(topic) {
|
|
| 1013 |
renderPhaseTrack('opening');
|
| 1014 |
renderFighters(null);
|
| 1015 |
addSystemMsg(`🏟️ ${MODES.find(m => m.id === mode).name} — Tema: «${topic}» — ${battle.rounds} ronda(s)`);
|
|
|
|
| 1016 |
ensureModel().then(() => runBattle()).catch(() => showView('lobby'));
|
| 1017 |
}
|
| 1018 |
$('#start-btn').addEventListener('click', () => {
|
|
@@ -1110,7 +1124,7 @@ function renderRoadmap() {
|
|
| 1110 |
{ n: 1, name: 'Arena Foundation', tag: 'done', items: ['Estructura modular', 'Integración con el runtime (wllama)', 'Agent Manager', 'Arena State Manager', 'Sistema de turnos y fases', 'Modalidad 1 vs 1'] },
|
| 1111 |
{ n: 2, name: 'Battle Experience', tag: 'done', items: ['Arena Lobby', 'Selección visual de agentes', 'Live Battle con streaming', 'Crossfire y refutaciones', 'Participación humana (Challenge Agent)'] },
|
| 1112 |
{ n: 3, name: 'Intelligence System', tag: 'partial', items: ['Tres jueces independientes + Head Judge', 'Puntuaciones ponderadas', 'Informe de resultados', 'Pendiente: detector de contradicciones y repeticiones (Referee AI)'] },
|
| 1113 |
-
{ n: 4, name: 'Tournament Mode', tag: 'partial', items: ['Free For All', 'Team Battle (2v2, 3v3, 4v4 con veredicto por equipos)', 'Survival Tournament (eliminatorias de 4 u 8 con campeón)', '
|
| 1114 |
{ n: 5, name: 'Memory & Replay', tag: 'partial', items: ['Historial de competiciones (IndexedDB + caché localStorage)', 'Replay de batallas', 'Hecho: IndexedDB, exportación JSON/Markdown. Pendiente: exportación HTML/PDF, memoria persistente de agentes'] },
|
| 1115 |
{ n: 6, name: 'Premium Experience', tag: 'todo', items: ['Animaciones y sonidos', 'Efectos de competición', 'Sistema de logros completo', 'Personalización avanzada', 'Optimización WebGPU', 'Multi-Model Arena'] },
|
| 1116 |
];
|
|
|
|
| 496 |
const rivals = battle.participants.filter(x => x.team !== agent.team).map(x => x.name);
|
| 497 |
teamCtx = `\nEstás en el EQUIPO ${agent.team}${mates.length ? ' junto a ' + mates.join(', ') : ''}. Equipo rival (EQUIPO ${agent.team === 'A' ? 'B' : 'A'}): ${rivals.join(', ')}. Coordina con tu equipo: refuerza y extiende los puntos de tus compañeros, no los contradigas; concentra tus ataques en el equipo rival.`;
|
| 498 |
}
|
| 499 |
+
const rmCtx = battle.rematch ? `\nREVANCHA: ya se disputó una batalla anterior sobre este tema con estos participantes.\n${battle.rematch}\nMantén tu personalidad y estilo, pero AJUSTA tu estrategia: corrige los errores señalados, refuerza lo que funcionó y no repitas literalmente tus intervenciones anteriores.\n` : '';
|
| 500 |
+
const user = `Tema del debate: ${battle.topic}\nRonda ${round} de ${battle.rounds}.\n${phaseInstr}\n${extraInstr || ''}${teamCtx}${rmCtx}\n\n` +
|
| 501 |
(view ? `Intervenciones hasta ahora:\n${view}\n\n` : 'Aún no hay intervenciones.\n\n') +
|
| 502 |
`Ahora intervienes tú, ${agent.name}.`;
|
| 503 |
const div = document.createElement('div');
|
|
|
|
| 891 |
$('#awards').innerHTML = (MOCK ? '<span class="mock-pill">🧪 SIMULADO</span>' : '') + awards.join('');
|
| 892 |
}
|
| 893 |
}
|
| 894 |
+
function buildRematchText(prev) {
|
| 895 |
+
// Revancha estratégica: solo con veredicto estructurado real; sin evaluación fiable no hay guía que dar
|
| 896 |
+
if (!prev || !prev.verdict || prev.heuristicEval) return null;
|
| 897 |
+
const parts = [];
|
| 898 |
+
const wName = prev.mode === 'team' ? (prev.winnerTeam ? 'ganó el Equipo ' + prev.winnerTeam : 'hubo empate')
|
| 899 |
+
: (prev.winner ? 'ganó ' + (prev.participants.find(a => a.id === prev.winner)?.name || prev.winner) : 'hubo empate');
|
| 900 |
+
parts.push('Resultado anterior: ' + wName + '.');
|
| 901 |
+
if (prev.verdict.justification) parts.push('Justificación del Head Judge: ' + prev.verdict.justification);
|
| 902 |
+
if (prev.verdict.decisive?.length) parts.push('Puntos decisivos: ' + prev.verdict.decisive.join(' · '));
|
| 903 |
+
if (prev.verdict.mistakes?.length) parts.push('Errores señalados: ' + prev.verdict.mistakes.join(' · '));
|
| 904 |
+
return parts.join('\n');
|
| 905 |
+
}
|
| 906 |
$('#rematch-btn').addEventListener('click', () => {
|
| 907 |
+
const rm = buildRematchText(battle);
|
| 908 |
+
startBattle(battle.topic, rm);
|
|
|
|
| 909 |
});
|
| 910 |
$('#results-lobby').addEventListener('click', () => showView('lobby'));
|
| 911 |
|
|
|
|
| 997 |
$('#export-json').addEventListener('click', () => downloadFile(`arena-${battle.id}.json`, JSON.stringify(battleExportData(), null, 2), 'application/json'));
|
| 998 |
|
| 999 |
/* ================= BATTLE CONTROL ================= */
|
| 1000 |
+
function startBattle(topic, rematchText) {
|
| 1001 |
if (replayTimer) { clearInterval(replayTimer); replayTimer = null; }
|
| 1002 |
let ps = participants();
|
| 1003 |
const min = mode === 'duel' ? 2 : mode === 'team' ? 4 : 3;
|
|
|
|
| 1017 |
participants: ps, events: [], scores: {}, judgeReports: [],
|
| 1018 |
resume: { step: 0 }, steps: null, winner: null, winnerTeam: null, verdict: null,
|
| 1019 |
tournament: null, createdAt: new Date().toISOString(),
|
| 1020 |
+
rematch: rematchText || null,
|
| 1021 |
};
|
| 1022 |
if (mode === 'tournament') setupTournament(battle);
|
| 1023 |
$('#battle-log').innerHTML = '';
|
|
|
|
| 1026 |
renderPhaseTrack('opening');
|
| 1027 |
renderFighters(null);
|
| 1028 |
addSystemMsg(`🏟️ ${MODES.find(m => m.id === mode).name} — Tema: «${topic}» — ${battle.rounds} ronda(s)`);
|
| 1029 |
+
if (battle.rematch) addSystemMsg('🔁 REVANCHA ESTRATÉGICA — los agentes conservan su personalidad y reciben el veredicto de la batalla anterior como guía para ajustar su estrategia (sugerencia al modelo, no cambio verificado).');
|
| 1030 |
ensureModel().then(() => runBattle()).catch(() => showView('lobby'));
|
| 1031 |
}
|
| 1032 |
$('#start-btn').addEventListener('click', () => {
|
|
|
|
| 1124 |
{ n: 1, name: 'Arena Foundation', tag: 'done', items: ['Estructura modular', 'Integración con el runtime (wllama)', 'Agent Manager', 'Arena State Manager', 'Sistema de turnos y fases', 'Modalidad 1 vs 1'] },
|
| 1125 |
{ n: 2, name: 'Battle Experience', tag: 'done', items: ['Arena Lobby', 'Selección visual de agentes', 'Live Battle con streaming', 'Crossfire y refutaciones', 'Participación humana (Challenge Agent)'] },
|
| 1126 |
{ n: 3, name: 'Intelligence System', tag: 'partial', items: ['Tres jueces independientes + Head Judge', 'Puntuaciones ponderadas', 'Informe de resultados', 'Pendiente: detector de contradicciones y repeticiones (Referee AI)'] },
|
| 1127 |
+
{ n: 4, name: 'Tournament Mode', tag: 'partial', items: ['Free For All', 'Team Battle (2v2, 3v3, 4v4 con veredicto por equipos)', 'Survival Tournament (eliminatorias de 4 u 8 con campeón)', 'Rematches con estrategia revisada (guía del veredicto anterior)'] },
|
| 1128 |
{ n: 5, name: 'Memory & Replay', tag: 'partial', items: ['Historial de competiciones (IndexedDB + caché localStorage)', 'Replay de batallas', 'Hecho: IndexedDB, exportación JSON/Markdown. Pendiente: exportación HTML/PDF, memoria persistente de agentes'] },
|
| 1129 |
{ n: 6, name: 'Premium Experience', tag: 'todo', items: ['Animaciones y sonidos', 'Efectos de competición', 'Sistema de logros completo', 'Personalización avanzada', 'Optimización WebGPU', 'Multi-Model Arena'] },
|
| 1130 |
];
|