// designing sociable robots p 108-109 class Drive { float arousal; float valence; float ADrive; float target; Drive() { valence=1.0; arousal=1.0; ADrive=1.00; target=1000.0; } void update() { float delta=ADrive-target; if(delta<0) { // understimulated ADrive*=1.1; } else if (delta>0) { // overstimulated ADrive*=1.1; } else { //homeostatic, ok. } } void setTarget(float newTarget) { target=newTarget; } void stimulate(float intensity) { } void evaluate() { } float getEnergy() { return ADrive; } } class Emotion { float activation; Emotion() { activation=0.0; } void express() { } } class SocAgent { Drive social, stimulation, fatigue; Emotion anger, disgust, fear, calm, joy, sorrow, suprise, interest, boredom; float threshold; SocAgent() { threshold=1000; social = new Drive(); stimulation = new Drive(); fatigue = new Drive(); } void sleep() { println("zzz...."); } void update() { social.update(); stimulation.update(); fatigue.update(); } void evaluate() { if(fatigue.getEnergy()>threshold) { sleep(); } } void render() { println("\tsocial: "+social.getEnergy()); println("\tstimulation: "+stimulation.getEnergy()); println("\tfatigue: "+fatigue.getEnergy()); } } SocAgent kismet; int t; void setup() { size(400, 400); kismet = new SocAgent(); t=0; } void draw() { kismet.update(); kismet.evaluate(); println("frame "+frameCount); kismet.render(); delay(1000); t++; }