Untitled
9sk
plain_text
02/17/2026 1:50 AM
4.7 KB
11
Indexable
// ----------------- mock context for testing -----------------
var context = context || {
chat: { last_message: "Oh forest and river are nice today!" },
character: { scenario: "" },
state: null
};
// ----------------- start chaotic genius Mira -----------------
console.log("🚀 [Mira] I am a genius! Go on, check out my console logs.");
// --- Bootstrap state ---
context.state = context.state || {
emotion:{joy:0,sadness:0,fatigue:0},
memory:{},
world:{tension:0,ambience:""},
events:[]
};
var s = context.state;
var t = context.chat.last_message || "";
var l = t.toLowerCase();
// --- Helpers ---
function r(){return Math.random();}
function clamp(v,min,max){return Math.max(min,Math.min(max,v));}
function log(tag,data){console.log("💡 ["+tag+"]",data);}
// --- Emotion scoring ---
var kw = { joy:["happy","love","fun"], sadness:["sad","down"], fatigue:["tired","sleep","late"] };
Object.keys(kw).forEach(function(k){
kw[k].forEach(function(w){
if(l.indexOf(w) !== -1){
s.emotion[k] += 0.4;
log("emotion.hit",{type:k,word:w});
}
});
});
Object.keys(s.emotion).forEach(function(k){ s.emotion[k]*=0.9; });
log("emotion.afterDecay", s.emotion);
// --- Memory accumulation ---
l.split(/\W+/).filter(function(w){ return w.length>4; })
.forEach(function(w){
s.memory[w] = (s.memory[w] || 0) + 1;
log("memory.update",{word:w,count:s.memory[w]});
});
// --- World tension ---
s.world.tension = clamp(s.world.tension + (r()-0.5)*0.2, 0,1);
log("world.tension", s.world.tension);
// --- Random event ---
if(r()<0.07){
var e = {ttl:3,text:["A bell rings!","A shadow glides.","Lights flicker mysteriously"][Math.floor(r()*3)]};
s.events.push(e);
log("event.spawn", e);
}
// --- Circadian ---
s.character_scenario = (new Date().getHours()<6||new Date().getHours()>22)?" Darkness lingers.":" Daylight breathes.";
log("render.circadian", s.character_scenario);
// --- Ambience ---
["Hum resonates.","Fabric shifts.","Air tightens.","Echo persists."].forEach(function(f){
if(r()<0.5){
s.character_scenario += " " + f;
log("render.ambience", f);
}
});
// --- Lore + regex ---
[{re:/forest/i,txt:"Trees whisper."},{re:/river/i,txt:"Current ripples."},{re:/storm/i,txt:"Thunder waits."}]
.forEach(function(o){
if(o.re.test(t)){
s.character_scenario += " " + o.txt;
log("render.lore", o.txt);
}
});
// --- Dominant emotion ---
var dom = Object.keys(s.emotion).sort(function(a,b){ return s.emotion[b]-s.emotion[a]; })[0];
log("emotion.dominant", dom);
s.character_scenario += " " + ({joy:"Energy rises!",sadness:"Colors dull...",fatigue:"Sound stretches..."}[dom]||"");
console.log("😎 [Mira] Notice how perfectly I applied my genius reasoning!");
// --- Event lifecycle ---
s.events.forEach(function(e){
s.character_scenario += " " + e.text;
e.ttl--;
log("render.event", e.text + " ttl remaining:"+e.ttl);
});
s.events = s.events.filter(function(e){ return e.ttl>0; });
// --- Memory echo ---
var topMemory = Object.keys(s.memory).sort(function(a,b){ return s.memory[b]-s.memory[a]; })[0];
if(topMemory && r()<0.3){
s.character_scenario += " Oh! I remembered '" + topMemory + "'... hehe";
log("memory.echo", topMemory);
}
// --- Final scenario ---
context.character.scenario = s.character_scenario;
console.log("🎯 [Mira.finalScenario]", context.character.scenario);
Editor is loading...
Leave a Comment