use of nars.truth.TruthFunctions in project narchy by automenta.
the class BeliefTableChart method renderTable.
private void renderTable(Concept c, long minT, long maxT, long now, GL2 gl, TruthWave wave, boolean beliefOrGoal) {
if (c == null)
return;
float nowX = xTime(minT, maxT, now);
// Present axis line
if ((now <= maxT) && (now >= minT)) {
gl.glColor4f(1f, 1f, 1f, 0.5f);
Draw.line(gl, nowX, 0, nowX, 1);
// float nowLineWidth = 0.005f;
// Draw.rect(gl, nowX - nowLineWidth / 2f, 0, nowLineWidth, 1);
}
/**
* drawn "pixel" dimensions
*/
renderWave(nowX, minT, maxT, gl, wave, beliefOrGoal);
// draw projections
if (projections > 0 && minT != maxT) {
for (boolean freqOrExp : new boolean[] { true, false }) {
TruthWave pwave = beliefOrGoal ? beliefProj : goalProj;
// HACK dont show expectation for beliefs
if (beliefOrGoal && !freqOrExp)
continue;
Colorize colorize;
if (freqOrExp) {
colorize = beliefOrGoal ? (ggl, frq, cnf) -> {
float a = 0.65f + 0.2f * cnf;
ggl.glColor4f(0.25f + 0.75f * cnf, 0.1f * (1f - cnf), 0, a);
} : (ggl, frq, cnf) -> {
float a = 0.65f + 0.2f * cnf;
ggl.glColor4f(0.1f * (1f - cnf), 0.25f + 0.75f * cnf, 0, a);
};
} else {
colorize = beliefOrGoal ? (ggl, frq, cnf) -> {
ggl.glColor4f(cnf, cnf / 2f, 0.25f, 0.85f);
} : (ggl, frq, cnf) -> {
ggl.glColor4f(cnf / 2f, cnf, 0.25f, 0.85f);
};
}
FloatFloatToFloatFunction y = freqOrExp ? (frq, cnf) -> frq : TruthFunctions::expectation;
// HACK show goal freq in thinner line
gl.glLineWidth((freqOrExp && !beliefOrGoal) ? 2f : 4f);
renderWaveLine(nowX, minT, maxT, gl, pwave, y, colorize);
}
}
float chSize = 0.1f;
Truth bc = wave.current;
if (bc != null) {
float theta;
float expectation = bc.expectation();
float dTheta = (expectation - 0.5f) * angleSpeed;
float conf = bc.conf();
if (beliefOrGoal) {
this.beliefTheta += dTheta;
theta = beliefTheta;
gl.glColor4f(1f, 0f, 0, 0.2f + 0.8f * conf);
drawCrossHair(gl, nowX, chSize, bc.freq(), conf, theta);
} else {
this.goalTheta += dTheta;
theta = goalTheta;
// //freq
// gl.glColor4f(0f, 1f, 0, 0.2f + 0.8f * conf);
// drawCrossHair(gl, nowX, chSize, bc.freq(), conf, theta);
// expectation
gl.glColor4f(0f, 1f, 0, 0.2f + 0.8f * conf);
drawCrossHair(gl, nowX, chSize, expectation, expectation, theta);
}
}
}
Aggregations